Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Unified Diff: chrome/browser/browser.cc

Issue 2905003: Implement support for disabling sync through configuration management. (Closed)
Patch Set: Fix PrefsControllerTest on MAC. Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/browser.h ('k') | chrome/browser/cocoa/browser_window_controller.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser.cc
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 832516c6298e395b06c13689051d341865b09ea1..07b16c1a74db4e19e125ed7c81a961ec522ee4d5 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -236,6 +236,9 @@ Browser::Browser(Type type, Profile* profile)
tab_restore_service_->AddObserver(this);
TabRestoreServiceChanged(tab_restore_service_);
}
+
+ if (profile_->GetProfileSyncService())
+ profile_->GetProfileSyncService()->AddObserver(this);
}
Browser::~Browser() {
@@ -243,6 +246,9 @@ Browser::~Browser() {
DCHECK(!tabstrip_model_.HasNonPhantomTabs());
tabstrip_model_.RemoveObserver(this);
+ if (profile_->GetProfileSyncService())
+ profile_->GetProfileSyncService()->RemoveObserver(this);
+
BrowserList::RemoveBrowser(this);
#if defined(OS_WIN) || defined(OS_LINUX)
@@ -1059,8 +1065,8 @@ void Browser::UpdateCommandsForFullscreenMode(bool is_fullscreen) {
command_updater_.UpdateCommandEnabled(IDC_REPORT_BUG, show_main_ui);
command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_BAR, show_main_ui);
command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, show_main_ui);
- command_updater_.UpdateCommandEnabled(
- IDC_SYNC_BOOKMARKS, show_main_ui && ProfileSyncService::IsSyncEnabled());
+ command_updater_.UpdateCommandEnabled(IDC_SYNC_BOOKMARKS,
+ show_main_ui && profile_->IsSyncAccessible());
command_updater_.UpdateCommandEnabled(IDC_OPTIONS, show_main_ui);
command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui);
command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui);
@@ -3031,6 +3037,21 @@ void Browser::Observe(NotificationType type,
}
}
+///////////////////////////////////////////////////////////////////////////////
+// Browser, ProfileSyncServiceObserver implementation:
+
+void Browser::OnStateChanged() {
+ DCHECK(profile_->GetProfileSyncService());
+
+#if !defined(OS_MACOSX)
+ const bool show_main_ui = (type() == TYPE_NORMAL) && !window_->IsFullscreen();
+#else
+ const bool show_main_ui = (type() == TYPE_NORMAL);
+#endif
+
+ command_updater_.UpdateCommandEnabled(IDC_SYNC_BOOKMARKS,
+ show_main_ui && profile_->IsSyncAccessible());
+}
///////////////////////////////////////////////////////////////////////////////
// Browser, Command and state updating (private):
« no previous file with comments | « chrome/browser/browser.h ('k') | chrome/browser/cocoa/browser_window_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698