Commit 0b4e2232 authored by erg@google.com's avatar erg@google.com

Profiles: Three small changes

- Change how BOOKMARK_BAR_VISIBILITY_PREF_CHANGED is handled because it broke interaction w/ incognito windows.
- Make SIDEBAR_CHANGED listen only to a certain SidebarManager instance.
- Mark COOKIE_CHANGED as ok to listen to AllSources().

BUG=87457, 92506
TEST=none

Review URL: http://codereview.chromium.org/7610003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96440 0039d316-1c4b-4281-b951-d872f2087c98
parent 71421bc2
...@@ -35,7 +35,7 @@ void ExtensionCookiesEventRouter::Init() { ...@@ -35,7 +35,7 @@ void ExtensionCookiesEventRouter::Init() {
CHECK(registrar_.IsEmpty()); CHECK(registrar_.IsEmpty());
registrar_.Add(this, registrar_.Add(this,
chrome::NOTIFICATION_COOKIE_CHANGED, chrome::NOTIFICATION_COOKIE_CHANGED,
NotificationService::AllSources()); NotificationService::AllBrowserContextsAndSources());
} }
void ExtensionCookiesEventRouter::Observe(int type, void ExtensionCookiesEventRouter::Observe(int type,
......
...@@ -277,9 +277,11 @@ Browser::Browser(Type type, Profile* profile) ...@@ -277,9 +277,11 @@ Browser::Browser(Type type, Profile* profile)
Source<ThemeService>(ThemeServiceFactory::GetForProfile(profile_))); Source<ThemeService>(ThemeServiceFactory::GetForProfile(profile_)));
registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED, registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED,
NotificationService::AllSources()); NotificationService::AllSources());
// We listen to all notification sources because the bookmark bar
// state needs to stay in sync between the incognito and normal profiles.
registrar_.Add(this, registrar_.Add(this,
chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
Source<Profile>(profile_)); NotificationService::AllBrowserContextsAndSources());
// Need to know when to alert the user of theme install delay. // Need to know when to alert the user of theme install delay.
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_READY_FOR_INSTALL, registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_READY_FOR_INSTALL,
...@@ -3737,8 +3739,8 @@ void Browser::Observe(int type, ...@@ -3737,8 +3739,8 @@ void Browser::Observe(int type,
break; break;
case chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: case chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED:
DCHECK_EQ(Source<Profile>(source).ptr(), profile_); if (profile_->IsSameProfile(Source<Profile>(source).ptr()))
UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE); UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE);
break; break;
default: default:
......
...@@ -52,12 +52,13 @@ BrowserWindowCocoa::BrowserWindowCocoa(Browser* browser, ...@@ -52,12 +52,13 @@ BrowserWindowCocoa::BrowserWindowCocoa(Browser* browser,
: browser_(browser), : browser_(browser),
controller_(controller), controller_(controller),
confirm_close_factory_(browser) { confirm_close_factory_(browser) {
// This pref applies to all windows, so all must watch for it. // Listen for bookmark bar visibility changes and set the initial state; we
// need to listen to all profiles because of normal profile/incognito issues.
registrar_.Add(this, registrar_.Add(this,
chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
NotificationService::AllSources()); NotificationService::AllBrowserContextsAndSources());
registrar_.Add(this, chrome::NOTIFICATION_SIDEBAR_CHANGED, registrar_.Add(this, chrome::NOTIFICATION_SIDEBAR_CHANGED,
NotificationService::AllSources()); Source<SidebarManager>(SidebarManager::GetInstance()));
} }
BrowserWindowCocoa::~BrowserWindowCocoa() { BrowserWindowCocoa::~BrowserWindowCocoa() {
...@@ -608,7 +609,8 @@ void BrowserWindowCocoa::Observe(int type, ...@@ -608,7 +609,8 @@ void BrowserWindowCocoa::Observe(int type,
// Only the key window gets a direct toggle from the menu. // Only the key window gets a direct toggle from the menu.
// Other windows hear about it from the notification. // Other windows hear about it from the notification.
case chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: case chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED:
[controller_ updateBookmarkBarVisibilityWithAnimation:YES]; if (browser_->profile()->IsSameProfile(Source<Profile>(source).ptr()))
[controller_ updateBookmarkBarVisibilityWithAnimation:YES];
break; break;
case chrome::NOTIFICATION_SIDEBAR_CHANGED: case chrome::NOTIFICATION_SIDEBAR_CHANGED:
UpdateSidebarForContents( UpdateSidebarForContents(
......
...@@ -213,13 +213,14 @@ GlobalMenuBar::GlobalMenuBar(Browser* browser) ...@@ -213,13 +213,14 @@ GlobalMenuBar::GlobalMenuBar(Browser* browser)
browser_->command_updater()->AddCommandObserver(it->first, this); browser_->command_updater()->AddCommandObserver(it->first, this);
} }
// Listen for bookmark bar visibility changes and set the initial state. // We listen to all notification sources because the bookmark bar
Source<Profile> source(browser->profile()); // state needs to stay in sync between the incognito and normal profiles.
registrar_.Add(this, registrar_.Add(this,
chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
source); NotificationService::AllBrowserContextsAndSources());
Observe(chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, Observe(chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
source, NotificationService::NoDetails()); Source<Profile>(browser->profile()),
NotificationService::NoDetails());
} }
GlobalMenuBar::~GlobalMenuBar() { GlobalMenuBar::~GlobalMenuBar() {
...@@ -233,14 +234,14 @@ void GlobalMenuBar::Disable() { ...@@ -233,14 +234,14 @@ void GlobalMenuBar::Disable() {
browser_->command_updater()->RemoveCommandObserver(it->first, this); browser_->command_updater()->RemoveCommandObserver(it->first, this);
} }
id_to_menu_item_.clear(); id_to_menu_item_.clear();
Source<Profile> source(browser_->profile());
if (registrar_.IsRegistered(this, if (registrar_.IsRegistered(this,
chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
source)) { NotificationService::AllBrowserContextsAndSources())) {
registrar_.Remove( registrar_.Remove(
this, this,
chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
source); NotificationService::AllBrowserContextsAndSources());
} }
} }
...@@ -321,7 +322,9 @@ void GlobalMenuBar::Observe(int type, ...@@ -321,7 +322,9 @@ void GlobalMenuBar::Observe(int type,
const NotificationSource& source, const NotificationSource& source,
const NotificationDetails& details) { const NotificationDetails& details) {
DCHECK_EQ(type, chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED); DCHECK_EQ(type, chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED);
DCHECK_EQ(Source<Profile>(source).ptr(), browser_->profile());
if (!browser_->profile()->IsSameProfile(Source<Profile>(source).ptr()))
return;
CommandIDMenuItemMap::iterator it = CommandIDMenuItemMap::iterator it =
id_to_menu_item_.find(IDC_SHOW_BOOKMARK_BAR); id_to_menu_item_.find(IDC_SHOW_BOOKMARK_BAR);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment