diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-16 20:29:01 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-16 20:29:01 +0000 |
commit | e1ff4a4ae373958c2e964e57d9b07a76c20065e6 (patch) | |
tree | 80efec1e89a94dfb5194f1ea666f67533b58bea8 | |
parent | ef7e621cde4d038c3684fb94a4055abe4adbd064 (diff) | |
download | chromium_src-e1ff4a4ae373958c2e964e57d9b07a76c20065e6.zip chromium_src-e1ff4a4ae373958c2e964e57d9b07a76c20065e6.tar.gz chromium_src-e1ff4a4ae373958c2e964e57d9b07a76c20065e6.tar.bz2 |
Remove some static methods on Browser that were used to service WebContentsDelegate implementations in Browser and ExternalTabContentsWin. Instead these can be methods on Browser.
BUG=316496
R=grt@chromium.org
Review URL: https://codereview.chromium.org/108023003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241008 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/ui/browser.cc | 137 | ||||
-rw-r--r-- | chrome/browser/ui/browser.h | 25 | ||||
-rw-r--r-- | chrome/browser/ui/browser_tab_strip_model_delegate.cc | 16 | ||||
-rw-r--r-- | chrome/browser/ui/views/external_tab_container_win.cc | 46 | ||||
-rw-r--r-- | chrome/browser/ui/views/external_tab_container_win.h | 12 |
5 files changed, 62 insertions, 174 deletions
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index bd68eb3..eaa47a6 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -849,90 +849,6 @@ void Browser::UpdateDownloadShelfVisibility(bool visible) { /////////////////////////////////////////////////////////////////////////////// -// static -bool Browser::ShouldRunUnloadEventsHelper(content::WebContents* contents) { - if (IsFastTabUnloadEnabled()) - return chrome::FastUnloadController::ShouldRunUnloadEventsHelper(contents); - return chrome::UnloadController::ShouldRunUnloadEventsHelper(contents); -} - -// static -bool Browser::RunUnloadEventsHelper(WebContents* contents) { - if (IsFastTabUnloadEnabled()) - return chrome::FastUnloadController::RunUnloadEventsHelper(contents); - return chrome::UnloadController::RunUnloadEventsHelper(contents); -} - -// static -void Browser::JSOutOfMemoryHelper(WebContents* web_contents) { - InfoBarService* infobar_service = - InfoBarService::FromWebContents(web_contents); - if (!infobar_service) - return; - SimpleAlertInfoBarDelegate::Create( - infobar_service, InfoBarDelegate::kNoIconID, - l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), true); -} - -// static -void Browser::RegisterProtocolHandlerHelper(WebContents* web_contents, - const std::string& protocol, - const GURL& url, - const base::string16& title, - bool user_gesture, - BrowserWindow* window) { - Profile* profile = - Profile::FromBrowserContext(web_contents->GetBrowserContext()); - if (profile->IsOffTheRecord()) - return; - - ProtocolHandler handler = - ProtocolHandler::CreateProtocolHandler(protocol, url, title); - - ProtocolHandlerRegistry* registry = - ProtocolHandlerRegistryFactory::GetForProfile(profile); - if (registry->SilentlyHandleRegisterHandlerRequest(handler)) - return; - - TabSpecificContentSettings* tab_content_settings = - TabSpecificContentSettings::FromWebContents(web_contents); - if (!user_gesture && window) { - tab_content_settings->set_pending_protocol_handler(handler); - tab_content_settings->set_previous_protocol_handler( - registry->GetHandlerFor(handler.protocol())); - window->GetLocationBar()->UpdateContentSettingsIcons(); - return; - } - - // Make sure content-setting icon is turned off in case the page does - // ungestured and gestured RPH calls. - if (window) { - tab_content_settings->ClearPendingProtocolHandler(); - window->GetLocationBar()->UpdateContentSettingsIcons(); - } - - RegisterProtocolHandlerInfoBarDelegate::Create( - InfoBarService::FromWebContents(web_contents), registry, handler); -} - -// static -void Browser::FindReplyHelper(WebContents* web_contents, - int request_id, - int number_of_matches, - const gfx::Rect& selection_rect, - int active_match_ordinal, - bool final_update) { - FindTabHelper* find_tab_helper = FindTabHelper::FromWebContents(web_contents); - if (!find_tab_helper) - return; - - find_tab_helper->HandleFindReply(request_id, - number_of_matches, - selection_rect, - active_match_ordinal, - final_update); -} - void Browser::UpdateUIForNavigationInTab(WebContents* contents, content::PageTransition transition, bool user_initiated) { @@ -1666,7 +1582,13 @@ bool Browser::IsFullscreenForTabOrPending( } void Browser::JSOutOfMemory(WebContents* web_contents) { - JSOutOfMemoryHelper(web_contents); + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); + if (!infobar_service) + return; + SimpleAlertInfoBarDelegate::Create( + infobar_service, InfoBarDelegate::kNoIconID, + l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), true); } void Browser::RegisterProtocolHandler(WebContents* web_contents, @@ -1674,8 +1596,38 @@ void Browser::RegisterProtocolHandler(WebContents* web_contents, const GURL& url, const base::string16& title, bool user_gesture) { - RegisterProtocolHandlerHelper( - web_contents, protocol, url, title, user_gesture, window()); + Profile* profile = + Profile::FromBrowserContext(web_contents->GetBrowserContext()); + if (profile->IsOffTheRecord()) + return; + + ProtocolHandler handler = + ProtocolHandler::CreateProtocolHandler(protocol, url, title); + + ProtocolHandlerRegistry* registry = + ProtocolHandlerRegistryFactory::GetForProfile(profile); + if (registry->SilentlyHandleRegisterHandlerRequest(handler)) + return; + + TabSpecificContentSettings* tab_content_settings = + TabSpecificContentSettings::FromWebContents(web_contents); + if (!user_gesture && window_) { + tab_content_settings->set_pending_protocol_handler(handler); + tab_content_settings->set_previous_protocol_handler( + registry->GetHandlerFor(handler.protocol())); + window_->GetLocationBar()->UpdateContentSettingsIcons(); + return; + } + + // Make sure content-setting icon is turned off in case the page does + // ungestured and gestured RPH calls. + if (window_) { + tab_content_settings->ClearPendingProtocolHandler(); + window_->GetLocationBar()->UpdateContentSettingsIcons(); + } + + RegisterProtocolHandlerInfoBarDelegate::Create( + InfoBarService::FromWebContents(web_contents), registry, handler); } void Browser::UpdatePreferredSize(WebContents* source, @@ -1694,8 +1646,15 @@ void Browser::FindReply(WebContents* web_contents, const gfx::Rect& selection_rect, int active_match_ordinal, bool final_update) { - FindReplyHelper(web_contents, request_id, number_of_matches, selection_rect, - active_match_ordinal, final_update); + FindTabHelper* find_tab_helper = FindTabHelper::FromWebContents(web_contents); + if (!find_tab_helper) + return; + + find_tab_helper->HandleFindReply(request_id, + number_of_matches, + selection_rect, + active_match_ordinal, + final_update); } void Browser::RequestToLockMouse(WebContents* web_contents, diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h index 893458f..c9c5543 100644 --- a/chrome/browser/ui/browser.h +++ b/chrome/browser/ui/browser.h @@ -395,31 +395,6 @@ class Browser : public TabStripModelObserver, ///////////////////////////////////////////////////////////////////////////// - // Returns true if we need to run unload events for the |contents|. - static bool ShouldRunUnloadEventsHelper(content::WebContents* contents); - - // Helper function to run unload listeners on a WebContents. - static bool RunUnloadEventsHelper(content::WebContents* contents); - - // Helper function to handle JS out of memory notifications - static void JSOutOfMemoryHelper(content::WebContents* web_contents); - - // Helper function to register a protocol handler. - static void RegisterProtocolHandlerHelper(content::WebContents* web_contents, - const std::string& protocol, - const GURL& url, - const base::string16& title, - bool user_gesture, - BrowserWindow* window); - - // Helper function to handle find results. - static void FindReplyHelper(content::WebContents* web_contents, - int request_id, - int number_of_matches, - const gfx::Rect& selection_rect, - int active_match_ordinal, - bool final_update); - // Called by chrome::Navigate() when a navigation has occurred in a tab in // this Browser. Updates the UI for the start of this navigation. void UpdateUIForNavigationInTab(content::WebContents* contents, diff --git a/chrome/browser/ui/browser_tab_strip_model_delegate.cc b/chrome/browser/ui/browser_tab_strip_model_delegate.cc index 8486b17..dc9bff9 100644 --- a/chrome/browser/ui/browser_tab_strip_model_delegate.cc +++ b/chrome/browser/ui/browser_tab_strip_model_delegate.cc @@ -5,6 +5,7 @@ #include "chrome/browser/ui/browser_tab_strip_model_delegate.h" #include "base/bind.h" +#include "base/command_line.h" #include "base/message_loop/message_loop.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sessions/tab_restore_service.h" @@ -15,8 +16,11 @@ #include "chrome/browser/ui/browser_tab_contents.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_window.h" +#include "chrome/browser/ui/fast_unload_controller.h" #include "chrome/browser/ui/tabs/dock_info.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" +#include "chrome/browser/ui/unload_controller.h" +#include "chrome/common/chrome_switches.h" #include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_delegate.h" @@ -136,12 +140,20 @@ void BrowserTabStripModelDelegate::CreateHistoricalTab( bool BrowserTabStripModelDelegate::RunUnloadListenerBeforeClosing( content::WebContents* contents) { - return Browser::RunUnloadEventsHelper(contents); + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableFastUnload)) { + return chrome::FastUnloadController::RunUnloadEventsHelper(contents); + } + return chrome::UnloadController::RunUnloadEventsHelper(contents); } bool BrowserTabStripModelDelegate::ShouldRunUnloadListenerBeforeClosing( content::WebContents* contents) { - return Browser::ShouldRunUnloadEventsHelper(contents); + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableFastUnload)) { + return chrome::FastUnloadController::ShouldRunUnloadEventsHelper(contents); + } + return chrome::UnloadController::ShouldRunUnloadEventsHelper(contents); } bool BrowserTabStripModelDelegate::CanBookmarkAllTabs() const { diff --git a/chrome/browser/ui/views/external_tab_container_win.cc b/chrome/browser/ui/views/external_tab_container_win.cc index a16b79f..81ccf6d 100644 --- a/chrome/browser/ui/views/external_tab_container_win.cc +++ b/chrome/browser/ui/views/external_tab_container_win.cc @@ -569,28 +569,6 @@ bool ExternalTabContainerWin::ExecuteContextMenuCommand(int command) { } void ExternalTabContainerWin::RunUnloadHandlers(IPC::Message* reply_message) { - if (!automation_) { - delete reply_message; - return; - } - - // If we have a pending unload message, then just respond back to this - // request and continue processing the previous unload message. - if (unload_reply_message_) { - AutomationMsg_RunUnloadHandlers::WriteReplyParams(reply_message, true); - automation_->Send(reply_message); - return; - } - - unload_reply_message_ = reply_message; - bool wait_for_unload_handlers = - web_contents_.get() && - Browser::RunUnloadEventsHelper(web_contents_.get()); - if (!wait_for_unload_handlers) { - AutomationMsg_RunUnloadHandlers::WriteReplyParams(reply_message, true); - automation_->Send(reply_message); - unload_reply_message_ = NULL; - } } void ExternalTabContainerWin::ProcessUnhandledAccelerator(const MSG& msg) { @@ -1014,30 +992,6 @@ void ExternalTabContainerWin::EnumerateDirectory(WebContents* tab, FileSelectHelper::EnumerateDirectory(tab, request_id, path); } -void ExternalTabContainerWin::JSOutOfMemory(WebContents* tab) { - Browser::JSOutOfMemoryHelper(tab); -} - -void ExternalTabContainerWin::RegisterProtocolHandler( - WebContents* tab, - const std::string& protocol, - const GURL& url, - const base::string16& title, - bool user_gesture) { - Browser::RegisterProtocolHandlerHelper(tab, protocol, url, title, - user_gesture, NULL); -} - -void ExternalTabContainerWin::FindReply(WebContents* tab, - int request_id, - int number_of_matches, - const gfx::Rect& selection_rect, - int active_match_ordinal, - bool final_update) { - Browser::FindReplyHelper(tab, request_id, number_of_matches, selection_rect, - active_match_ordinal, final_update); -} - void ExternalTabContainerWin::RequestMediaAccessPermission( content::WebContents* web_contents, const content::MediaStreamRequest& request, diff --git a/chrome/browser/ui/views/external_tab_container_win.h b/chrome/browser/ui/views/external_tab_container_win.h index bda2ddc..182548a 100644 --- a/chrome/browser/ui/views/external_tab_container_win.h +++ b/chrome/browser/ui/views/external_tab_container_win.h @@ -153,18 +153,6 @@ class ExternalTabContainerWin : public ExternalTabContainer, virtual void EnumerateDirectory(content::WebContents* tab, int request_id, const base::FilePath& path) OVERRIDE; - virtual void JSOutOfMemory(content::WebContents* tab); - virtual void RegisterProtocolHandler(content::WebContents* tab, - const std::string& protocol, - const GURL& url, - const base::string16& title, - bool user_gesture) OVERRIDE; - virtual void FindReply(content::WebContents* tab, - int request_id, - int number_of_matches, - const gfx::Rect& selection_rect, - int active_match_ordinal, - bool final_update) OVERRIDE; virtual void RequestMediaAccessPermission( content::WebContents* web_contents, const content::MediaStreamRequest& request, |