summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-05 05:55:57 +0000
committergab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-05 05:55:57 +0000
commit7f4a1d24175ce4435c93c68b94317b9fb2fcaa90 (patch)
treec08316124a56aae8104ed7e2f6912f698ea35bb4
parentec385b7c25d82d91b5206b405fa5375fc86114bb (diff)
downloadchromium_src-7f4a1d24175ce4435c93c68b94317b9fb2fcaa90.zip
chromium_src-7f4a1d24175ce4435c93c68b94317b9fb2fcaa90.tar.gz
chromium_src-7f4a1d24175ce4435c93c68b94317b9fb2fcaa90.tar.bz2
Add HostDesktopType parameter to browser::FindAnyBrowser().
BUG=129187 Review URL: https://chromiumcodereview.appspot.com/11416349 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171175 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--PRESUBMIT.py10
-rw-r--r--chrome/browser/extensions/api/tabs/tabs.cc2
-rw-r--r--chrome/browser/extensions/extension_function.cc8
-rw-r--r--chrome/browser/ui/browser_finder.cc6
-rw-r--r--chrome/browser/ui/browser_finder.h9
5 files changed, 17 insertions, 18 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 0bb6e3d..6ab4491 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -152,16 +152,6 @@ _BANNED_CPP_FUNCTIONS = (
(),
),
(
- 'browser::FindAnyBrowser',
- (
- '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::FindOrCreateTabbedBrowser',
(
'This function is deprecated and we\'re working on removing it. Pass',
diff --git a/chrome/browser/extensions/api/tabs/tabs.cc b/chrome/browser/extensions/api/tabs/tabs.cc
index 724f487..761abae 100644
--- a/chrome/browser/extensions/api/tabs/tabs.cc
+++ b/chrome/browser/extensions/api/tabs/tabs.cc
@@ -302,7 +302,7 @@ bool GetLastFocusedWindowFunction::RunImpl() {
// include other window types (e.g. panels), we will need to add logic to
// WindowControllerList that mirrors the active behavior of BrowserList.
Browser* browser = browser::FindAnyBrowser(
- profile(), include_incognito());
+ profile(), include_incognito(), chrome::GetActiveDesktop());
if (!browser || !browser->window()) {
error_ = keys::kNoLastFocusedWindowError;
return false;
diff --git a/chrome/browser/extensions/extension_function.cc b/chrome/browser/extensions/extension_function.cc
index e0e4c5d..5af06a0 100644
--- a/chrome/browser/extensions/extension_function.cc
+++ b/chrome/browser/extensions/extension_function.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_host/chrome_render_message_filter.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/extensions/extension_messages.h"
#include "content/public/browser/notification_source.h"
@@ -207,11 +208,14 @@ Browser* UIThreadExtensionFunction::GetCurrentBrowser() {
// is true, we will also search browsers in the incognito version of this
// profile. Note that the profile may already be incognito, in which case
// we will search the incognito version only, regardless of the value of
- // |include_incognito|.
+ // |include_incognito|. Look only for browsers on the active desktop as it is
+ // preferable to pretend no browser is open then to return a browser on
+ // another desktop.
if (render_view_host_) {
Profile* profile = Profile::FromBrowserContext(
render_view_host_->GetProcess()->GetBrowserContext());
- Browser* browser = browser::FindAnyBrowser(profile, include_incognito_);
+ Browser* browser = browser::FindAnyBrowser(profile, include_incognito_,
+ chrome::GetActiveDesktop());
if (browser)
return browser;
}
diff --git a/chrome/browser/ui/browser_finder.cc b/chrome/browser/ui/browser_finder.cc
index f14202e..5d8d713 100644
--- a/chrome/browser/ui/browser_finder.cc
+++ b/chrome/browser/ui/browser_finder.cc
@@ -148,9 +148,11 @@ Browser* FindOrCreateTabbedBrowser(Profile* profile,
return browser;
}
-Browser* FindAnyBrowser(Profile* profile, bool match_original_profiles) {
+Browser* FindAnyBrowser(Profile* profile,
+ bool match_original_profiles,
+ chrome::HostDesktopType type) {
return FindBrowserWithTabbedOrAnyType(profile,
- kDefaultHostDesktopType,
+ type,
false,
match_original_profiles);
}
diff --git a/chrome/browser/ui/browser_finder.h b/chrome/browser/ui/browser_finder.h
index 25f2020..7dd12e5 100644
--- a/chrome/browser/ui/browser_finder.h
+++ b/chrome/browser/ui/browser_finder.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_UI_BROWSER_FINDER_H_
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/host_desktop.h"
#include "ui/gfx/native_widget_types.h"
class Profile;
@@ -38,9 +39,11 @@ Browser* FindOrCreateTabbedBrowser(Profile* profile);
Browser* FindOrCreateTabbedBrowser(Profile* profile,
chrome::HostDesktopType type);
-// Find an existing browser window with any type. See comment above for
-// additional information.
-Browser* FindAnyBrowser(Profile* profile, bool match_original_profiles);
+// Finds an existing browser window of any kind.
+// |type| refers to the host desktop the returned browser should belong to.
+Browser* FindAnyBrowser(Profile* profile,
+ bool match_original_profiles,
+ chrome::HostDesktopType type);
// Find an existing browser window with the provided profile and hosted in the
// given desktop. Searches in the order of last activation. Only browsers that