diff options
author | fsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-15 22:45:33 +0000 |
---|---|---|
committer | fsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-15 22:45:33 +0000 |
commit | 5e79679787b2ca428c09b45e9ee0f52b98c48021 (patch) | |
tree | d6b871af6ab0e2a3cc909c7c58a1f5e7732d7f5b /content/browser | |
parent | 452283191defa40d34f3b09aa9fbcd579b71a127 (diff) | |
download | chromium_src-5e79679787b2ca428c09b45e9ee0f52b98c48021.zip chromium_src-5e79679787b2ca428c09b45e9ee0f52b98c48021.tar.gz chromium_src-5e79679787b2ca428c09b45e9ee0f52b98c48021.tar.bz2 |
Browser Plugin: Minor refactor to move NavigateGuest handling to BrowserPluginGuest.
BUG=none
Review URL: https://codereview.chromium.org/11942003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176996 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
4 files changed, 27 insertions, 29 deletions
diff --git a/content/browser/browser_plugin/browser_plugin_embedder.cc b/content/browser/browser_plugin/browser_plugin_embedder.cc index 3fba36e..031d4bf 100644 --- a/content/browser/browser_plugin/browser_plugin_embedder.cc +++ b/content/browser/browser_plugin/browser_plugin_embedder.cc @@ -213,8 +213,6 @@ bool BrowserPluginEmbedder::OnMessageReceived(const IPC::Message& message) { IPC_BEGIN_MESSAGE_MAP(BrowserPluginEmbedder, message) IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CreateGuest, OnCreateGuest) - IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateGuest, - OnNavigateGuest) IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginAtPositionResponse, OnPluginAtPositionResponse) IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, @@ -279,6 +277,7 @@ bool BrowserPluginEmbedder::ShouldForwardToBrowserPluginGuest( case BrowserPluginHostMsg_DragStatusUpdate::ID: case BrowserPluginHostMsg_Go::ID: case BrowserPluginHostMsg_HandleInputEvent::ID: + case BrowserPluginHostMsg_NavigateGuest::ID: case BrowserPluginHostMsg_Reload::ID: case BrowserPluginHostMsg_ResizeGuest::ID: case BrowserPluginHostMsg_SetAutoSize::ID: @@ -301,32 +300,6 @@ void BrowserPluginEmbedder::OnCreateGuest( CreateGuest(instance_id, MSG_ROUTING_NONE, NULL, params); } -void BrowserPluginEmbedder::OnNavigateGuest( - int instance_id, - const std::string& src) { - BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); - CHECK(guest); - GURL url(src); - WebContentsImpl* guest_web_contents = - static_cast<WebContentsImpl*>(guest->GetWebContents()); - - // We do not load empty urls in web_contents. - // If a guest sets empty src attribute after it has navigated to some - // non-empty page, the action is considered no-op. This empty src navigation - // should never be sent to BrowserPluginEmbedder (browser process). - DCHECK(!src.empty()); - if (!src.empty()) { - // Because guests do not swap processes on navigation, only navigations to - // normal web URLs are supported. No protocol handlers are installed for - // other schemes (e.g., WebUI or extensions), and no permissions or bindings - // can be granted to the guest process. - guest_web_contents->GetController().LoadURL(url, - Referrer(), - PAGE_TRANSITION_AUTO_TOPLEVEL, - std::string()); - } -} - void BrowserPluginEmbedder::OnPluginAtPositionResponse( int instance_id, int request_id, const gfx::Point& position) { const std::map<int, WebContents::GetRenderViewHostCallback>::iterator diff --git a/content/browser/browser_plugin/browser_plugin_embedder.h b/content/browser/browser_plugin/browser_plugin_embedder.h index 4eae837..b918370 100644 --- a/content/browser/browser_plugin/browser_plugin_embedder.h +++ b/content/browser/browser_plugin/browser_plugin_embedder.h @@ -120,7 +120,6 @@ class CONTENT_EXPORT BrowserPluginEmbedder : public WebContentsObserver, void OnCreateGuest(int instance_id, const BrowserPluginHostMsg_CreateGuest_Params& params); - void OnNavigateGuest(int instance_id, const std::string& src); void OnPluginAtPositionResponse(int instance_id, int request_id, const gfx::Point& position); diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc index 3162a57..13bc895 100644 --- a/content/browser/browser_plugin/browser_plugin_guest.cc +++ b/content/browser/browser_plugin/browser_plugin_guest.cc @@ -72,6 +72,7 @@ bool BrowserPluginGuest::OnMessageReceivedFromEmbedder( IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Go, OnGo) IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_HandleInputEvent, OnHandleInputEvent) + IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateGuest, OnNavigateGuest) IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Reload, OnReload) IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest) IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetAutoSize, OnSetSize) @@ -434,6 +435,30 @@ void BrowserPluginGuest::OnHandleInputEvent( guest_rvh->StartHangMonitorTimeout(guest_hang_timeout_); } +void BrowserPluginGuest::OnNavigateGuest( + int instance_id, + const std::string& src) { + GURL url(src); + WebContentsImpl* guest_web_contents = + static_cast<WebContentsImpl*>(web_contents()); + + // We do not load empty urls in web_contents. + // If a guest sets empty src attribute after it has navigated to some + // non-empty page, the action is considered no-op. This empty src navigation + // should never be sent to BrowserPluginEmbedder (browser process). + DCHECK(!src.empty()); + if (!src.empty()) { + // Because guests do not swap processes on navigation, only navigations to + // normal web URLs are supported. No protocol handlers are installed for + // other schemes (e.g., WebUI or extensions), and no permissions or bindings + // can be granted to the guest process. + guest_web_contents->GetController().LoadURL(url, + Referrer(), + PAGE_TRANSITION_AUTO_TOPLEVEL, + std::string()); + } +} + void BrowserPluginGuest::OnReload(int instance_id) { // TODO(fsamuel): Don't check for repost because we don't want to show // Chromium's repost warning. We might want to implement a separate API diff --git a/content/browser/browser_plugin/browser_plugin_guest.h b/content/browser/browser_plugin/browser_plugin_guest.h index e2eae2a..9b7fb47 100644 --- a/content/browser/browser_plugin/browser_plugin_guest.h +++ b/content/browser/browser_plugin/browser_plugin_guest.h @@ -211,6 +211,7 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver, virtual void OnHandleInputEvent(int instance_id, const gfx::Rect& guest_window_rect, const WebKit::WebInputEvent* event); + void OnNavigateGuest(int instance_id, const std::string& src); // Reload the guest. Overriden in tests. virtual void OnReload(int instance_id); // Grab the new damage buffer from the embedder, and resize the guest's |