| OLD | NEW |
| 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 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 } | 662 } |
| 663 | 663 |
| 664 //////////////////////////////////////////////////////////////////////////////// | 664 //////////////////////////////////////////////////////////////////////////////// |
| 665 // BrowserCommandController, content::NotificationObserver implementation: | 665 // BrowserCommandController, content::NotificationObserver implementation: |
| 666 | 666 |
| 667 void BrowserCommandController::Observe( | 667 void BrowserCommandController::Observe( |
| 668 int type, | 668 int type, |
| 669 const content::NotificationSource& source, | 669 const content::NotificationSource& source, |
| 670 const content::NotificationDetails& details) { | 670 const content::NotificationDetails& details) { |
| 671 switch (type) { | 671 switch (type) { |
| 672 case NOTIFICATION_PREF_CHANGED: { | |
| 673 const std::string& pref_name = | |
| 674 *content::Details<std::string>(details).ptr(); | |
| 675 if (pref_name == prefs::kPrintingEnabled) { | |
| 676 UpdatePrintingState(); | |
| 677 } else if (pref_name == prefs::kIncognitoModeAvailability) { | |
| 678 UpdateCommandsForIncognitoAvailability(); | |
| 679 } else if (pref_name == prefs::kDevToolsDisabled) { | |
| 680 UpdateCommandsForDevTools(); | |
| 681 } else if (pref_name == prefs::kEditBookmarksEnabled) { | |
| 682 UpdateCommandsForBookmarkEditing(); | |
| 683 } else if (pref_name == prefs::kShowBookmarkBar) { | |
| 684 UpdateCommandsForBookmarkBar(); | |
| 685 } else if (pref_name == prefs::kAllowFileSelectionDialogs) { | |
| 686 UpdateSaveAsState(); | |
| 687 UpdateOpenFileState(); | |
| 688 } else if (pref_name == prefs::kInManagedMode) { | |
| 689 UpdateCommandsForMultipleProfiles(); | |
| 690 } else { | |
| 691 NOTREACHED(); | |
| 692 } | |
| 693 break; | |
| 694 } | |
| 695 case content::NOTIFICATION_INTERSTITIAL_ATTACHED: | 672 case content::NOTIFICATION_INTERSTITIAL_ATTACHED: |
| 696 UpdateCommandsForTabState(); | 673 UpdateCommandsForTabState(); |
| 697 break; | 674 break; |
| 698 | 675 |
| 699 case content::NOTIFICATION_INTERSTITIAL_DETACHED: | 676 case content::NOTIFICATION_INTERSTITIAL_DETACHED: |
| 700 UpdateCommandsForTabState(); | 677 UpdateCommandsForTabState(); |
| 701 break; | 678 break; |
| 702 | 679 |
| 703 default: | 680 default: |
| 704 NOTREACHED() << "Got a notification we didn't register for."; | 681 NOTREACHED() << "Got a notification we didn't register for."; |
| 705 } | 682 } |
| 706 } | 683 } |
| 707 | 684 |
| 708 //////////////////////////////////////////////////////////////////////////////// | 685 //////////////////////////////////////////////////////////////////////////////// |
| 686 // PrefObserver implementation: |
| 687 |
| 688 void BrowserCommandController::OnPreferenceChanged( |
| 689 PrefServiceBase* service, |
| 690 const std::string& pref_name) { |
| 691 if (pref_name == prefs::kPrintingEnabled) { |
| 692 UpdatePrintingState(); |
| 693 } else if (pref_name == prefs::kIncognitoModeAvailability) { |
| 694 UpdateCommandsForIncognitoAvailability(); |
| 695 } else if (pref_name == prefs::kDevToolsDisabled) { |
| 696 UpdateCommandsForDevTools(); |
| 697 } else if (pref_name == prefs::kEditBookmarksEnabled) { |
| 698 UpdateCommandsForBookmarkEditing(); |
| 699 } else if (pref_name == prefs::kShowBookmarkBar) { |
| 700 UpdateCommandsForBookmarkBar(); |
| 701 } else if (pref_name == prefs::kAllowFileSelectionDialogs) { |
| 702 UpdateSaveAsState(); |
| 703 UpdateOpenFileState(); |
| 704 } else if (pref_name == prefs::kInManagedMode) { |
| 705 UpdateCommandsForMultipleProfiles(); |
| 706 } else { |
| 707 NOTREACHED(); |
| 708 } |
| 709 } |
| 710 |
| 711 //////////////////////////////////////////////////////////////////////////////// |
| 709 // BrowserCommandController, TabStripModelObserver implementation: | 712 // BrowserCommandController, TabStripModelObserver implementation: |
| 710 | 713 |
| 711 void BrowserCommandController::TabInsertedAt(TabContents* contents, | 714 void BrowserCommandController::TabInsertedAt(TabContents* contents, |
| 712 int index, | 715 int index, |
| 713 bool foreground) { | 716 bool foreground) { |
| 714 AddInterstitialObservers(contents); | 717 AddInterstitialObservers(contents); |
| 715 } | 718 } |
| 716 | 719 |
| 717 void BrowserCommandController::TabDetachedAt(TabContents* contents, int index) { | 720 void BrowserCommandController::TabDetachedAt(TabContents* contents, int index) { |
| 718 RemoveInterstitialObservers(contents); | 721 RemoveInterstitialObservers(contents); |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1173 | 1176 |
| 1174 BrowserWindow* BrowserCommandController::window() { | 1177 BrowserWindow* BrowserCommandController::window() { |
| 1175 return browser_->window(); | 1178 return browser_->window(); |
| 1176 } | 1179 } |
| 1177 | 1180 |
| 1178 Profile* BrowserCommandController::profile() { | 1181 Profile* BrowserCommandController::profile() { |
| 1179 return browser_->profile(); | 1182 return browser_->profile(); |
| 1180 } | 1183 } |
| 1181 | 1184 |
| 1182 } // namespace chrome | 1185 } // namespace chrome |
| OLD | NEW |