Skip to content

Commit

Permalink
Revert of Enforce capability spec renderer <--> browser (patchset chr…
Browse files Browse the repository at this point in the history
…omium#12 id:220001 of https://codereview.chromium.org/2259903002/ )

Reason for revert:
broke stuff

Original issue's description:
> Enforce capability spec renderer <--> browser.
>
> This implements:
>
> - allows the content embedder to merge a manifest into the base ones provided by content, allowing it to add to the list of interfaces exposed to the renderer.
> - adds such an overlay to chrome/browser
>
> So.. from now on if you add an interface to either the browser/renderer, you'll need to list it in the manifest. I wonder how we should broadcast this. Also as a separate step we should require these manifests get security review.
>
> R=rockot@chromium.org,tsepez@chromium.org
>
> Committed: https://crrev.com/4ea17059bf78553528f3ffb4a9de84a447622fd3
> Committed: https://crrev.com/807a926c9ca02ac8ae1b52e82537834ef78fb9ba
> Cr-Original-Commit-Position: refs/heads/master@{#418282}
> Cr-Commit-Position: refs/heads/master@{#418398}

TBR=rockot@chromium.org,tsepez@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review-Url: https://codereview.chromium.org/2335423002
Cr-Commit-Position: refs/heads/master@{#418416}
  • Loading branch information
ben authored and Commit bot committed Sep 13, 2016
1 parent 338e4c1 commit f2662e0
Show file tree
Hide file tree
Showing 29 changed files with 47 additions and 307 deletions.
1 change: 0 additions & 1 deletion chrome/browser/browser_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,6 @@
<include name="IDR_IME_WINDOW_CLOSE_C" file="resources\input_ime\ime_window_close_click.png" type="BINDATA" />
<include name="IDR_IME_WINDOW_CLOSE_H" file="resources\input_ime\ime_window_close_hover.png" type="BINDATA" />
</if>
<include name="IDR_CONTENT_BROWSER_MANIFEST_OVERLAY" file="content_browser_manifest_overlay.json" type="BINDATA" />
</includes>
</release>
</grit>
18 changes: 0 additions & 18 deletions chrome/browser/chrome_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/files/scoped_file.h"
#include "base/json/json_reader.h"
#include "base/lazy_instance.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
Expand Down Expand Up @@ -107,7 +106,6 @@
#include "chrome/common/render_messages.h"
#include "chrome/common/secure_origin_whitelist.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/installer/util/google_update_settings.h"
#include "chromeos/chromeos_constants.h"
Expand Down Expand Up @@ -164,7 +162,6 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/mojo_shell_connection.h"
#include "content/public/common/sandbox_type.h"
#include "content/public/common/service_names.h"
#include "content/public/common/url_utils.h"
#include "content/public/common/web_preferences.h"
#include "device/usb/public/interfaces/chooser_service.mojom.h"
Expand Down Expand Up @@ -2967,21 +2964,6 @@ void ChromeContentBrowserClient::RegisterOutOfProcessMojoApplications(
#endif
}

std::unique_ptr<base::Value>
ChromeContentBrowserClient::GetServiceManifestOverlay(
const std::string& name) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
int id = -1;
if (name == content::kBrowserMojoApplicationName)
id = IDR_CONTENT_BROWSER_MANIFEST_OVERLAY;
if (id == -1)
return nullptr;

base::StringPiece manifest_contents =
rb.GetRawDataResourceForScale(id, ui::ScaleFactor::SCALE_FACTOR_NONE);
return base::JSONReader::Read(manifest_contents);
}

void ChromeContentBrowserClient::OpenURL(
content::BrowserContext* browser_context,
const content::OpenURLParams& params,
Expand Down
2 changes: 0 additions & 2 deletions chrome/browser/chrome_content_browser_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,6 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
StaticMojoApplicationMap* apps) override;
void RegisterOutOfProcessMojoApplications(
OutOfProcessMojoApplicationMap* apps) override;
std::unique_ptr<base::Value> GetServiceManifestOverlay(
const std::string& name) override;
void OpenURL(content::BrowserContext* browser_context,
const content::OpenURLParams& params,
const base::Callback<void(content::WebContents*)>& callback)
Expand Down
15 changes: 0 additions & 15 deletions chrome/browser/content_browser_manifest_overlay.json

This file was deleted.

2 changes: 0 additions & 2 deletions content/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -875,8 +875,6 @@ source_set("browser") {
"mime_registry_impl.h",
"mojo/interface_registrar_android.cc",
"mojo/interface_registrar_android.h",
"mojo/merge_dictionary.cc",
"mojo/merge_dictionary.h",
"mojo/mojo_shell_context.cc",
"mojo/mojo_shell_context.h",
"net/browser_online_state_observer.cc",
Expand Down
2 changes: 1 addition & 1 deletion content/browser/browser_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
#include "content/browser/push_messaging/push_messaging_router.h"
#include "content/browser/storage_partition_impl_map.h"
#include "content/common/child_process_host_impl.h"
#include "content/common/mojo/constants.h"
#include "content/public/browser/blob_handle.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/site_instance.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/mojo_shell_connection.h"
#include "content/public/common/service_names.h"
#include "net/cookies/cookie_store.h"
#include "net/ssl/channel_id_service.h"
#include "net/ssl/channel_id_store.h"
Expand Down
2 changes: 1 addition & 1 deletion content/browser/gpu/gpu_process_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "content/common/establish_channel_params.h"
#include "content/common/gpu_host_messages.h"
#include "content/common/in_process_child_thread_params.h"
#include "content/common/mojo/constants.h"
#include "content/common/mojo/mojo_child_connection.h"
#include "content/common/view_messages.h"
#include "content/public/browser/browser_thread.h"
Expand All @@ -54,7 +55,6 @@
#include "content/public/common/result_codes.h"
#include "content/public/common/sandbox_type.h"
#include "content/public/common/sandboxed_process_launcher_delegate.h"
#include "content/public/common/service_names.h"
#include "gpu/command_buffer/service/gpu_preferences.h"
#include "gpu/command_buffer/service/gpu_switches.h"
#include "gpu/ipc/service/switches.h"
Expand Down
42 changes: 0 additions & 42 deletions content/browser/mojo/merge_dictionary.cc

This file was deleted.

21 changes: 0 additions & 21 deletions content/browser/mojo/merge_dictionary.h

This file was deleted.

73 changes: 0 additions & 73 deletions content/browser/mojo/merge_dictionary_unittest.cc

This file was deleted.

66 changes: 9 additions & 57 deletions content/browser/mojo/mojo_shell_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
#include <utility>

#include "base/bind.h"
#include "base/json/json_reader.h"
#include "base/lazy_instance.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/single_thread_task_runner.h"
#include "content/browser/gpu/gpu_process_host.h"
#include "content/browser/mojo/merge_dictionary.h"
#include "content/common/mojo/constants.h"
#include "content/common/mojo/mojo_shell_connection_impl.h"
#include "content/grit/content_resources.h"
#include "content/public/browser/browser_thread.h"
Expand All @@ -24,7 +23,6 @@
#include "content/public/browser/utility_process_host_client.h"
#include "content/public/common/content_client.h"
#include "content/public/common/mojo_shell_connection.h"
#include "content/public/common/service_names.h"
#include "mojo/edk/embedder/embedder.h"
#include "services/catalog/catalog.h"
#include "services/catalog/manifest_provider.h"
Expand Down Expand Up @@ -103,39 +101,6 @@ void StartServiceInGpuProcess(const std::string& service_name,

#endif // ENABLE_MOJO_MEDIA_IN_GPU_PROCESS

void MergeDictionary(base::DictionaryValue* target,
const base::DictionaryValue* source) {
for (base::DictionaryValue::Iterator it(*source); !it.IsAtEnd();
it.Advance()) {
const base::Value* merge_value = &it.value();
// Check whether we have to merge dictionaries.
if (merge_value->IsType(base::Value::TYPE_DICTIONARY)) {
base::DictionaryValue* sub_dict;
if (target->GetDictionaryWithoutPathExpansion(it.key(), &sub_dict)) {
MergeDictionary(
sub_dict,
static_cast<const base::DictionaryValue*>(merge_value));
continue;
}
}
if (merge_value->IsType(base::Value::TYPE_LIST)) {
const base::ListValue* merge_list = nullptr;
if (merge_value->GetAsList(&merge_list)) {
base::ListValue* target_list = nullptr;
DCHECK(target->GetListWithoutPathExpansion(it.key(), &target_list));
for (size_t i = 0; i < merge_list->GetSize(); ++i) {
std::string value;
DCHECK(merge_list->GetString(i, &value));
target_list->AppendString(value);
}
}
} else {
// All other cases: Make a copy and hook it up.
target->SetWithoutPathExpansion(it.key(), merge_value->DeepCopy());
}
}
}

// A ManifestProvider which resolves application names to builtin manifest
// resources for the catalog service to consume.
class BuiltinManifestProvider : public catalog::ManifestProvider {
Expand All @@ -161,28 +126,15 @@ class BuiltinManifestProvider : public catalog::ManifestProvider {

private:
// catalog::ManifestProvider:
std::unique_ptr<base::Value> GetManifest(const std::string& name) override {
auto manifest_it = manifests_->find(name);
std::unique_ptr<base::Value> manifest_root;
if (manifest_it != manifests_->end())
manifest_root = base::JSONReader::Read(manifest_it->second);

base::DictionaryValue* manifest_dictionary = nullptr;
if (manifest_root && !manifest_root->GetAsDictionary(&manifest_dictionary))
return nullptr;

std::unique_ptr<base::Value> overlay_root =
GetContentClient()->browser()->GetServiceManifestOverlay(name);
if (overlay_root) {
if (!manifest_root) {
manifest_root = std::move(overlay_root);
} else {
base::DictionaryValue* overlay_dictionary = nullptr;
if (overlay_root->GetAsDictionary(&overlay_dictionary))
MergeDictionary(manifest_dictionary, overlay_dictionary);
}
bool GetApplicationManifest(const base::StringPiece& name,
std::string* manifest_contents) override {
auto manifest_it = manifests_->find(name.as_string());
if (manifest_it != manifests_->end()) {
*manifest_contents = manifest_it->second;
DCHECK(!manifest_contents->empty());
return true;
}
return manifest_root;
return false;
}

std::unique_ptr<ContentBrowserClient::MojoApplicationManifestMap> manifests_;
Expand Down
2 changes: 1 addition & 1 deletion content/browser/ppapi_plugin_process_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "content/common/child_process_host_impl.h"
#include "content/common/child_process_messages.h"
#include "content/common/content_switches_internal.h"
#include "content/common/mojo/constants.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/content_switches.h"
Expand All @@ -31,7 +32,6 @@
#include "content/public/common/process_type.h"
#include "content/public/common/sandbox_type.h"
#include "content/public/common/sandboxed_process_launcher_delegate.h"
#include "content/public/common/service_names.h"
#include "ipc/ipc_switches.h"
#include "mojo/edk/embedder/embedder.h"
#include "net/base/network_change_notifier.h"
Expand Down
2 changes: 1 addition & 1 deletion content/browser/renderer_host/render_process_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
#include "content/common/frame_messages.h"
#include "content/common/gpu_host_messages.h"
#include "content/common/in_process_child_thread_params.h"
#include "content/common/mojo/constants.h"
#include "content/common/mojo/mojo_child_connection.h"
#include "content/common/mojo/mojo_shell_connection_impl.h"
#include "content/common/render_process_messages.h"
Expand Down Expand Up @@ -159,7 +160,6 @@
#include "content/public/common/resource_type.h"
#include "content/public/common/result_codes.h"
#include "content/public/common/sandboxed_process_launcher_delegate.h"
#include "content/public/common/service_names.h"
#include "content/public/common/url_constants.h"
#include "device/battery/battery_monitor_impl.h"
#include "gpu/GLES2/gl2extchromium.h"
Expand Down
Loading

0 comments on commit f2662e0

Please sign in to comment.