summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-27 13:54:12 +0000
committergrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-27 13:54:12 +0000
commit6e5b39d9a34b83a8fe4c9541ab9b7afa9cdccc61 (patch)
tree68f67d06f237316a6b2f0a3c4d31b5c5109958cd
parente6e7db7f883ab88bc43a4f95033606eba9f1245f (diff)
downloadchromium_src-6e5b39d9a34b83a8fe4c9541ab9b7afa9cdccc61.zip
chromium_src-6e5b39d9a34b83a8fe4c9541ab9b7afa9cdccc61.tar.gz
chromium_src-6e5b39d9a34b83a8fe4c9541ab9b7afa9cdccc61.tar.bz2
FindLastActiveWithProfile now requires a HostDesktopType.
BUG=129187 TEST=none Review URL: https://chromiumcodereview.appspot.com/11365128 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169654 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--PRESUBMIT.py9
-rw-r--r--chrome/browser/app_controller_mac.mm3
-rw-r--r--chrome/browser/background/background_contents_service.cc4
-rw-r--r--chrome/browser/background/background_mode_manager.cc4
-rw-r--r--chrome/browser/chromeos/drive/drive_file_system_util.cc3
-rw-r--r--chrome/browser/chromeos/extensions/file_manager_util.cc3
-rw-r--r--chrome/browser/download/chrome_download_manager_delegate.cc4
-rw-r--r--chrome/browser/download/download_crx_util.cc8
-rw-r--r--chrome/browser/extensions/bundle_installer.cc3
-rw-r--r--chrome/browser/extensions/bundle_installer.h4
-rw-r--r--chrome/browser/extensions/extension_error_ui_default.cc4
-rw-r--r--chrome/browser/extensions/extension_install_ui_default.cc7
-rw-r--r--chrome/browser/notifications/balloon_host.cc4
-rw-r--r--chrome/browser/notifications/notification_options_menu_model.cc4
-rw-r--r--chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc4
-rw-r--r--chrome/browser/ui/browser_finder.cc8
-rw-r--r--chrome/browser/ui/browser_finder.h8
17 files changed, 52 insertions, 32 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 2fba7a5..e9c4212 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -147,15 +147,6 @@ _BANNED_CPP_FUNCTIONS = (
False,
),
(
- 'chrome::FindLastActiveWithProfile',
- (
- 'This function is deprecated and we\'re working on removing it. Pass',
- 'more context to get a Browser*, like a WebContents, window, or session',
- 'id. Talk to robertshield@ for more information.',
- ),
- True,
- ),
- (
'browser::FindAnyBrowser',
(
'This function is deprecated and we\'re working on removing it. Pass',
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index e10bc19..09ca8aa 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -102,7 +102,8 @@ bool g_is_opening_new_window = false;
// not possible. If the last active browser is minimized (in particular, if
// there are only minimized windows), it will unminimize it.
Browser* ActivateBrowser(Profile* profile) {
- Browser* browser = chrome::FindLastActiveWithProfile(profile);
+ Browser* browser = chrome::FindLastActiveWithProfile(profile,
+ chrome::HOST_DESKTOP_TYPE_NATIVE);
if (browser)
browser->window()->Activate();
return browser;
diff --git a/chrome/browser/background/background_contents_service.cc b/chrome/browser/background/background_contents_service.cc
index 3263305..e2f9fda 100644
--- a/chrome/browser/background/background_contents_service.cc
+++ b/chrome/browser/background/background_contents_service.cc
@@ -24,6 +24,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_tabstrip.h"
+#include "chrome/browser/ui/host_desktop.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
@@ -615,7 +616,8 @@ void BackgroundContentsService::AddWebContents(
bool user_gesture,
bool* was_blocked) {
Browser* browser = chrome::FindLastActiveWithProfile(
- Profile::FromBrowserContext(new_contents->GetBrowserContext()));
+ Profile::FromBrowserContext(new_contents->GetBrowserContext()),
+ chrome::GetActiveDesktop());
if (browser) {
chrome::AddWebContents(browser, NULL, new_contents, disposition,
initial_pos, user_gesture, was_blocked);
diff --git a/chrome/browser/background/background_mode_manager.cc b/chrome/browser/background/background_mode_manager.cc
index d4df3fa..1dcb1bea 100644
--- a/chrome/browser/background/background_mode_manager.cc
+++ b/chrome/browser/background/background_mode_manager.cc
@@ -29,6 +29,7 @@
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/extensions/application_launch.h"
+#include "chrome/browser/ui/host_desktop.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
@@ -93,7 +94,8 @@ void BackgroundModeManager::BackgroundModeData::ExecuteCommand(int item) {
}
Browser* BackgroundModeManager::BackgroundModeData::GetBrowserWindow() {
- Browser* browser = chrome::FindLastActiveWithProfile(profile_);
+ Browser* browser = chrome::FindLastActiveWithProfile(profile_,
+ chrome::GetActiveDesktop());
return browser ? browser : chrome::OpenEmptyWindow(profile_);
}
diff --git a/chrome/browser/chromeos/drive/drive_file_system_util.cc b/chrome/browser/chromeos/drive/drive_file_system_util.cc
index 7115b6d..ba8ff6d 100644
--- a/chrome/browser/chromeos/drive/drive_file_system_util.cc
+++ b/chrome/browser/chromeos/drive/drive_file_system_util.cc
@@ -98,7 +98,8 @@ void GetHostedDocumentURLBlockingThread(const FilePath& drive_cache_path,
}
void OpenEditURLUIThread(Profile* profile, const GURL* edit_url) {
- Browser* browser = chrome::FindLastActiveWithProfile(profile);
+ Browser* browser = chrome::FindLastActiveWithProfile(profile,
+ chrome::HOST_DESKTOP_TYPE_ASH);
if (browser) {
browser->OpenURL(content::OpenURLParams(*edit_url, content::Referrer(),
CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
diff --git a/chrome/browser/chromeos/extensions/file_manager_util.cc b/chrome/browser/chromeos/extensions/file_manager_util.cc
index 9ea26b5..381966f 100644
--- a/chrome/browser/chromeos/extensions/file_manager_util.cc
+++ b/chrome/browser/chromeos/extensions/file_manager_util.cc
@@ -612,7 +612,8 @@ bool ExecuteDefaultHandler(Profile* profile, const FilePath& path) {
std::string extension_id = handler->extension_id();
std::string action_id = handler->id();
- Browser* browser = chrome::FindLastActiveWithProfile(profile);
+ Browser* browser = chrome::FindLastActiveWithProfile(profile,
+ chrome::HOST_DESKTOP_TYPE_ASH);
// If there is no browsers for the profile, bail out. Return true so warning
// about file type not being supported is not displayed.
diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrome/browser/download/chrome_download_manager_delegate.cc
index a142d12..8e1c8e1 100644
--- a/chrome/browser/download/chrome_download_manager_delegate.cc
+++ b/chrome/browser/download/chrome_download_manager_delegate.cc
@@ -36,6 +36,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/browser/ui/browser_tabstrip.h"
+#include "chrome/browser/ui/host_desktop.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/extensions/feature_switch.h"
#include "chrome/common/extensions/user_script.h"
@@ -265,7 +266,8 @@ WebContents* ChromeDownloadManagerDelegate::
#else
// Start the download in the last active browser. This is not ideal but better
// than fully hiding the download from the user.
- Browser* last_active = chrome::FindLastActiveWithProfile(profile_);
+ Browser* last_active = chrome::FindLastActiveWithProfile(profile_,
+ chrome::GetActiveDesktop());
return last_active ? chrome::GetActiveWebContents(last_active) : NULL;
#endif
}
diff --git a/chrome/browser/download/download_crx_util.cc b/chrome/browser/download/download_crx_util.cc
index cfe5352..c8a0828 100644
--- a/chrome/browser/download/download_crx_util.cc
+++ b/chrome/browser/download/download_crx_util.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/extensions/webstore_installer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/host_desktop.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_notification_types.h"
#include "content/public/browser/download_item.h"
@@ -44,9 +45,12 @@ ExtensionInstallPrompt* CreateExtensionInstallPrompt(
} else {
content::WebContents* web_contents = download_item.GetWebContents();
if (!web_contents) {
- Browser* browser = chrome::FindLastActiveWithProfile(profile);
+ chrome::HostDesktopType active_desktop = chrome::GetActiveDesktop();
+ Browser* browser = chrome::FindLastActiveWithProfile(profile,
+ active_desktop);
if (!browser)
- browser = new Browser(Browser::CreateParams(profile));
+ browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED,
+ profile, active_desktop));
web_contents = browser->tab_strip_model()->GetActiveWebContents();
}
return new ExtensionInstallPrompt(web_contents);
diff --git a/chrome/browser/extensions/bundle_installer.cc b/chrome/browser/extensions/bundle_installer.cc
index b9c3f5f..b068680 100644
--- a/chrome/browser/extensions/bundle_installer.cc
+++ b/chrome/browser/extensions/bundle_installer.cc
@@ -107,6 +107,7 @@ BundleInstaller::BundleInstaller(Browser* browser,
const BundleInstaller::ItemList& items)
: approved_(false),
browser_(browser),
+ host_desktop_type_(browser->host_desktop_type()),
profile_(browser->profile()),
delegate_(NULL) {
BrowserList::AddObserver(this);
@@ -272,7 +273,7 @@ void BundleInstaller::ShowPrompt() {
if (!browser) {
// The browser that we got initially could have gone away during our
// thread hopping.
- browser = chrome::FindLastActiveWithProfile(profile_);
+ browser = chrome::FindLastActiveWithProfile(profile_, host_desktop_type_);
}
content::WebContents* web_contents = NULL;
if (browser)
diff --git a/chrome/browser/extensions/bundle_installer.h b/chrome/browser/extensions/bundle_installer.h
index 7498710..dd549a4 100644
--- a/chrome/browser/extensions/bundle_installer.h
+++ b/chrome/browser/extensions/bundle_installer.h
@@ -15,6 +15,7 @@
#include "chrome/browser/extensions/webstore_installer.h"
#include "chrome/browser/extensions/webstore_install_helper.h"
#include "chrome/browser/ui/browser_list_observer.h"
+#include "chrome/browser/ui/host_desktop.h"
#include "chrome/common/extensions/extension.h"
namespace base {
@@ -186,6 +187,9 @@ class BundleInstaller : public WebstoreInstallHelper::Delegate,
// The browser to show the confirmation bubble for.
Browser* browser_;
+ // The desktop type of the browser.
+ chrome::HostDesktopType host_desktop_type_;
+
// The profile that the bundle should be installed in.
Profile* profile_;
diff --git a/chrome/browser/extensions/extension_error_ui_default.cc b/chrome/browser/extensions/extension_error_ui_default.cc
index 9ce25d0..905ebeb 100644
--- a/chrome/browser/extensions/extension_error_ui_default.cc
+++ b/chrome/browser/extensions/extension_error_ui_default.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/chrome_pages.h"
+#include "chrome/browser/ui/host_desktop.h"
ExtensionErrorUIDefault::ExtensionErrorUIDefault(
ExtensionService* extension_service)
@@ -23,7 +24,8 @@ ExtensionErrorUIDefault::~ExtensionErrorUIDefault() {
bool ExtensionErrorUIDefault::ShowErrorInBubbleView() {
Browser* browser =
- chrome::FindLastActiveWithProfile(extension_service()->profile());
+ chrome::FindLastActiveWithProfile(extension_service()->profile(),
+ chrome::GetActiveDesktop());
if (!browser)
return false;
diff --git a/chrome/browser/extensions/extension_install_ui_default.cc b/chrome/browser/extensions/extension_install_ui_default.cc
index 6929832..7378bdf 100644
--- a/chrome/browser/extensions/extension_install_ui_default.cc
+++ b/chrome/browser/extensions/extension_install_ui_default.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/host_desktop.h"
#include "chrome/browser/ui/simple_message_box.h"
#include "chrome/browser/ui/singleton_tabs.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
@@ -158,7 +159,8 @@ void ExtensionInstallUIDefault::OnInstallFailure(
if (disable_failure_ui_for_tests || skip_post_install_ui_)
return;
- Browser* browser = chrome::FindLastActiveWithProfile(profile_);
+ Browser* browser = chrome::FindLastActiveWithProfile(profile_,
+ chrome::GetActiveDesktop());
WebContents* web_contents = chrome::GetActiveWebContents(browser);
if (!web_contents)
return;
@@ -285,6 +287,7 @@ ExtensionInstallPrompt* ExtensionInstallUI::CreateInstallPromptWithBrowser(
// static
ExtensionInstallPrompt* ExtensionInstallUI::CreateInstallPromptWithProfile(
Profile* profile) {
- Browser* browser = chrome::FindLastActiveWithProfile(profile);
+ Browser* browser = chrome::FindLastActiveWithProfile(profile,
+ chrome::GetActiveDesktop());
return CreateInstallPromptWithBrowser(browser);
}
diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc
index 5f8d48c..c0ac128 100644
--- a/chrome/browser/notifications/balloon_host.cc
+++ b/chrome/browser/notifications/balloon_host.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_tabstrip.h"
+#include "chrome/browser/ui/host_desktop.h"
#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
#include "chrome/browser/view_type_utils.h"
#include "chrome/common/chrome_notification_types.h"
@@ -84,7 +85,8 @@ void BalloonHost::AddNewContents(WebContents* source,
bool user_gesture,
bool* was_blocked) {
Browser* browser = chrome::FindLastActiveWithProfile(
- Profile::FromBrowserContext(new_contents->GetBrowserContext()));
+ Profile::FromBrowserContext(new_contents->GetBrowserContext()),
+ chrome::GetActiveDesktop());
if (browser) {
chrome::AddWebContents(browser, NULL, new_contents, disposition,
initial_pos, user_gesture, was_blocked);
diff --git a/chrome/browser/notifications/notification_options_menu_model.cc b/chrome/browser/notifications/notification_options_menu_model.cc
index 691d112..ec840f4 100644
--- a/chrome/browser/notifications/notification_options_menu_model.cc
+++ b/chrome/browser/notifications/notification_options_menu_model.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/chrome_pages.h"
+#include "chrome/browser/ui/host_desktop.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/content_settings_types.h"
#include "chrome/common/extensions/extension.h"
@@ -250,7 +251,8 @@ void NotificationOptionsMenuModel::ExecuteCommand(int command_id) {
break;
}
case kOpenContentSettingsCommand: {
- Browser* browser = chrome::FindLastActiveWithProfile(balloon_->profile());
+ Browser* browser = chrome::FindLastActiveWithProfile(
+ balloon_->profile(), chrome::GetActiveDesktop());
if (!browser) {
// It is possible that there is no browser window (e.g. when there are
// background pages, or for a chrome frame process on windows).
diff --git a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc
index caa9967..7191321 100644
--- a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc
+++ b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/host_desktop.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/service_messages.h"
@@ -62,7 +63,8 @@ CloudPrintSetupFlow* CloudPrintSetupFlow::OpenDialog(
const base::WeakPtr<Delegate>& delegate,
gfx::NativeWindow parent_window) {
DCHECK(profile);
- Browser* browser = chrome::FindLastActiveWithProfile(profile);
+ Browser* browser = chrome::FindLastActiveWithProfile(profile,
+ chrome::GetActiveDesktop());
// Set the arguments for showing the gaia login page.
DictionaryValue args;
args.SetString("user", "");
diff --git a/chrome/browser/ui/browser_finder.cc b/chrome/browser/ui/browser_finder.cc
index 081d019..a881f2c 100644
--- a/chrome/browser/ui/browser_finder.cc
+++ b/chrome/browser/ui/browser_finder.cc
@@ -198,12 +198,12 @@ Browser* FindBrowserWithWebContents(const WebContents* web_contents) {
namespace chrome {
-Browser* FindLastActiveWithProfile(Profile* profile) {
+Browser* FindLastActiveWithProfile(Profile* profile, HostDesktopType type) {
+ BrowserListImpl* list = BrowserListImpl::GetInstance(type);
// We are only interested in last active browsers, so we don't fall back to
// all browsers like FindBrowserWith* do.
- return FindBrowserMatching(
- BrowserList::begin_last_active(), BrowserList::end_last_active(), profile,
- Browser::FEATURE_NONE, kMatchAny);
+ return FindBrowserMatching(list->begin_last_active(), list->end_last_active(),
+ profile, Browser::FEATURE_NONE, kMatchAny);
}
Browser* FindLastActiveWithHostDesktopType(HostDesktopType type) {
diff --git a/chrome/browser/ui/browser_finder.h b/chrome/browser/ui/browser_finder.h
index cca758f..2c55f05 100644
--- a/chrome/browser/ui/browser_finder.h
+++ b/chrome/browser/ui/browser_finder.h
@@ -68,16 +68,16 @@ Browser* FindBrowserWithWebContents(const content::WebContents* web_contents);
namespace chrome {
-// Returns the Browser object owned by |profile| whose window was most recently
-// active. If no such Browsers exist, returns NULL.
+// Returns the Browser object owned by |profile| on the given desktop type
+// whose window was most recently active. If no such Browsers exist, returns
+// NULL.
//
// WARNING: this is NULL until a browser becomes active. If during startup
// a browser does not become active (perhaps the user launches Chrome, then
// 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.
-// DEPRECATED: DO NOT USE.
-Browser* FindLastActiveWithProfile(Profile* profile);
+Browser* FindLastActiveWithProfile(Profile* profile, HostDesktopType type);
// Returns the Browser object on the given desktop type whose window was most
// recently active. If no such Browsers exist, returns NULL.