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() {
CHECK(registrar_.IsEmpty());
registrar_.Add(this,
chrome::NOTIFICATION_COOKIE_CHANGED,
NotificationService::AllSources());
NotificationService::AllBrowserContextsAndSources());
}
void ExtensionCookiesEventRouter::Observe(int type,
......
......@@ -277,9 +277,11 @@ Browser::Browser(Type type, Profile* profile)
Source<ThemeService>(ThemeServiceFactory::GetForProfile(profile_)));
registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED,
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,
chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
Source<Profile>(profile_));
NotificationService::AllBrowserContextsAndSources());
// Need to know when to alert the user of theme install delay.
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_READY_FOR_INSTALL,
......@@ -3737,8 +3739,8 @@ void Browser::Observe(int type,
break;
case chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED:
DCHECK_EQ(Source<Profile>(source).ptr(), profile_);
UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE);
if (profile_->IsSameProfile(Source<Profile>(source).ptr()))
UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE);
break;
default:
......
......@@ -52,12 +52,13 @@ BrowserWindowCocoa::BrowserWindowCocoa(Browser* browser,
: browser_(browser),
controller_(controller),
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,
chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
NotificationService::AllSources());
NotificationService::AllBrowserContextsAndSources());
registrar_.Add(this, chrome::NOTIFICATION_SIDEBAR_CHANGED,
NotificationService::AllSources());
Source<SidebarManager>(SidebarManager::GetInstance()));
}
BrowserWindowCocoa::~BrowserWindowCocoa() {
......@@ -608,7 +609,8 @@ void BrowserWindowCocoa::Observe(int type,
// Only the key window gets a direct toggle from the menu.
// Other windows hear about it from the notification.
case chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED:
[controller_ updateBookmarkBarVisibilityWithAnimation:YES];
if (browser_->profile()->IsSameProfile(Source<Profile>(source).ptr()))
[controller_ updateBookmarkBarVisibilityWithAnimation:YES];
break;
case chrome::NOTIFICATION_SIDEBAR_CHANGED:
UpdateSidebarForContents(
......
......@@ -213,13 +213,14 @@ GlobalMenuBar::GlobalMenuBar(Browser* browser)
browser_->command_updater()->AddCommandObserver(it->first, this);
}
// Listen for bookmark bar visibility changes and set the initial state.
Source<Profile> source(browser->profile());
// 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,
chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
source);
NotificationService::AllBrowserContextsAndSources());
Observe(chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
source, NotificationService::NoDetails());
Source<Profile>(browser->profile()),
NotificationService::NoDetails());
}
GlobalMenuBar::~GlobalMenuBar() {
......@@ -233,14 +234,14 @@ void GlobalMenuBar::Disable() {
browser_->command_updater()->RemoveCommandObserver(it->first, this);
}
id_to_menu_item_.clear();
Source<Profile> source(browser_->profile());
if (registrar_.IsRegistered(this,
chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
source)) {
NotificationService::AllBrowserContextsAndSources())) {
registrar_.Remove(
this,
chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
source);
NotificationService::AllBrowserContextsAndSources());
}
}
......@@ -321,7 +322,9 @@ void GlobalMenuBar::Observe(int type,
const NotificationSource& source,
const NotificationDetails& details) {
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 =
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