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

Unified Diff: chrome/browser/ui/browser_command_controller.cc

Issue 11308295: Revert 170483 - Remove PrefObserver usages, batch 12. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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/ui/browser_command_controller.h ('k') | chrome/browser/ui/cocoa/browser_window_cocoa.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser_command_controller.cc
===================================================================
--- chrome/browser/ui/browser_command_controller.cc (revision 170518)
+++ chrome/browser/ui/browser_command_controller.cc (working copy)
@@ -159,40 +159,16 @@
PrefService* local_state = g_browser_process->local_state();
if (local_state) {
local_pref_registrar_.Init(local_state);
- local_pref_registrar_.Add(
- prefs::kAllowFileSelectionDialogs,
- base::Bind(
- &BrowserCommandController::UpdateCommandsForFileSelectionDialogs,
- base::Unretained(this)));
- local_pref_registrar_.Add(
- prefs::kInManagedMode,
- base::Bind(
- &BrowserCommandController::UpdateCommandsForMultipleProfiles,
- base::Unretained(this)));
+ local_pref_registrar_.Add(prefs::kAllowFileSelectionDialogs, this);
+ local_pref_registrar_.Add(prefs::kInManagedMode, this);
}
profile_pref_registrar_.Init(profile()->GetPrefs());
- profile_pref_registrar_.Add(
- prefs::kDevToolsDisabled,
- base::Bind(&BrowserCommandController::UpdateCommandsForDevTools,
- base::Unretained(this)));
- profile_pref_registrar_.Add(
- prefs::kEditBookmarksEnabled,
- base::Bind(&BrowserCommandController::UpdateCommandsForBookmarkEditing,
- base::Unretained(this)));
- profile_pref_registrar_.Add(
- prefs::kShowBookmarkBar,
- base::Bind(&BrowserCommandController::UpdateCommandsForBookmarkBar,
- base::Unretained(this)));
- profile_pref_registrar_.Add(
- prefs::kIncognitoModeAvailability,
- base::Bind(
- &BrowserCommandController::UpdateCommandsForIncognitoAvailability,
- base::Unretained(this)));
- profile_pref_registrar_.Add(
- prefs::kPrintingEnabled,
- base::Bind(&BrowserCommandController::UpdatePrintingState,
- base::Unretained(this)));
+ profile_pref_registrar_.Add(prefs::kDevToolsDisabled, this);
+ profile_pref_registrar_.Add(prefs::kEditBookmarksEnabled, this);
+ profile_pref_registrar_.Add(prefs::kShowBookmarkBar, this);
+ profile_pref_registrar_.Add(prefs::kIncognitoModeAvailability, this);
+ profile_pref_registrar_.Add(prefs::kPrintingEnabled, this);
InitCommandState();
@@ -708,6 +684,32 @@
}
////////////////////////////////////////////////////////////////////////////////
+// PrefObserver implementation:
+
+void BrowserCommandController::OnPreferenceChanged(
+ PrefServiceBase* service,
+ const std::string& pref_name) {
+ if (pref_name == prefs::kPrintingEnabled) {
+ UpdatePrintingState();
+ } else if (pref_name == prefs::kIncognitoModeAvailability) {
+ UpdateCommandsForIncognitoAvailability();
+ } else if (pref_name == prefs::kDevToolsDisabled) {
+ UpdateCommandsForDevTools();
+ } else if (pref_name == prefs::kEditBookmarksEnabled) {
+ UpdateCommandsForBookmarkEditing();
+ } else if (pref_name == prefs::kShowBookmarkBar) {
+ UpdateCommandsForBookmarkBar();
+ } else if (pref_name == prefs::kAllowFileSelectionDialogs) {
+ UpdateSaveAsState();
+ UpdateOpenFileState();
+ } else if (pref_name == prefs::kInManagedMode) {
+ UpdateCommandsForMultipleProfiles();
+ } else {
+ NOTREACHED();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
// BrowserCommandController, TabStripModelObserver implementation:
void BrowserCommandController::TabInsertedAt(WebContents* contents,
@@ -1050,11 +1052,6 @@
show_main_ui);
}
-void BrowserCommandController::UpdateCommandsForFileSelectionDialogs() {
- UpdateSaveAsState();
- UpdateOpenFileState();
-}
-
void BrowserCommandController::UpdateCommandsForFullscreenMode(
FullScreenMode fullscreen_mode) {
const bool show_main_ui =
« no previous file with comments | « chrome/browser/ui/browser_command_controller.h ('k') | chrome/browser/ui/cocoa/browser_window_cocoa.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698