summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorfsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-24 04:56:06 +0000
committerfsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-24 04:56:06 +0000
commit44703cc73a24cc39b3e5e832f447d8261701fa4c (patch)
tree79f249332af4fc3613b4f59878233668cbde1908 /content
parent363e33dcc1b59766434bab7b85f9f9b7ce108237 (diff)
downloadchromium_src-44703cc73a24cc39b3e5e832f447d8261701fa4c.zip
chromium_src-44703cc73a24cc39b3e5e832f447d8261701fa4c.tar.gz
chromium_src-44703cc73a24cc39b3e5e832f447d8261701fa4c.tar.bz2
<webview>: Implement ExecuteScript
This patch implements executeScript for <webview> by using extensions bindings for forwarding requests to the browser process from the app process. The <webview> shim passes the ProcessId and the RouteID of the guest process to the ExecuteScriptFunction object in the browser process. From there, ExecuteScriptFunction grabs the guest web contents, and creates a ScriptExecutor object attached to the guest WebContents. The callback is supported trivially through the extension bindings. When a new guest web contents is created, we inject the Chrome App's extension information into the guest process, so that executeScript knows to bypass permission requests when attempting to execute script within the guest (as suggested by mpcomplete@). BUG=153530 Test=WebViewTest.Shim, webViewExecuteScript Review URL: https://codereview.chromium.org/11968054 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178520 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/browser_plugin/browser_plugin_guest.cc5
-rw-r--r--content/common/browser_plugin_messages.h6
-rw-r--r--content/public/browser/content_browser_client.h4
-rw-r--r--content/renderer/browser_plugin/browser_plugin.cc6
-rw-r--r--content/renderer/browser_plugin/browser_plugin.h8
-rw-r--r--content/renderer/browser_plugin/browser_plugin_bindings.cc24
6 files changed, 46 insertions, 7 deletions
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc
index c6c2522..f58b8a7 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.cc
+++ b/content/browser/browser_plugin/browser_plugin_guest.cc
@@ -18,6 +18,7 @@
#include "content/common/drag_messages.h"
#include "content/common/view_messages.h"
#include "content/port/browser/render_view_host_delegate_view.h"
+#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h"
@@ -98,6 +99,9 @@ void BrowserPluginGuest::Initialize(
content::Source<content::WebContents>(web_contents()));
OnSetSize(instance_id_, params.auto_size_params, params.resize_guest_params);
+
+ GetContentClient()->browser()->GuestWebContentsCreated(
+ web_contents(), embedder_web_contents_);
}
BrowserPluginGuest::~BrowserPluginGuest() {
@@ -303,6 +307,7 @@ void BrowserPluginGuest::DidCommitProvisionalLoadForFrame(
params.url = url;
params.is_top_level = is_main_frame;
params.process_id = render_view_host->GetProcess()->GetID();
+ params.route_id = render_view_host->GetRoutingID();
params.current_entry_index =
web_contents()->GetController().GetCurrentEntryIndex();
params.entry_count =
diff --git a/content/common/browser_plugin_messages.h b/content/common/browser_plugin_messages.h
index f20be30..5d33460 100644
--- a/content/common/browser_plugin_messages.h
+++ b/content/common/browser_plugin_messages.h
@@ -67,8 +67,10 @@ IPC_STRUCT_BEGIN(BrowserPluginMsg_LoadCommit_Params)
IPC_STRUCT_MEMBER(GURL, url)
// Indicates whether the navigation was on the top-level frame.
IPC_STRUCT_MEMBER(bool, is_top_level)
- // Chrome's process ID for the guest.
+ // The browser's process ID for the guest.
IPC_STRUCT_MEMBER(int, process_id)
+ // The browser's routing ID for the guest's RenderView.
+ IPC_STRUCT_MEMBER(int, route_id)
// The index of the current navigation entry after this navigation was
// committed.
IPC_STRUCT_MEMBER(int, current_entry_index)
@@ -283,7 +285,7 @@ IPC_MESSAGE_ROUTED4(BrowserPluginMsg_LoadRedirect,
bool /* is_top_level */)
// When the guest commits a navigation, the browser process informs
-// the embedder through the BrowserPluginMsg_DidCommit message.
+// the embedder through the BrowserPluginMsg_LoadCommit message.
IPC_MESSAGE_ROUTED2(BrowserPluginMsg_LoadCommit,
int /* instance_id */,
BrowserPluginMsg_LoadCommit_Params)
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
index 5c0dd67..170f3fe 100644
--- a/content/public/browser/content_browser_client.h
+++ b/content/public/browser/content_browser_client.h
@@ -110,6 +110,10 @@ class CONTENT_EXPORT ContentBrowserClient {
// Notifies that a new RenderHostView has been created.
virtual void RenderViewHostCreated(RenderViewHost* render_view_host) {}
+ // Notifies that a <webview> guest WebContents has been created.
+ virtual void GuestWebContentsCreated(WebContents* guest_web_contents,
+ WebContents* embedder_web_contents) {}
+
// Notifies that a RenderProcessHost has been created. This is called before
// the content layer adds its own BrowserMessageFilters, so that the
// embedder's IPC filters have priority.
diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc
index 7098405..eb9068a 100644
--- a/content/renderer/browser_plugin/browser_plugin.cc
+++ b/content/renderer/browser_plugin/browser_plugin.cc
@@ -125,7 +125,8 @@ BrowserPlugin::BrowserPlugin(
max_width_(0),
min_height_(0),
min_width_(0),
- process_id_(-1),
+ guest_process_id_(-1),
+ guest_route_id_(-1),
persist_storage_(false),
valid_partition_id_(true),
content_window_routing_id_(MSG_ROUTING_NONE),
@@ -429,7 +430,8 @@ void BrowserPlugin::OnLoadCommit(
src_ = params.url.spec();
UpdateDOMAttribute(kSrc, src_.c_str());
}
- process_id_ = params.process_id;
+ guest_process_id_ = params.process_id;
+ guest_route_id_ = params.route_id;
current_nav_entry_index_ = params.current_entry_index;
nav_entry_count_ = params.entry_count;
diff --git a/content/renderer/browser_plugin/browser_plugin.h b/content/renderer/browser_plugin/browser_plugin.h
index 466826a..88f92e1 100644
--- a/content/renderer/browser_plugin/browser_plugin.h
+++ b/content/renderer/browser_plugin/browser_plugin.h
@@ -77,7 +77,10 @@ class CONTENT_EXPORT BrowserPlugin :
NPObject* GetContentWindow() const;
// Returns Chrome's process ID for the current guest.
- int process_id() const { return process_id_; }
+ int guest_process_id() const { return guest_process_id_; }
+ // Returns Chrome's route ID for the current guest.
+ int guest_route_id() const { return guest_route_id_; }
+
// The partition identifier string is stored as UTF-8.
std::string GetPartitionAttribute() const;
// Query whether the guest can navigate back to the previous entry.
@@ -302,7 +305,8 @@ class CONTENT_EXPORT BrowserPlugin :
int max_width_;
int min_height_;
int min_width_;
- int process_id_;
+ int guest_process_id_;
+ int guest_route_id_;
std::string storage_partition_id_;
bool persist_storage_;
bool valid_partition_id_;
diff --git a/content/renderer/browser_plugin/browser_plugin_bindings.cc b/content/renderer/browser_plugin/browser_plugin_bindings.cc
index e0daeee..984fb66 100644
--- a/content/renderer/browser_plugin/browser_plugin_bindings.cc
+++ b/content/renderer/browser_plugin/browser_plugin_bindings.cc
@@ -42,6 +42,7 @@ const char kMethodCanGoBack[] = "canGoBack";
const char kMethodCanGoForward[] = "canGoForward";
const char kMethodForward[] = "forward";
const char kMethodGetProcessId[] = "getProcessId";
+const char kMethodGetRouteId[] = "getRouteId";
const char kMethodGo[] = "go";
const char kMethodReload[] = "reload";
const char kMethodStop[] = "stop";
@@ -301,6 +302,26 @@ class BrowserPluginBindingForward : public BrowserPluginMethodBinding {
DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingForward);
};
+// Note: This is a method that is used internally by the <webview> shim only.
+// This should not be exposed to developers.
+class BrowserPluginBindingGetRouteID : public BrowserPluginMethodBinding {
+ public:
+ BrowserPluginBindingGetRouteID()
+ : BrowserPluginMethodBinding(kMethodGetRouteId, 0) {
+ }
+
+ virtual bool Invoke(BrowserPluginBindings* bindings,
+ const NPVariant* args,
+ NPVariant* result) OVERRIDE {
+ int route_id = bindings->instance()->guest_route_id();
+ INT32_TO_NPVARIANT(route_id, *result);
+ return true;
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingGetRouteID);
+};
+
class BrowserPluginBindingGetProcessID : public BrowserPluginMethodBinding {
public:
BrowserPluginBindingGetProcessID()
@@ -310,7 +331,7 @@ class BrowserPluginBindingGetProcessID : public BrowserPluginMethodBinding {
virtual bool Invoke(BrowserPluginBindings* bindings,
const NPVariant* args,
NPVariant* result) OVERRIDE {
- int process_id = bindings->instance()->process_id();
+ int process_id = bindings->instance()->guest_process_id();
INT32_TO_NPVARIANT(process_id, *result);
return true;
}
@@ -689,6 +710,7 @@ BrowserPluginBindings::BrowserPluginBindings(BrowserPlugin* instance)
method_bindings_.push_back(new BrowserPluginBindingCanGoForward);
method_bindings_.push_back(new BrowserPluginBindingForward);
method_bindings_.push_back(new BrowserPluginBindingGetProcessID);
+ method_bindings_.push_back(new BrowserPluginBindingGetRouteID);
method_bindings_.push_back(new BrowserPluginBindingGo);
method_bindings_.push_back(new BrowserPluginBindingReload);
method_bindings_.push_back(new BrowserPluginBindingStop);