diff options
author | scottmg <scottmg@chromium.org> | 2016-02-02 17:27:24 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-03 01:28:12 +0000 |
commit | 5c03fe02699201911d37510b73597e40dba19286 (patch) | |
tree | 2534abae2a5524dfbecec587602fddb1330642d0 /chrome/browser/ui | |
parent | 8a3270a91f3425b12240cd617a2162b7aad7e733 (diff) | |
download | chromium_src-5c03fe02699201911d37510b73597e40dba19286.zip chromium_src-5c03fe02699201911d37510b73597e40dba19286.tar.gz chromium_src-5c03fe02699201911d37510b73597e40dba19286.tar.bz2 |
Remove HostDesktopType from FindLastActive[WithProfile]
From chrome/browser/ui/browser_finder.h.
R=sky@chromium.org
BUG=558054
Review URL: https://codereview.chromium.org/1659203002
Cr-Commit-Position: refs/heads/master@{#373118}
Diffstat (limited to 'chrome/browser/ui')
23 files changed, 39 insertions, 72 deletions
diff --git a/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc b/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc index 818a165..d20b66a 100644 --- a/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc +++ b/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc @@ -493,8 +493,7 @@ bool SystemTrayDelegateChromeOS::ShouldShowDisplayNotification() { // Packaged app is not counted as 'last active', so if a browser opening the // display settings is in background of a packaged app, it will return true. // TODO(mukai): fix this. - Browser* active_browser = - chrome::FindLastActiveWithHostDesktopType(chrome::HOST_DESKTOP_TYPE_ASH); + Browser* active_browser = chrome::FindLastActive(); if (!active_browser) return true; diff --git a/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc b/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc index a14af17..e7bda79 100644 --- a/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc +++ b/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc @@ -107,9 +107,8 @@ class CloseObserver : public content::WebContentsObserver { class BrowserActivationObserver : public chrome::BrowserListObserver { public: - explicit BrowserActivationObserver(chrome::HostDesktopType desktop_type) - : browser_(chrome::FindLastActiveWithHostDesktopType(desktop_type)), - observed_(false) { + BrowserActivationObserver() + : browser_(chrome::FindLastActive()), observed_(false) { BrowserList::AddObserver(this); } ~BrowserActivationObserver() override { BrowserList::RemoveObserver(this); } @@ -580,8 +579,7 @@ IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, ModalPopUnder) { NavigateAndCheckPopupShown(url, ExpectPopup); - Browser* popup_browser = - chrome::FindLastActiveWithHostDesktopType(browser()->host_desktop_type()); + Browser* popup_browser = chrome::FindLastActive(); ASSERT_NE(popup_browser, browser()); // Showing an alert will raise the tab over the popup. @@ -593,15 +591,12 @@ IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, ModalPopUnder) { app_modal::JavaScriptAppModalDialog* js_dialog = static_cast<app_modal::JavaScriptAppModalDialog*>(dialog); - BrowserActivationObserver activation_observer(browser()->host_desktop_type()); + BrowserActivationObserver activation_observer; js_dialog->native_dialog()->AcceptAppModalDialog(); - if (popup_browser != chrome::FindLastActiveWithHostDesktopType( - popup_browser->host_desktop_type())) { + if (popup_browser != chrome::FindLastActive()) activation_observer.WaitForActivation(); - } - ASSERT_EQ(popup_browser, chrome::FindLastActiveWithHostDesktopType( - popup_browser->host_desktop_type())); + ASSERT_EQ(popup_browser, chrome::FindLastActive()); } void BuildSimpleWebKeyEvent(blink::WebInputEvent::Type type, diff --git a/chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.cc b/chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.cc index b78d631..f64655b 100644 --- a/chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.cc +++ b/chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.cc @@ -37,8 +37,7 @@ void BookmarkBubbleSignInDelegate::OnBrowserRemoved(Browser* browser) { void BookmarkBubbleSignInDelegate::EnsureBrowser() { if (!browser_) { Profile* original_profile = profile_->GetOriginalProfile(); - browser_ = chrome::FindLastActiveWithProfile(original_profile, - desktop_type_); + browser_ = chrome::FindLastActiveWithProfile(original_profile); if (!browser_) { browser_ = new Browser(Browser::CreateParams(original_profile, desktop_type_)); diff --git a/chrome/browser/ui/browser_finder.cc b/chrome/browser/ui/browser_finder.cc index e79cae3..159e1eb 100644 --- a/chrome/browser/ui/browser_finder.cc +++ b/chrome/browser/ui/browser_finder.cc @@ -201,7 +201,7 @@ Browser* FindBrowserWithWebContents(const WebContents* web_contents) { return NULL; } -Browser* FindLastActiveWithProfile(Profile* profile, HostDesktopType type) { +Browser* FindLastActiveWithProfile(Profile* profile) { BrowserList* list = BrowserList::GetInstance(); // We are only interested in last active browsers, so we don't fall back to // all browsers like FindBrowserWith* do. @@ -209,7 +209,7 @@ Browser* FindLastActiveWithProfile(Profile* profile, HostDesktopType type) { profile, Browser::FEATURE_NONE, kMatchAny); } -Browser* FindLastActiveWithHostDesktopType(HostDesktopType type) { +Browser* FindLastActive() { BrowserList* browser_list_impl = BrowserList::GetInstance(); if (browser_list_impl) return browser_list_impl->GetLastActive(); diff --git a/chrome/browser/ui/browser_finder.h b/chrome/browser/ui/browser_finder.h index 8425c9f..0daeaab 100644 --- a/chrome/browser/ui/browser_finder.h +++ b/chrome/browser/ui/browser_finder.h @@ -67,7 +67,7 @@ Browser* FindBrowserWithWebContents(const content::WebContents* web_contents); // clicks on another app before the first browser window appears) then this // returns NULL. // WARNING #2: this will always be NULL in unit tests run on the bots. -Browser* FindLastActiveWithProfile(Profile* profile, HostDesktopType type); +Browser* FindLastActiveWithProfile(Profile* profile); // Returns the Browser object on the given desktop type whose window was most // recently active. If no such Browsers exist, returns NULL. @@ -77,7 +77,7 @@ Browser* FindLastActiveWithProfile(Profile* profile, HostDesktopType type); // clicks on another app before the first browser window appears) then this // returns NULL. // WARNING #2: this will always be NULL in unit tests run on the bots. -Browser* FindLastActiveWithHostDesktopType(HostDesktopType type); +Browser* FindLastActive(); // Returns the number of browsers across all profiles and desktops. size_t GetTotalBrowserCount(); diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm index dadf9ad..8955416 100644 --- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm @@ -153,8 +153,8 @@ void BrowserWindowCocoa::Show() { // browser at the time |Show()| is called. This is the natural behaviour under // Windows, but |-makeKeyAndOrderFront:| won't send |-windowDidBecomeMain:| // until we return to the runloop. Therefore any calls to - // |chrome::FindLastActiveWithHostDesktopType| will return the previous - // browser instead if we don't explicitly set it here. + // |chrome::FindLastActive| will return the previous browser instead if we + // don't explicitly set it here. BrowserList::SetLastActive(browser_); bool is_session_restore = browser_->is_session_restore(); diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm index 0299daa..d8a1f67 100644 --- a/chrome/browser/ui/cocoa/browser_window_controller.mm +++ b/chrome/browser/ui/cocoa/browser_window_controller.mm @@ -295,9 +295,7 @@ void SetUpBrowserWindowCommandHandler(NSWindow* window) { if (browser_->is_type_popup() && windowRect.x() == 0 && windowRect.y() == 0) { gfx::Size size = windowRect.size(); - windowRect.set_origin( - WindowSizer::GetDefaultPopupOrigin(size, - browser_->host_desktop_type())); + windowRect.set_origin(WindowSizer::GetDefaultPopupOrigin(size)); } // Size and position the window. Note that it is not yet onscreen. Popup diff --git a/chrome/browser/ui/cocoa/handoff_active_url_observer.cc b/chrome/browser/ui/cocoa/handoff_active_url_observer.cc index a2862e4..ba154b2 100644 --- a/chrome/browser/ui/cocoa/handoff_active_url_observer.cc +++ b/chrome/browser/ui/cocoa/handoff_active_url_observer.cc @@ -18,8 +18,7 @@ HandoffActiveURLObserver::HandoffActiveURLObserver( DCHECK(delegate_); BrowserList::AddObserver(this); - SetActiveBrowser(chrome::FindLastActiveWithHostDesktopType( - chrome::HOST_DESKTOP_TYPE_NATIVE)); + SetActiveBrowser(chrome::FindLastActive()); } HandoffActiveURLObserver::~HandoffActiveURLObserver() { @@ -36,8 +35,7 @@ void HandoffActiveURLObserver::OnBrowserRemoved(Browser* removed_browser) { if (active_browser_ != removed_browser) return; - SetActiveBrowser(chrome::FindLastActiveWithHostDesktopType( - chrome::HOST_DESKTOP_TYPE_NATIVE)); + SetActiveBrowser(chrome::FindLastActive()); delegate_->HandoffActiveURLChanged(GetActiveWebContents()); } diff --git a/chrome/browser/ui/cocoa/last_active_browser_cocoa.cc b/chrome/browser/ui/cocoa/last_active_browser_cocoa.cc index d0cd335..3bece9d 100644 --- a/chrome/browser/ui/cocoa/last_active_browser_cocoa.cc +++ b/chrome/browser/ui/cocoa/last_active_browser_cocoa.cc @@ -9,7 +9,7 @@ namespace chrome { Browser* GetLastActiveBrowser() { - return FindLastActiveWithHostDesktopType(HOST_DESKTOP_TYPE_NATIVE); + return FindLastActive(); } } // namespace chrome diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model_browsertest.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model_browsertest.cc index 6303502..2a54f7f 100644 --- a/chrome/browser/ui/content_settings/content_setting_bubble_model_browsertest.cc +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model_browsertest.cc @@ -119,8 +119,7 @@ class ContentSettingBubbleModelMediaStreamTest : public InProcessBrowserTest { content::WebContents* GetActiveTab() { // First, we need to find the active browser window. It should be at // the same desktop as the browser in which we invoked the bubble. - Browser* active_browser = chrome::FindLastActiveWithHostDesktopType( - browser()->host_desktop_type()); + Browser* active_browser = chrome::FindLastActive(); return active_browser->tab_strip_model()->GetActiveWebContents(); } }; diff --git a/chrome/browser/ui/extensions/extension_install_ui_default.cc b/chrome/browser/ui/extensions/extension_install_ui_default.cc index b954ca4..1848168 100644 --- a/chrome/browser/ui/extensions/extension_install_ui_default.cc +++ b/chrome/browser/ui/extensions/extension_install_ui_default.cc @@ -211,8 +211,7 @@ void ExtensionInstallUIDefault::OnInstallFailure( if (disable_failure_ui_for_tests() || skip_post_install_ui_) return; - Browser* browser = - chrome::FindLastActiveWithProfile(profile_, chrome::GetActiveDesktop()); + Browser* browser = chrome::FindLastActiveWithProfile(profile_); if (!browser) // Can be NULL in unittests. return; WebContents* web_contents = @@ -256,8 +255,7 @@ void ExtensionInstallUIDefault::SetSkipPostInstallUI(bool skip_ui) { } gfx::NativeWindow ExtensionInstallUIDefault::GetDefaultInstallDialogParent() { - Browser* browser = - chrome::FindLastActiveWithProfile(profile_, chrome::GetActiveDesktop()); + Browser* browser = chrome::FindLastActiveWithProfile(profile_); if (browser) { content::WebContents* contents = browser->tab_strip_model()->GetActiveWebContents(); diff --git a/chrome/browser/ui/network_profile_bubble.cc b/chrome/browser/ui/network_profile_bubble.cc index 3ac8ae4..d6fb3d9 100644 --- a/chrome/browser/ui/network_profile_bubble.cc +++ b/chrome/browser/ui/network_profile_bubble.cc @@ -174,8 +174,7 @@ void NetworkProfileBubble::RecordUmaEvent(MetricNetworkedProfileCheck event) { // static void NetworkProfileBubble::NotifyNetworkProfileDetected() { - Browser* browser = chrome::FindLastActiveWithHostDesktopType( - chrome::GetActiveDesktop()); + Browser* browser = chrome::FindLastActive(); if (browser) ShowNotification(browser); diff --git a/chrome/browser/ui/startup/default_browser_prompt.cc b/chrome/browser/ui/startup/default_browser_prompt.cc index a6efe4c..2357af0 100644 --- a/chrome/browser/ui/startup/default_browser_prompt.cc +++ b/chrome/browser/ui/startup/default_browser_prompt.cc @@ -260,7 +260,7 @@ void CheckDefaultBrowserObserver::ResetCheckDefaultBrowserPref() { } void CheckDefaultBrowserObserver::ShowPrompt() { - Browser* browser = chrome::FindLastActiveWithHostDesktopType(desktop_type_); + Browser* browser = chrome::FindLastActive(); if (!browser) return; // Reached during ui tests. diff --git a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc index 47d5793..4061c1c 100644 --- a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc +++ b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc @@ -545,7 +545,7 @@ Browser* OneClickSigninSyncStarter::EnsureBrowser( // The user just created a new profile or has closed the browser that // we used previously. Grab the most recently active browser or else // create a new one. - browser = chrome::FindLastActiveWithProfile(profile, desktop_type); + browser = chrome::FindLastActiveWithProfile(profile); if (!browser) { browser = new Browser(Browser::CreateParams(profile, desktop_type)); diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 964b105..6c31812 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -1842,9 +1842,7 @@ bool BrowserView::GetSavedWindowPlacement( // assume none were given by the window.open() command. if (window_rect.x() == 0 && window_rect.y() == 0) { gfx::Size size = window_rect.size(); - window_rect.set_origin( - WindowSizer::GetDefaultPopupOrigin(size, - browser_->host_desktop_type())); + window_rect.set_origin(WindowSizer::GetDefaultPopupOrigin(size)); } *bounds = window_rect; diff --git a/chrome/browser/ui/views/profiles/user_manager_view.cc b/chrome/browser/ui/views/profiles/user_manager_view.cc index 34e67ec..cd9ce66 100644 --- a/chrome/browser/ui/views/profiles/user_manager_view.cc +++ b/chrome/browser/ui/views/profiles/user_manager_view.cc @@ -285,8 +285,7 @@ void UserManagerView::Init(Profile* system_profile, const GURL& url) { profile_manager->GetLastUsedProfileDir(profile_manager->user_data_dir()); Profile* profile = profile_manager->GetProfileByPath(last_used_profile_path); if (profile) { - Browser* browser = chrome::FindLastActiveWithProfile(profile, - chrome::GetActiveDesktop()); + Browser* browser = chrome::FindLastActiveWithProfile(profile); if (browser) { gfx::NativeView native_view = views::Widget::GetWidgetForNativeWindow( diff --git a/chrome/browser/ui/views/select_file_dialog_extension.cc b/chrome/browser/ui/views/select_file_dialog_extension.cc index 61c50f0..9784d6a 100644 --- a/chrome/browser/ui/views/select_file_dialog_extension.cc +++ b/chrome/browser/ui/views/select_file_dialog_extension.cc @@ -123,10 +123,8 @@ void FindRuntimeContext(gfx::NativeWindow owner_window, } else { // If the owning window is still unknown, this could be a background page or // and extension popup. Use the last active browser. - if (!owner_browser) { - owner_browser = - chrome::FindLastActiveWithHostDesktopType(chrome::GetActiveDesktop()); - } + if (!owner_browser) + owner_browser = chrome::FindLastActive(); if (owner_browser) { *base_window = owner_browser->window(); *web_contents = owner_browser->tab_strip_model()->GetActiveWebContents(); diff --git a/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc b/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc index ab68868..c97de48 100644 --- a/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc +++ b/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc @@ -386,8 +386,7 @@ bool InlineSigninHelper::HandleCrossAccountError( return false; } - Browser* browser = chrome::FindLastActiveWithProfile( - profile_, chrome::GetActiveDesktop()); + Browser* browser = chrome::FindLastActiveWithProfile(profile_); content::WebContents* web_contents = browser->tab_strip_model()->GetActiveWebContents(); @@ -410,8 +409,7 @@ void InlineSigninHelper::ConfirmEmailAction( OneClickSigninSyncStarter::ConfirmationRequired confirmation_required, OneClickSigninSyncStarter::StartSyncMode start_mode, InlineSigninHelper::Action action) { - Browser* browser = chrome::FindLastActiveWithProfile( - profile_, chrome::GetActiveDesktop()); + Browser* browser = chrome::FindLastActiveWithProfile(profile_); switch (action) { case InlineSigninHelper::CREATE_NEW_USER: content::RecordAction( @@ -859,10 +857,8 @@ void InlineLoginHandlerImpl::HandleLoginError(const std::string& error_msg) { Browser* InlineLoginHandlerImpl::GetDesktopBrowser() { Browser* browser = chrome::FindBrowserWithWebContents( web_ui()->GetWebContents()); - if (!browser) { - browser = chrome::FindLastActiveWithProfile( - Profile::FromWebUI(web_ui()), chrome::GetActiveDesktop()); - } + if (!browser) + browser = chrome::FindLastActiveWithProfile(Profile::FromWebUI(web_ui())); return browser; } diff --git a/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc b/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc index 4c07b75..b5194fe 100644 --- a/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc +++ b/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc @@ -96,10 +96,8 @@ void SyncConfirmationHandler::OnAccountUpdated(const AccountInfo& info) { Browser* SyncConfirmationHandler::GetDesktopBrowser() { Browser* browser = chrome::FindBrowserWithWebContents( web_ui()->GetWebContents()); - if (!browser) { - browser = chrome::FindLastActiveWithProfile( - Profile::FromWebUI(web_ui()), chrome::GetActiveDesktop()); - } + if (!browser) + browser = chrome::FindLastActiveWithProfile(Profile::FromWebUI(web_ui())); DCHECK(browser); return browser; } diff --git a/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc b/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc index 26df800..fe0fafa 100644 --- a/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc +++ b/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc @@ -207,7 +207,7 @@ void UrlHashHelper::ExecuteUrlHash() { Browser* target_browser = browser_; if (!target_browser) { - target_browser = chrome::FindLastActiveWithProfile(profile_, desktop_type_); + target_browser = chrome::FindLastActiveWithProfile(profile_); if (!target_browser) return; } diff --git a/chrome/browser/ui/window_sizer/window_sizer.h b/chrome/browser/ui/window_sizer/window_sizer.h index 5d74b00..8408392 100644 --- a/chrome/browser/ui/window_sizer/window_sizer.h +++ b/chrome/browser/ui/window_sizer/window_sizer.h @@ -7,7 +7,6 @@ #include "base/macros.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/ui/host_desktop.h" #include "ui/base/ui_base_types.h" #include "ui/gfx/geometry/rect.h" @@ -108,8 +107,7 @@ class WindowSizer { ui::WindowShowState* show_state); // Returns the default origin for popups of the given size. - static gfx::Point GetDefaultPopupOrigin(const gfx::Size& size, - chrome::HostDesktopType type); + static gfx::Point GetDefaultPopupOrigin(const gfx::Size& size); // How much horizontal and vertical offset there is between newly // opened windows. This value may be different on each platform. diff --git a/chrome/browser/ui/window_sizer/window_sizer_aura.cc b/chrome/browser/ui/window_sizer/window_sizer_aura.cc index 358bd4b..0406ef5 100644 --- a/chrome/browser/ui/window_sizer/window_sizer_aura.cc +++ b/chrome/browser/ui/window_sizer/window_sizer_aura.cc @@ -4,15 +4,12 @@ #include "chrome/browser/ui/window_sizer/window_sizer.h" -#include "chrome/browser/ui/host_desktop.h" - // This doesn't matter for aura, which has different tiling. // static const int WindowSizer::kWindowTilePixels = 10; // static -gfx::Point WindowSizer::GetDefaultPopupOrigin(const gfx::Size& size, - chrome::HostDesktopType type) { +gfx::Point WindowSizer::GetDefaultPopupOrigin(const gfx::Size& size) { // TODO(skuhne): Check if this isn't needed anymore (since it is implemented // in WindowPositioner) and remove it. return gfx::Point(); diff --git a/chrome/browser/ui/window_sizer/window_sizer_mac.mm b/chrome/browser/ui/window_sizer/window_sizer_mac.mm index 64d049f..0254641 100644 --- a/chrome/browser/ui/window_sizer/window_sizer_mac.mm +++ b/chrome/browser/ui/window_sizer/window_sizer_mac.mm @@ -9,20 +9,18 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_window.h" -#include "chrome/browser/ui/host_desktop.h" // How much horizontal and vertical offset there is between newly // opened windows. const int WindowSizer::kWindowTilePixels = 22; // static -gfx::Point WindowSizer::GetDefaultPopupOrigin(const gfx::Size& size, - chrome::HostDesktopType type) { +gfx::Point WindowSizer::GetDefaultPopupOrigin(const gfx::Size& size) { NSRect work_area = [[NSScreen mainScreen] visibleFrame]; NSRect main_area = [[[NSScreen screens] firstObject] frame]; NSPoint corner = NSMakePoint(NSMinX(work_area), NSMaxY(work_area)); - if (Browser* browser = chrome::FindLastActiveWithHostDesktopType(type)) { + if (Browser* browser = chrome::FindLastActive()) { NSWindow* window = browser->window()->GetNativeWindow(); NSRect window_frame = [window frame]; |