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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/extension_action_context_menu.mm

Issue 5915004: Introduce incognito preference settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed whitespaces in mac files Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/sys_string_conversions.h" 7 #include "base/sys_string_conversions.h"
8 #include "base/task.h" 8 #include "base/task.h"
9 #include "chrome/browser/browser_list.h" 9 #include "chrome/browser/browser_list.h"
10 #include "chrome/browser/extensions/extension_install_ui.h" 10 #include "chrome/browser/extensions/extension_install_ui.h"
11 #include "chrome/browser/extensions/extension_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/extension_tabs_module.h" 12 #include "chrome/browser/extensions/extension_tabs_module.h"
13 #include "chrome/browser/prefs/pref_change_registrar.h" 13 #include "chrome/browser/prefs/pref_change_registrar.h"
14 #include "chrome/browser/prefs/pref_service.h" 14 #include "chrome/browser/prefs/pref_service.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" 16 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h"
17 #include "chrome/browser/ui/cocoa/browser_window_controller.h" 17 #include "chrome/browser/ui/cocoa/browser_window_controller.h"
18 #include "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" 18 #include "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h"
19 #include "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" 19 #include "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h"
20 #include "chrome/browser/ui/cocoa/info_bubble_view.h" 20 #include "chrome/browser/ui/cocoa/info_bubble_view.h"
21 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" 21 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
22 #include "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 22 #include "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
23 #include "chrome/common/extensions/extension.h" 23 #include "chrome/common/extensions/extension.h"
24 #include "chrome/common/extensions/extension_action.h" 24 #include "chrome/common/extensions/extension_action.h"
25 #include "chrome/common/extensions/extension_constants.h" 25 #include "chrome/common/extensions/extension_constants.h"
26 #include "chrome/common/notification_details.h" 26 #include "chrome/common/notification_details.h"
27 #include "chrome/common/notification_observer.h" 27 #include "chrome/common/notification_observer.h"
28 #include "chrome/common/notification_source.h"
28 #include "chrome/common/notification_type.h" 29 #include "chrome/common/notification_type.h"
29 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
30 #include "chrome/common/url_constants.h" 31 #include "chrome/common/url_constants.h"
31 #include "grit/generated_resources.h" 32 #include "grit/generated_resources.h"
32 #include "ui/base/l10n/l10n_util_mac.h" 33 #include "ui/base/l10n/l10n_util_mac.h"
33 34
34 // A class that loads the extension icon on the I/O thread before showing the 35 // A class that loads the extension icon on the I/O thread before showing the
35 // confirmation dialog to uninstall the given extension. 36 // confirmation dialog to uninstall the given extension.
36 // Also acts as the extension's UI delegate in order to display the dialog. 37 // Also acts as the extension's UI delegate in order to display the dialog.
37 class AsyncUninstaller : public ExtensionInstallUI::Delegate { 38 class AsyncUninstaller : public ExtensionInstallUI::Delegate {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 else 86 else
86 NOTREACHED(); 87 NOTREACHED();
87 } 88 }
88 89
89 private: 90 private:
90 ExtensionActionContextMenu* menu_; 91 ExtensionActionContextMenu* menu_;
91 PrefService* pref_service_; 92 PrefService* pref_service_;
92 PrefChangeRegistrar registrar_; 93 PrefChangeRegistrar registrar_;
93 }; 94 };
94 95
96 class ProfileObserverBridge : public NotificationObserver {
97 public:
98 ProfileObserverBridge(ExtensionActionContextMenu* owner,
99 const Profile* profile)
100 : owner_(owner),
101 profile_(profile) {
102 registrar_.Add(this, NotificationType::PROFILE_DESTROYED,
103 Source<Profile>(profile));
104 }
105
106 ~ProfileObserverBridge() {}
107
108 // Overridden from NotificationObserver
109 void Observe(NotificationType type,
110 const NotificationSource& source,
111 const NotificationDetails& details) {
112 if (type == NotificationType::PROFILE_DESTROYED &&
113 source == Source<Profile>(profile_)) {
114 [owner_ invalidateProfile];
115 }
116 }
117
118 private:
119 ExtensionActionContextMenu* owner_;
120 const Profile* profile_;
121 NotificationRegistrar registrar_;
122 };
123
95 } // namespace extension_action_context_menu 124 } // namespace extension_action_context_menu
96 125
97 @interface ExtensionActionContextMenu(Private) 126 @interface ExtensionActionContextMenu(Private)
98 // Callback for the context menu items. 127 // Callback for the context menu items.
99 - (void)dispatch:(id)menuItem; 128 - (void)dispatch:(id)menuItem;
100 @end 129 @end
101 130
102 @implementation ExtensionActionContextMenu 131 @implementation ExtensionActionContextMenu
103 132
104 namespace { 133 namespace {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 l10n_util::GetNSStringWithFixup(IDS_EXTENSION_ACTION_INSPECT_POPUP); 199 l10n_util::GetNSStringWithFixup(IDS_EXTENSION_ACTION_INSPECT_POPUP);
171 inspectorItem_.reset([[NSMenuItem alloc] initWithTitle:inspectorTitle 200 inspectorItem_.reset([[NSMenuItem alloc] initWithTitle:inspectorTitle
172 action:@selector(dispatch:) 201 action:@selector(dispatch:)
173 keyEquivalent:@""]); 202 keyEquivalent:@""]);
174 [inspectorItem_.get() setTarget:self]; 203 [inspectorItem_.get() setTarget:self];
175 [inspectorItem_.get() setTag:kExtensionContextInspect]; 204 [inspectorItem_.get() setTag:kExtensionContextInspect];
176 205
177 PrefService* service = profile_->GetPrefs(); 206 PrefService* service = profile_->GetPrefs();
178 observer_.reset( 207 observer_.reset(
179 new extension_action_context_menu::DevmodeObserver(self, service)); 208 new extension_action_context_menu::DevmodeObserver(self, service));
209 profile_observer_.reset(
210 new extension_action_context_menu::ProfileObserverBridge(self,
211 profile));
180 212
181 [self updateInspectorItem]; 213 [self updateInspectorItem];
182 return self; 214 return self;
183 } 215 }
184 return nil; 216 return nil;
185 } 217 }
186 218
187 - (void)updateInspectorItem { 219 - (void)updateInspectorItem {
188 PrefService* service = profile_->GetPrefs(); 220 PrefService* service = profile_->GetPrefs();
189 bool devmode = service->GetBoolean(prefs::kExtensionsUIDeveloperMode); 221 bool devmode = service->GetBoolean(prefs::kExtensionsUIDeveloperMode);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 300 }
269 } 301 }
270 302
271 - (BOOL)validateMenuItem:(NSMenuItem*)menuItem { 303 - (BOOL)validateMenuItem:(NSMenuItem*)menuItem {
272 if([menuItem isEqualTo:inspectorItem_.get()]) { 304 if([menuItem isEqualTo:inspectorItem_.get()]) {
273 return action_ && action_->HasPopup(CurrentTabId()); 305 return action_ && action_->HasPopup(CurrentTabId());
274 } 306 }
275 return YES; 307 return YES;
276 } 308 }
277 309
310 - (void)invalidateProfile {
311 observer_.reset();
312 profile_ = NULL;
313 }
314
278 @end 315 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698