diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-19 22:59:57 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-19 22:59:57 +0000 |
commit | 6a64e8a2affa73435a7f90dcddb4cad873c1884e (patch) | |
tree | 86c7d3b6d4c17aea67b8ccb8d6cb39c8a21111d9 | |
parent | c8b0eb2495c63de99a2fa1dc81e9c2edb1700e87 (diff) | |
download | chromium_src-6a64e8a2affa73435a7f90dcddb4cad873c1884e.zip chromium_src-6a64e8a2affa73435a7f90dcddb4cad873c1884e.tar.gz chromium_src-6a64e8a2affa73435a7f90dcddb4cad873c1884e.tar.bz2 |
Removed the sending of the following content IPC messages out of chrome and replaced them with
corresponding API's on the RenderWidgetHost object.
1. ViewMsg_Zoom.
2. ViewMsg_ReloadFrame.
3. ViewMsg_Find.
4. ViewMsg_CSSInsertRequest.
5. ViewMsg_DisableScrollbarsForSmallWindows.
6. ViewMsg_EnablePreferredSizeChangedMode.
Continuing fixes to ensure that IPC messages don't span across content and chrome.
BUG=87335.
TEST=no change in functionality.
Review URL: http://codereview.chromium.org/7923023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101855 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 7 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider_win.cc | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_host.cc | 11 | ||||
-rw-r--r-- | chrome/browser/external_tab_container_win.cc | 6 | ||||
-rw-r--r-- | chrome/browser/notifications/balloon_host.cc | 9 | ||||
-rw-r--r-- | chrome/browser/pdf_unsupported_feature.cc | 3 | ||||
-rw-r--r-- | chrome/browser/tab_contents/render_view_context_menu.cc | 2 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_view_mac.mm | 3 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/applescript/tab_applescript.mm | 2 | ||||
-rw-r--r-- | chrome/browser/ui/find_bar/find_tab_helper.cc | 5 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel.cc | 10 | ||||
-rw-r--r-- | content/browser/renderer_host/render_widget_host.cc | 31 | ||||
-rw-r--r-- | content/browser/renderer_host/render_widget_host.h | 26 | ||||
-rw-r--r-- | content/browser/tab_contents/render_view_host_manager.cc | 2 |
15 files changed, 84 insertions, 37 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 9f036f4..9d8b3ab 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -521,10 +521,9 @@ void AutomationProvider::SendFindRequest( options.forward = forward; options.matchCase = match_case; options.findNext = find_next; - tab_contents->render_view_host()->Send(new ViewMsg_Find( - tab_contents->render_view_host()->routing_id(), + tab_contents->render_view_host()->Find( FindInPageNotificationObserver::kFindInPageRequestId, search_string, - options)); + options); } class SetProxyConfigTask : public Task { @@ -712,7 +711,7 @@ void AutomationProvider::StopAsync(int tab_handle) { return; } - view->Send(new ViewMsg_Stop(view->routing_id())); + view->Stop(); } void AutomationProvider::OnSetPageFontSize(int tab_handle, diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc index 3fe88f1..3de6383 100644 --- a/chrome/browser/automation/automation_provider_win.cc +++ b/chrome/browser/automation/automation_provider_win.cc @@ -467,7 +467,7 @@ void AutomationProvider::OnSetZoomLevel(int handle, int zoom_level) { if (tab->tab_contents() && tab->tab_contents()->render_view_host()) { RenderViewHost* host = tab->tab_contents()->render_view_host(); PageZoom::Function zoom = static_cast<PageZoom::Function>(zoom_level); - host->Send(new ViewMsg_Zoom(host->routing_id(), zoom)); + host->Zoom(zoom); } } } diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index a2c7371..726ec71 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -346,14 +346,12 @@ void ExtensionHost::InsertInfobarCSS() { ResourceBundle::GetSharedInstance().GetRawDataResource( IDR_EXTENSIONS_INFOBAR_CSS)); - render_view_host()->Send(new ViewMsg_CSSInsertRequest( - render_view_host()->routing_id(), string16(), css.as_string())); + render_view_host()->InsertCSS(string16(), css.as_string()); } void ExtensionHost::DisableScrollbarsForSmallWindows( const gfx::Size& size_limit) { - render_view_host()->Send(new ViewMsg_DisableScrollbarsForSmallWindows( - render_view_host()->routing_id(), size_limit)); + render_view_host()->DisableScrollbarsForThreshold(size_limit); } void ExtensionHost::DidStopLoading() { @@ -796,8 +794,7 @@ void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { if (extension_host_type_ == ViewType::EXTENSION_POPUP || extension_host_type_ == ViewType::EXTENSION_INFOBAR) { - render_view_host->Send(new ViewMsg_EnablePreferredSizeChangedMode( - render_view_host->routing_id(), - kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow)); + render_view_host->EnablePreferredSizeMode( + kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow); } } diff --git a/chrome/browser/external_tab_container_win.cc b/chrome/browser/external_tab_container_win.cc index f67c5b1..cc9fb2d 100644 --- a/chrome/browser/external_tab_container_win.cc +++ b/chrome/browser/external_tab_container_win.cc @@ -1037,13 +1037,13 @@ bool ExternalTabContainer::AcceleratorPressed( int command_id = iter->second; switch (command_id) { case IDC_ZOOM_PLUS: - host->Send(new ViewMsg_Zoom(host->routing_id(), PageZoom::ZOOM_IN)); + host->Zoom(PageZoom::ZOOM_IN); break; case IDC_ZOOM_NORMAL: - host->Send(new ViewMsg_Zoom(host->routing_id(), PageZoom::RESET)); + host->Zoom(PageZoom::RESET); break; case IDC_ZOOM_MINUS: - host->Send(new ViewMsg_Zoom(host->routing_id(), PageZoom::ZOOM_OUT)); + host->Zoom(PageZoom::ZOOM_OUT); break; case IDC_DEV_TOOLS: DevToolsWindow::ToggleDevToolsWindow( diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc index 8f3b54e..fd30e64 100644 --- a/chrome/browser/notifications/balloon_host.cc +++ b/chrome/browser/notifications/balloon_host.cc @@ -81,12 +81,11 @@ void BalloonHost::Close(RenderViewHost* render_view_host) { } void BalloonHost::RenderViewCreated(RenderViewHost* render_view_host) { - render_view_host->Send(new ViewMsg_DisableScrollbarsForSmallWindows( - render_view_host->routing_id(), balloon_->min_scrollbar_size())); + render_view_host->DisableScrollbarsForThreshold( + balloon_->min_scrollbar_size()); render_view_host->WasResized(); - render_view_host->Send(new ViewMsg_EnablePreferredSizeChangedMode( - render_view_host->routing_id(), - kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow)); + render_view_host->EnablePreferredSizeMode( + kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow); } void BalloonHost::RenderViewReady(RenderViewHost* render_view_host) { diff --git a/chrome/browser/pdf_unsupported_feature.cc b/chrome/browser/pdf_unsupported_feature.cc index 9fb0747..c5460f8 100644 --- a/chrome/browser/pdf_unsupported_feature.cc +++ b/chrome/browser/pdf_unsupported_feature.cc @@ -151,8 +151,7 @@ void OpenUsingReader(TabContentsWrapper* tab, tab->render_view_host()->routing_id(), tab->tab_contents()->GetURL(), plugin); - tab->render_view_host()->Send(new ViewMsg_ReloadFrame( - tab->render_view_host()->routing_id())); + tab->render_view_host()->ReloadFrame(); if (new_delegate) { if (old_delegate) { diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index 25f0722..6bd81a7 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -1651,7 +1651,7 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) { } case IDC_CONTENT_CONTEXT_RELOADFRAME: - rvh->Send(new ViewMsg_ReloadFrame(rvh->routing_id())); + rvh->ReloadFrame(); break; case IDC_CONTENT_CONTEXT_VIEWFRAMESOURCE: diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.mm b/chrome/browser/tab_contents/tab_contents_view_mac.mm index b6bafea..1c2db13 100644 --- a/chrome/browser/tab_contents/tab_contents_view_mac.mm +++ b/chrome/browser/tab_contents/tab_contents_view_mac.mm @@ -170,8 +170,7 @@ void TabContentsViewMac::RenderViewCreated(RenderViewHost* host) { // We want updates whenever the intrinsic width of the webpage changes. // Put the RenderView into that mode. The preferred width is used for example // when the "zoom" button in the browser window is clicked. - host->Send(new ViewMsg_EnablePreferredSizeChangedMode( - host->routing_id(), kPreferredSizeWidth)); + host->EnablePreferredSizeMode(kPreferredSizeWidth); } void TabContentsViewMac::SetPageTitle(const std::wstring& title) { diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index ac6cfde..a40639c 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -1878,7 +1878,7 @@ void Browser::Zoom(PageZoom::Function zoom_function) { UserMetrics::RecordAction(kActions[zoom_function - PageZoom::ZOOM_OUT]); TabContentsWrapper* tab_contents = GetSelectedTabContentsWrapper(); RenderViewHost* host = tab_contents->render_view_host(); - host->Send(new ViewMsg_Zoom(host->routing_id(), zoom_function)); + host->Zoom(zoom_function); } void Browser::FocusToolbar() { diff --git a/chrome/browser/ui/cocoa/applescript/tab_applescript.mm b/chrome/browser/ui/cocoa/applescript/tab_applescript.mm index 1b8f0b8..a0f4726 100644 --- a/chrome/browser/ui/cocoa/applescript/tab_applescript.mm +++ b/chrome/browser/ui/cocoa/applescript/tab_applescript.mm @@ -227,7 +227,7 @@ return; } - view->Send(new ViewMsg_Stop(view->routing_id())); + view->Stop(); } - (void)handlesPrintScriptCommand:(NSScriptCommand*)command { diff --git a/chrome/browser/ui/find_bar/find_tab_helper.cc b/chrome/browser/ui/find_bar/find_tab_helper.cc index 9c5e538..c7f191c 100644 --- a/chrome/browser/ui/find_bar/find_tab_helper.cc +++ b/chrome/browser/ui/find_bar/find_tab_helper.cc @@ -84,9 +84,8 @@ void FindTabHelper::StartFinding(string16 search_string, options.forward = forward_direction; options.matchCase = case_sensitive; options.findNext = find_next; - tab_contents()->render_view_host()->Send(new ViewMsg_Find( - tab_contents()->render_view_host()->routing_id(), - current_find_request_id_, find_text_, options)); + tab_contents()->render_view_host()->Find(current_find_request_id_, + find_text_, options); } void FindTabHelper::StopFinding( diff --git a/chrome/browser/ui/panels/panel.cc b/chrome/browser/ui/panels/panel.cc index 2fcd393..d9492b7 100644 --- a/chrome/browser/ui/panels/panel.cc +++ b/chrome/browser/ui/panels/panel.cc @@ -508,9 +508,8 @@ void Panel::Observe(int type, case content::NOTIFICATION_TAB_CONTENTS_SWAPPED: { RenderViewHost* render_view_host = GetRenderViewHost(); DCHECK(render_view_host); - render_view_host->Send(new ViewMsg_EnablePreferredSizeChangedMode( - render_view_host->routing_id(), - kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow)); + render_view_host->EnablePreferredSizeMode( + kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow); RequestRenderViewHostToDisableScrollbars(render_view_host); break; } @@ -532,10 +531,9 @@ void Panel::RequestRenderViewHostToDisableScrollbars( DCHECK(render_view_host); gfx::Size non_client_size = native_panel_->GetNonClientAreaExtent(); - render_view_host->Send(new ViewMsg_DisableScrollbarsForSmallWindows( - render_view_host->routing_id(), + render_view_host->DisableScrollbarsForThreshold( gfx::Size(max_size_.width() - non_client_size.width(), - max_size_.height() - non_client_size.height()))); + max_size_.height() - non_client_size.height())); } Browser* Panel::browser() const { diff --git a/content/browser/renderer_host/render_widget_host.cc b/content/browser/renderer_host/render_widget_host.cc index fe5816b..cca84f5 100644 --- a/content/browser/renderer_host/render_widget_host.cc +++ b/content/browser/renderer_host/render_widget_host.cc @@ -1254,3 +1254,34 @@ void RenderWidgetHost::ActivateDeferredPluginHandles() { void RenderWidgetHost::StartUserGesture() { OnUserGesture(); } + +void RenderWidgetHost::Zoom(PageZoom::Function zoom_function) { + Send(new ViewMsg_Zoom(routing_id(), zoom_function)); +} + +void RenderWidgetHost::ReloadFrame() { + Send(new ViewMsg_ReloadFrame(routing_id())); +} + +void RenderWidgetHost::Find(int request_id, const string16& search_text, + const WebKit::WebFindOptions& options) { + Send(new ViewMsg_Find(routing_id(), request_id, search_text, options)); +} + +void RenderWidgetHost::Stop() { + Send(new ViewMsg_Stop(routing_id())); +} + +void RenderWidgetHost::InsertCSS(const string16& frame_xpath, + const std::string& css) { + Send(new ViewMsg_CSSInsertRequest(routing_id(), frame_xpath, css)); +} + +void RenderWidgetHost::DisableScrollbarsForThreshold(const gfx::Size& size) { + Send(new ViewMsg_DisableScrollbarsForSmallWindows(routing_id(), size)); +} + +void RenderWidgetHost::EnablePreferredSizeMode(int flags) { + Send(new ViewMsg_EnablePreferredSizeChangedMode(routing_id(), flags)); +} + diff --git a/content/browser/renderer_host/render_widget_host.h b/content/browser/renderer_host/render_widget_host.h index 16cfd97..fa90998 100644 --- a/content/browser/renderer_host/render_widget_host.h +++ b/content/browser/renderer_host/render_widget_host.h @@ -17,6 +17,7 @@ #include "base/timer.h" #include "content/common/content_export.h" #include "content/common/native_web_keyboard_event.h" +#include "content/common/page_zoom.h" #include "content/common/property_bag.h" #include "ipc/ipc_channel.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" @@ -40,6 +41,7 @@ class WebInputEvent; class WebMouseEvent; struct WebCompositionUnderline; struct WebScreenInfo; +struct WebFindOptions; } class BackingStore; @@ -373,6 +375,30 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener, // perform an action. See OnUserGesture for more details. void StartUserGesture(); + // Changes the zoom level for the current main frame. + void Zoom(PageZoom::Function zoom_function); + + // Reloads the current focused frame. + void ReloadFrame(); + + // Finds text on a page. + void Find(int request_id, const string16& search_text, + const WebKit::WebFindOptions& options); + + // Stops loading the page. + void Stop(); + + // Requests the renderer to evaluate an xpath to a frame and insert css + // into that frame's document. + void InsertCSS(const string16& frame_xpath, const std::string& css); + + // Tells the renderer not to add scrollbars with height and width below a + // threshold. + void DisableScrollbarsForThreshold(const gfx::Size& size); + + // Instructs the RenderView to send back updates to the preferred size. + void EnablePreferredSizeMode(int flags); + protected: // Internal implementation of the public Forward*Event() methods. void ForwardInputEvent(const WebKit::WebInputEvent& input_event, diff --git a/content/browser/tab_contents/render_view_host_manager.cc b/content/browser/tab_contents/render_view_host_manager.cc index 0fcc1df..e486be3 100644 --- a/content/browser/tab_contents/render_view_host_manager.cc +++ b/content/browser/tab_contents/render_view_host_manager.cc @@ -125,7 +125,7 @@ RenderViewHost* RenderViewHostManager::Navigate(const NavigationEntry& entry) { } void RenderViewHostManager::Stop() { - render_view_host_->Send(new ViewMsg_Stop(render_view_host_->routing_id())); + render_view_host_->Stop(); // If we are cross-navigating, we should stop the pending renderers. This // will lead to a DidFailProvisionalLoad, which will properly destroy them. |