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 #import "chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h" | 5 #import "chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h" |
6 | 6 |
7 #include "base/prefs/public/pref_change_registrar.h" | 7 #include "base/prefs/public/pref_change_registrar.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "chrome/browser/extensions/extension_action.h" | 9 #include "chrome/browser/extensions/extension_action.h" |
10 #include "chrome/browser/extensions/extension_action_manager.h" | 10 #include "chrome/browser/extensions/extension_action_manager.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 @interface ExtensionActionContextMenu(Private) | 82 @interface ExtensionActionContextMenu(Private) |
83 // Callback for the context menu items. | 83 // Callback for the context menu items. |
84 - (void)dispatch:(id)menuItem; | 84 - (void)dispatch:(id)menuItem; |
85 | 85 |
86 // Runs the action for |menuItem|. | 86 // Runs the action for |menuItem|. |
87 - (void)updateInspectorItem; | 87 - (void)updateInspectorItem; |
88 @end | 88 @end |
89 | 89 |
90 namespace extension_action_context_menu { | 90 namespace extension_action_context_menu { |
91 | 91 |
92 class DevmodeObserver : public PrefObserver { | 92 class DevmodeObserver { |
93 public: | 93 public: |
94 DevmodeObserver(ExtensionActionContextMenu* menu, | 94 DevmodeObserver(ExtensionActionContextMenu* menu, |
95 PrefService* service) | 95 PrefService* service) |
96 : menu_(menu), pref_service_(service) { | 96 : menu_(menu), pref_service_(service) { |
97 registrar_.Init(pref_service_); | 97 registrar_.Init(pref_service_); |
98 registrar_.Add(prefs::kExtensionsUIDeveloperMode, this); | 98 registrar_.Add( |
| 99 prefs::kExtensionsUIDeveloperMode, |
| 100 base::Bind(&DevmodeObserver::OnExtensionsUIDeveloperModeChanged, |
| 101 base::Unretained(this))); |
99 } | 102 } |
100 virtual ~DevmodeObserver() {} | 103 virtual ~DevmodeObserver() {} |
101 | 104 |
102 void OnPreferenceChanged(PrefServiceBase* service, | 105 void OnExtensionsUIDeveloperModeChanged() { |
103 const std::string& pref_name) { | |
104 [menu_ updateInspectorItem]; | 106 [menu_ updateInspectorItem]; |
105 } | 107 } |
106 | 108 |
107 private: | 109 private: |
108 ExtensionActionContextMenu* menu_; | 110 ExtensionActionContextMenu* menu_; |
109 PrefService* pref_service_; | 111 PrefService* pref_service_; |
110 PrefChangeRegistrar registrar_; | 112 PrefChangeRegistrar registrar_; |
111 }; | 113 }; |
112 | 114 |
113 } // namespace extension_action_context_menu | 115 } // namespace extension_action_context_menu |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 281 |
280 - (BOOL)validateMenuItem:(NSMenuItem*)menuItem { | 282 - (BOOL)validateMenuItem:(NSMenuItem*)menuItem { |
281 if ([menuItem tag] == kExtensionContextOptions) { | 283 if ([menuItem tag] == kExtensionContextOptions) { |
282 // Disable 'Options' if there are no options to set. | 284 // Disable 'Options' if there are no options to set. |
283 return extension_->options_url().spec().length() > 0; | 285 return extension_->options_url().spec().length() > 0; |
284 } | 286 } |
285 return YES; | 287 return YES; |
286 } | 288 } |
287 | 289 |
288 @end | 290 @end |
OLD | NEW |