diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-04 01:29:09 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-04 01:29:09 +0000 |
commit | 3b14b7f2ed2cb6d613dc900c22eaf20d9ee1cec4 (patch) | |
tree | 882491cfc91da9b58125812096cc5ac98fb291e6 /chrome/browser/protector | |
parent | 4bea86d44d7ada7ecc43695df42010c59e28b32a (diff) | |
download | chromium_src-3b14b7f2ed2cb6d613dc900c22eaf20d9ee1cec4.zip chromium_src-3b14b7f2ed2cb6d613dc900c22eaf20d9ee1cec4.tar.gz chromium_src-3b14b7f2ed2cb6d613dc900c22eaf20d9ee1cec4.tar.bz2 |
Add desktop type context to most existing instances of FindTabbedBrowser.
BUG=129187
TEST=NONE
Review URL: https://codereview.chromium.org/10967003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160039 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/protector')
-rw-r--r-- | chrome/browser/protector/protector_service.cc | 13 | ||||
-rw-r--r-- | chrome/browser/protector/settings_change_global_error.cc | 19 | ||||
-rw-r--r-- | chrome/browser/protector/settings_change_global_error.h | 13 |
3 files changed, 29 insertions, 16 deletions
diff --git a/chrome/browser/protector/protector_service.cc b/chrome/browser/protector/protector_service.cc index d57344e..2a44230 100644 --- a/chrome/browser/protector/protector_service.cc +++ b/chrome/browser/protector/protector_service.cc @@ -13,6 +13,7 @@ #include "chrome/browser/protector/protector_utils.h" #include "chrome/browser/protector/settings_change_global_error.h" #include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/host_desktop.h" #include "chrome/browser/ui/singleton_tabs.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/pref_names.h" @@ -84,7 +85,9 @@ void ProtectorService::ShowChange(BaseSettingChange* change) { new_item.change.reset(change_ptr.release()); items_.push_back(new_item); // Do not show the bubble immediately if another one is active. - error->AddToProfile(profile_, !has_active_change_); + // TODO(robertshield): Add desktop context to protector, crbug.com/153771 + error->AddToProfile(profile_, !has_active_change_, + chrome::HOST_DESKTOP_TYPE_NATIVE); has_active_change_ = true; } else { VLOG(1) << "Not showing a change because it's not user-visible."; @@ -176,7 +179,9 @@ void ProtectorService::OnRemovedFromProfile(SettingsChangeGlobalError* error) { // Item was merged with another change instance and error has been removed, // create a new one for the composite change. item->error.reset(new SettingsChangeGlobalError(item->change.get(), this)); - item->error->AddToProfile(profile_, show_new_error); + // TODO(robertshield): Add desktop context to protector, crbug.com/153771 + item->error->AddToProfile(profile_, show_new_error, + chrome::HOST_DESKTOP_TYPE_NATIVE); has_active_change_ = true; return; } @@ -188,7 +193,9 @@ void ProtectorService::OnRemovedFromProfile(SettingsChangeGlobalError* error) { if (!has_active_change_) { for (item = items_.begin(); item != items_.end(); ++item) { if (!item->error->HasShownBubbleView()) { - item->error->ShowBubble(); + // TODO(robertshield): Add desktop context to protector, + // crbug.com/153771 + item->error->ShowBubble(chrome::HOST_DESKTOP_TYPE_NATIVE); has_active_change_ = true; return; } diff --git a/chrome/browser/protector/settings_change_global_error.cc b/chrome/browser/protector/settings_change_global_error.cc index 68b6ae4..9ccf558 100644 --- a/chrome/browser/protector/settings_change_global_error.cc +++ b/chrome/browser/protector/settings_change_global_error.cc @@ -69,14 +69,16 @@ SettingsChangeGlobalError::~SettingsChangeGlobalError() { menu_ids.Get().reset(menu_id_ - IDC_SHOW_SETTINGS_CHANGE_FIRST); } -void SettingsChangeGlobalError::AddToProfile(Profile* profile, - bool show_bubble) { +void SettingsChangeGlobalError::AddToProfile( + Profile* profile, + bool show_bubble, + chrome::HostDesktopType desktop_type) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); profile_ = profile; GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError(this); BrowserList::AddObserver(this); if (show_bubble) { - ShowBubble(); + ShowBubble(desktop_type); } else { // Start inactivity timer. BrowserThread::PostDelayedTask( @@ -98,13 +100,11 @@ void SettingsChangeGlobalError::RemoveFromProfile() { delegate_->OnRemovedFromProfile(this); } -void SettingsChangeGlobalError::ShowBubble() { +void SettingsChangeGlobalError::ShowBubble( + chrome::HostDesktopType desktop_type) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(profile_); - Browser* browser = browser::FindTabbedBrowser( - profile_, - // match incognito - true); + Browser* browser = browser::FindTabbedBrowser(profile_, true, desktop_type); if (browser) ShowBubbleInBrowser(browser); } @@ -217,7 +217,8 @@ void SettingsChangeGlobalError::OnBrowserSetLastActive( BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind(&SettingsChangeGlobalError::ShowBubble, - weak_factory_.GetWeakPtr())); + weak_factory_.GetWeakPtr(), + browser->host_desktop_type())); } } diff --git a/chrome/browser/protector/settings_change_global_error.h b/chrome/browser/protector/settings_change_global_error.h index ebab480..7f537c1 100644 --- a/chrome/browser/protector/settings_change_global_error.h +++ b/chrome/browser/protector/settings_change_global_error.h @@ -12,6 +12,7 @@ #include "chrome/browser/protector/base_setting_change.h" #include "chrome/browser/ui/browser_list_observer.h" #include "chrome/browser/ui/global_error/global_error.h" +#include "chrome/browser/ui/host_desktop.h" class Browser; class Profile; @@ -33,14 +34,18 @@ class SettingsChangeGlobalError : public GlobalError, virtual ~SettingsChangeGlobalError(); // Adds a global error to the given browser profile and shows a bubble - // immediately if |show_bubble| is |true|. - void AddToProfile(Profile* profile, bool show_bubble); + // immediately on the desktop specified by |desktop_type| if |show_bubble| is + // |true|. + void AddToProfile(Profile* profile, + bool show_bubble, + chrome::HostDesktopType desktop_type); // Removes global error from its profile. void RemoveFromProfile(); - // Displays the bubble in the last active tabbed browser. - void ShowBubble(); + // Displays the bubble in the last active tabbed browser on the desktop + // specified by |desktop_type|. + void ShowBubble(chrome::HostDesktopType desktop_type); // Returns the change instance to which this error refers. BaseSettingChange* change() { return change_; } |