diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-31 03:58:56 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-31 03:58:56 +0000 |
commit | aec0c94c6d5a0cc97254c38d57b97f3d7292ea7e (patch) | |
tree | 006a54b0c0381307efb294048fde339d2273455b /chrome/browser/browser_list.cc | |
parent | bfa69d49b17f33635c79f79819b90a8d2089c4b3 (diff) | |
download | chromium_src-aec0c94c6d5a0cc97254c38d57b97f3d7292ea7e.zip chromium_src-aec0c94c6d5a0cc97254c38d57b97f3d7292ea7e.tar.gz chromium_src-aec0c94c6d5a0cc97254c38d57b97f3d7292ea7e.tar.bz2 |
roll back 30659 since it still breaks browser_tests
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30661 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_list.cc')
-rw-r--r-- | chrome/browser/browser_list.cc | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/chrome/browser/browser_list.cc b/chrome/browser/browser_list.cc index c5ef49c..aba80b7 100644 --- a/chrome/browser/browser_list.cc +++ b/chrome/browser/browser_list.cc @@ -79,16 +79,6 @@ class BrowserActivityObserver : public NotificationObserver { BrowserActivityObserver* activity_observer = NULL; -// Returns true if the specified |browser| has a matching profile and type to -// those specified. If |any_type| is true, only |profile| must be matched. -bool BrowserMatchesProfileAndType(Browser* browser, - Profile* profile, - Browser::Type type, - bool any_type) { - return (any_type || browser->type() == type) && - browser->profile() == profile; -} - } // namespace BrowserList::list_type BrowserList::browsers_; @@ -252,10 +242,8 @@ void BrowserList::WindowsSessionEnding() { bool BrowserList::HasBrowserWithProfile(Profile* profile) { BrowserList::const_iterator iter; for (size_t i = 0; i < browsers_.size(); ++i) { - if (BrowserMatchesProfileAndType(browsers_[i], profile, - Browser::TYPE_NORMAL, true)) { + if (browsers_[i]->profile() == profile) return true; - } } return false; } @@ -284,28 +272,44 @@ Browser* BrowserList::GetLastActive() { Browser* BrowserList::GetLastActiveWithProfile(Profile* p) { list_type::reverse_iterator browser = last_active_browsers_.rbegin(); for (; browser != last_active_browsers_.rend(); ++browser) { - if (BrowserMatchesProfileAndType(*browser, p, Browser::TYPE_NORMAL, true)) + if ((*browser)->profile() == p) { return *browser; + } } + return NULL; } // static Browser* BrowserList::FindBrowserWithType(Profile* p, Browser::Type t) { - list_type::reverse_iterator browser = last_active_browsers_.rbegin(); - for (; browser != last_active_browsers_.rend(); ++browser) { - if (BrowserMatchesProfileAndType(*browser, p, t, false)) - return *browser; + Browser* last_active = GetLastActive(); + if (last_active && last_active->profile() == p && last_active->type() == t) + return last_active; + + BrowserList::const_iterator i; + for (i = BrowserList::begin(); i != BrowserList::end(); ++i) { + if (*i == last_active) + continue; + + if ((*i)->profile() == p && (*i)->type() == t) + return *i; } return NULL; } // static Browser* BrowserList::FindBrowserWithProfile(Profile* p) { - list_type::reverse_iterator browser = last_active_browsers_.rbegin(); - for (; browser != last_active_browsers_.rend(); ++browser) { - if (BrowserMatchesProfileAndType(*browser, p, Browser::TYPE_NORMAL, true)) - return *browser; + Browser* last_active = GetLastActive(); + if (last_active && last_active->profile() == p) + return last_active; + + BrowserList::const_iterator i; + for (i = BrowserList::begin(); i != BrowserList::end(); ++i) { + if (*i == last_active) + continue; + + if ((*i)->profile() == p) + return *i; } return NULL; } @@ -325,8 +329,8 @@ size_t BrowserList::GetBrowserCountForType(Profile* p, Browser::Type type) { BrowserList::const_iterator i; size_t result = 0; for (i = BrowserList::begin(); i != BrowserList::end(); ++i) { - if (BrowserMatchesProfileAndType(*i, p, type, false)) - ++result; + if ((*i)->profile() == p && (*i)->type() == type) + result++; } return result; } @@ -336,7 +340,7 @@ size_t BrowserList::GetBrowserCount(Profile* p) { BrowserList::const_iterator i; size_t result = 0; for (i = BrowserList::begin(); i != BrowserList::end(); ++i) { - if (BrowserMatchesProfileAndType(*i, p, Browser::TYPE_NORMAL, true)) + if ((*i)->profile() == p) result++; } return result; |