diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 11 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider.h | 6 | ||||
-rw-r--r-- | chrome/browser/external_tab_container.cc | 12 | ||||
-rw-r--r-- | chrome/browser/external_tab_container.h | 4 | ||||
-rw-r--r-- | chrome/browser/render_view_host.cc | 21 | ||||
-rw-r--r-- | chrome/browser/render_view_host.h | 18 | ||||
-rw-r--r-- | chrome/browser/web_contents.cc | 2 |
7 files changed, 46 insertions, 28 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index fafdd5b..fecbfa7 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -772,8 +772,8 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) { GetConstrainedWindowBounds) IPC_MESSAGE_HANDLER(AutomationMsg_OpenFindInPageRequest, HandleOpenFindInPageRequest) - IPC_MESSAGE_HANDLER(AutomationMsg_PostMessage, - OnPostMessage) + IPC_MESSAGE_HANDLER(AutomationMsg_HandleMessageFromExternalHost, + OnMessageFromExternalHost) IPC_END_MESSAGE_MAP() } @@ -2205,9 +2205,8 @@ void AutomationProvider::AutocompleteEditIsQueryInProgress( message.routing_id(), success, query_in_progress)); } -void AutomationProvider::OnPostMessage(int handle, - const std::string& target, - const std::string& message) { +void AutomationProvider::OnMessageFromExternalHost( + int handle, const std::string& target, const std::string& message) { if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); if (!tab) { @@ -2231,7 +2230,7 @@ void AutomationProvider::OnPostMessage(int handle, return; } - view_host->PostMessage(target, message); + view_host->ForwardMessageFromExternalHost(target, message); } } diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index 1fac8fa..1aadbc4 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -311,9 +311,9 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, void AutocompleteEditGetMatches(const IPC::Message& message, int autocomplete_edit_handle); - // Handler for PostMessage sent by the automation client. - void OnPostMessage(int handle, const std::string& target, - const std::string& message); + // Handler for a message sent by the automation client. + void OnMessageFromExternalHost(int handle, const std::string& target, + const std::string& message); // Callback for history redirect queries. virtual void OnRedirectQueryComplete( diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc index bc25861..1bd3dd8 100644 --- a/chrome/browser/external_tab_container.cc +++ b/chrome/browser/external_tab_container.cc @@ -35,6 +35,7 @@ #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents.h" #include "chrome/browser/tab_contents_container_view.h" +#include "chrome/browser/web_contents.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/win_util.h" #include "chrome/views/hwnd_view_container.h" @@ -89,6 +90,11 @@ bool ExternalTabContainer::Init(Profile* profile) { } tab_contents_->SetupController(profile); tab_contents_->set_delegate(this); + + WebContents* web_conents = tab_contents_->AsWebContents(); + if (web_conents) + web_conents->render_view_host()->AllowExternalHostBindings(); + // Create a TabContentsContainerView to handle focus cycling using Tab and // Shift-Tab. // TODO(sanjeevr): We need to create a dummy FocusTraversable object to @@ -238,11 +244,11 @@ void ExternalTabContainer::DidNavigate(NavigationType nav_type, } } -void ExternalTabContainer::SendExternalHostMessage(const std::string& receiver, - const std::string& message) { +void ExternalTabContainer::ForwardMessageToExternalHost( + const std::string& receiver, const std::string& message) { if(automation_) { automation_->Send( - new AutomationMsg_SendExternalHostMessage(0, receiver, message)); + new AutomationMsg_ForwardMessageToExternalHost(0, receiver, message)); } } diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h index 304d179..8b368dd 100644 --- a/chrome/browser/external_tab_container.h +++ b/chrome/browser/external_tab_container.h @@ -105,8 +105,8 @@ class ExternalTabContainer : public TabContentsDelegate, virtual void ToolbarSizeChanged(TabContents* source, bool is_animating); virtual void DidNavigate(NavigationType nav_type, int relative_navigation_offet); - virtual void SendExternalHostMessage(const std::string& receiver, - const std::string& message); + virtual void ForwardMessageToExternalHost(const std::string& receiver, + const std::string& message); // Notification service callback. diff --git a/chrome/browser/render_view_host.cc b/chrome/browser/render_view_host.cc index 0a6912b..4a3339f 100644 --- a/chrome/browser/render_view_host.cc +++ b/chrome/browser/render_view_host.cc @@ -101,6 +101,7 @@ RenderViewHost::RenderViewHost(SiteInstance* instance, : RenderWidgetHost(instance->GetProcess(), routing_id), instance_(instance), enable_dom_ui_bindings_(false), + enable_external_host_bindings_(false), delegate_(delegate), renderer_initialized_(false), waiting_for_drag_context_response_(false), @@ -175,8 +176,8 @@ bool RenderViewHost::CreateRenderView() { // If it's enabled, tell the renderer to set up the Javascript bindings for // sending messages back to the browser. - if (enable_dom_ui_bindings_) - Send(new ViewMsg_AllowDOMUIBindings(routing_id_)); + Send(new ViewMsg_AllowBindings( + routing_id_, enable_dom_ui_bindings_, enable_external_host_bindings_)); // Let our delegate know that we created a RenderView. delegate_->RendererCreated(this); @@ -571,6 +572,10 @@ void RenderViewHost::AllowDOMUIBindings() { RendererSecurityPolicy::GetInstance()->GrantDOMUIBindings(process()->host_id()); } +void RenderViewHost::AllowExternalHostBindings() { + enable_external_host_bindings_ = true; +} + void RenderViewHost::SetDOMUIProperty(const std::string& name, const std::string& value) { DCHECK(enable_dom_ui_bindings_); @@ -665,8 +670,8 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) { OnMsgDomOperationResponse) IPC_MESSAGE_HANDLER(ViewHostMsg_DOMUISend, OnMsgDOMUISend) - IPC_MESSAGE_HANDLER(ViewHostMsg_ExternalHostMessage, - OnMsgExternalHostMessage) + IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardMessageToExternalHost, + OnMsgForwardMessageToExternalHost) #ifdef CHROME_PERSONALIZATION IPC_MESSAGE_HANDLER(ViewHostMsg_PersonalizationEvent, OnPersonalizationEvent) @@ -1015,7 +1020,7 @@ void RenderViewHost::OnMsgDOMUISend( delegate_->ProcessDOMUIMessage(message, content); } -void RenderViewHost::OnMsgExternalHostMessage( +void RenderViewHost::OnMsgForwardMessageToExternalHost( const std::string& receiver, const std::string& message) { delegate_->ProcessExternalHostMessage(receiver, message); @@ -1220,7 +1225,7 @@ void RenderViewHost::OnDebugDisconnect() { } } -void RenderViewHost::PostMessage(const std::string& target, - const std::string& message) { - Send(new ViewMsg_PostMessage(routing_id_, target, message)); +void RenderViewHost::ForwardMessageFromExternalHost( + const std::string& target, const std::string& message) { + Send(new ViewMsg_HandleMessageFromExternalHost(routing_id_, target, message)); } diff --git a/chrome/browser/render_view_host.h b/chrome/browser/render_view_host.h index dcba399..e80f111 100644 --- a/chrome/browser/render_view_host.h +++ b/chrome/browser/render_view_host.h @@ -333,6 +333,10 @@ class RenderViewHost : public RenderWidgetHost { // process. void AllowDomAutomationBindings(); + // Tell the render view to allow the javascript access to + // the external host via automation. + void AllowExternalHostBindings(); + // Tell the render view to expose DOM bindings so that the JS content // can send JSON-encoded data back to the browser process. // This is used for HTML-based UI. @@ -398,9 +402,9 @@ class RenderViewHost : public RenderWidgetHost { // and we're necessarily leaving the page. void UnloadListenerHasFired() { has_unload_listener_ = false; } - // Posts a message to the renderer. - void PostMessage(const std::string& target, - const std::string& message); + // Forward a message from external host to chrome renderer. + void ForwardMessageFromExternalHost(const std::string& target, + const std::string& message); #ifdef CHROME_PERSONALIZATION HostPersonalization personalization() { @@ -463,8 +467,8 @@ class RenderViewHost : public RenderWidgetHost { int automation_id); void OnMsgDOMUISend(const std::string& message, const std::string& content); - void OnMsgExternalHostMessage(const std::string& receiver, - const std::string& message); + void OnMsgForwardMessageToExternalHost(const std::string& receiver, + const std::string& message); #ifdef CHROME_PERSONALIZATION void OnPersonalizationEvent(const std::string& message, const std::string& content); @@ -555,6 +559,10 @@ class RenderViewHost : public RenderWidgetHost { // sending messages back to the browser. bool enable_dom_ui_bindings_; + // True if javascript access to the external host (through + // automation) is allowed. + bool enable_external_host_bindings_; + // Handle to an event that's set when the page is showing a modal dialog box // (or equivalent constrained window). The renderer and plugin processes // check this to know if they should pump messages/tasks then. diff --git a/chrome/browser/web_contents.cc b/chrome/browser/web_contents.cc index ccaf94d..30249e8 100644 --- a/chrome/browser/web_contents.cc +++ b/chrome/browser/web_contents.cc @@ -1998,7 +1998,7 @@ void WebContents::DomOperationResponse(const std::string& json_string, void WebContents::ProcessExternalHostMessage(const std::string& receiver, const std::string& message) { if (delegate()) - delegate()->SendExternalHostMessage(receiver, message); + delegate()->ForwardMessageToExternalHost(receiver, message); } void WebContents::GoToEntryAtOffset(int offset) { |