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

Side by Side Diff: chrome/browser/ui/browser_command_controller.cc

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head for commit 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/browser_command_controller.h" 5 #include "chrome/browser/ui/browser_command_controller.h"
6 6
7 #include "chrome/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/defaults.h" 9 #include "chrome/browser/defaults.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 } 657 }
658 658
659 //////////////////////////////////////////////////////////////////////////////// 659 ////////////////////////////////////////////////////////////////////////////////
660 // BrowserCommandController, content::NotificationObserver implementation: 660 // BrowserCommandController, content::NotificationObserver implementation:
661 661
662 void BrowserCommandController::Observe( 662 void BrowserCommandController::Observe(
663 int type, 663 int type,
664 const content::NotificationSource& source, 664 const content::NotificationSource& source,
665 const content::NotificationDetails& details) { 665 const content::NotificationDetails& details) {
666 switch (type) { 666 switch (type) {
667 case NOTIFICATION_PREF_CHANGED: {
668 const std::string& pref_name =
669 *content::Details<std::string>(details).ptr();
670 if (pref_name == prefs::kPrintingEnabled) {
671 UpdatePrintingState();
672 } else if (pref_name == prefs::kIncognitoModeAvailability) {
673 UpdateCommandsForIncognitoAvailability();
674 } else if (pref_name == prefs::kDevToolsDisabled) {
675 UpdateCommandsForDevTools();
676 } else if (pref_name == prefs::kEditBookmarksEnabled) {
677 UpdateCommandsForBookmarkEditing();
678 } else if (pref_name == prefs::kShowBookmarkBar) {
679 UpdateCommandsForBookmarkBar();
680 } else if (pref_name == prefs::kAllowFileSelectionDialogs) {
681 UpdateSaveAsState();
682 UpdateOpenFileState();
683 } else if (pref_name == prefs::kInManagedMode) {
684 UpdateCommandsForMultipleProfiles();
685 } else {
686 NOTREACHED();
687 }
688 break;
689 }
690 case content::NOTIFICATION_INTERSTITIAL_ATTACHED: 667 case content::NOTIFICATION_INTERSTITIAL_ATTACHED:
691 UpdateCommandsForTabState(); 668 UpdateCommandsForTabState();
692 break; 669 break;
693 670
694 case content::NOTIFICATION_INTERSTITIAL_DETACHED: 671 case content::NOTIFICATION_INTERSTITIAL_DETACHED:
695 UpdateCommandsForTabState(); 672 UpdateCommandsForTabState();
696 break; 673 break;
697 674
698 default: 675 default:
699 NOTREACHED() << "Got a notification we didn't register for."; 676 NOTREACHED() << "Got a notification we didn't register for.";
700 } 677 }
701 } 678 }
702 679
703 //////////////////////////////////////////////////////////////////////////////// 680 ////////////////////////////////////////////////////////////////////////////////
681 // PrefObserver implementation:
682
683 void BrowserCommandController::OnPreferenceChanged(
684 PrefServiceBase* service,
685 const std::string& pref_name) {
686 if (pref_name == prefs::kPrintingEnabled) {
687 UpdatePrintingState();
688 } else if (pref_name == prefs::kIncognitoModeAvailability) {
689 UpdateCommandsForIncognitoAvailability();
690 } else if (pref_name == prefs::kDevToolsDisabled) {
691 UpdateCommandsForDevTools();
692 } else if (pref_name == prefs::kEditBookmarksEnabled) {
693 UpdateCommandsForBookmarkEditing();
694 } else if (pref_name == prefs::kShowBookmarkBar) {
695 UpdateCommandsForBookmarkBar();
696 } else if (pref_name == prefs::kAllowFileSelectionDialogs) {
697 UpdateSaveAsState();
698 UpdateOpenFileState();
699 } else if (pref_name == prefs::kInManagedMode) {
700 UpdateCommandsForMultipleProfiles();
701 } else {
702 NOTREACHED();
703 }
704 }
705
706 ////////////////////////////////////////////////////////////////////////////////
704 // BrowserCommandController, TabStripModelObserver implementation: 707 // BrowserCommandController, TabStripModelObserver implementation:
705 708
706 void BrowserCommandController::TabInsertedAt(TabContents* contents, 709 void BrowserCommandController::TabInsertedAt(TabContents* contents,
707 int index, 710 int index,
708 bool foreground) { 711 bool foreground) {
709 AddInterstitialObservers(contents); 712 AddInterstitialObservers(contents);
710 } 713 }
711 714
712 void BrowserCommandController::TabDetachedAt(TabContents* contents, int index) { 715 void BrowserCommandController::TabDetachedAt(TabContents* contents, int index) {
713 RemoveInterstitialObservers(contents); 716 RemoveInterstitialObservers(contents);
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 1171
1169 BrowserWindow* BrowserCommandController::window() { 1172 BrowserWindow* BrowserCommandController::window() {
1170 return browser_->window(); 1173 return browser_->window();
1171 } 1174 }
1172 1175
1173 Profile* BrowserCommandController::profile() { 1176 Profile* BrowserCommandController::profile() {
1174 return browser_->profile(); 1177 return browser_->profile();
1175 } 1178 }
1176 1179
1177 } // namespace chrome 1180 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_command_controller.h ('k') | chrome/browser/ui/browser_instant_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698