| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/extension_tabs_module.h" | 10 #include "chrome/browser/extensions/extension_tabs_module.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 PrefService* service) | 73 PrefService* service) |
| 74 : menu_(menu), pref_service_(service) { | 74 : menu_(menu), pref_service_(service) { |
| 75 registrar_.Init(pref_service_); | 75 registrar_.Init(pref_service_); |
| 76 registrar_.Add(prefs::kExtensionsUIDeveloperMode, this); | 76 registrar_.Add(prefs::kExtensionsUIDeveloperMode, this); |
| 77 } | 77 } |
| 78 virtual ~DevmodeObserver() {} | 78 virtual ~DevmodeObserver() {} |
| 79 | 79 |
| 80 void Observe(NotificationType type, | 80 void Observe(NotificationType type, |
| 81 const NotificationSource& source, | 81 const NotificationSource& source, |
| 82 const NotificationDetails& details) { | 82 const NotificationDetails& details) { |
| 83 if (type == NotificationType::PREF_CHANGED) | 83 if (type == chrome::PREF_CHANGED) |
| 84 [menu_ updateInspectorItem]; | 84 [menu_ updateInspectorItem]; |
| 85 else | 85 else |
| 86 NOTREACHED(); | 86 NOTREACHED(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 private: | 89 private: |
| 90 ExtensionActionContextMenu* menu_; | 90 ExtensionActionContextMenu* menu_; |
| 91 PrefService* pref_service_; | 91 PrefService* pref_service_; |
| 92 PrefChangeRegistrar registrar_; | 92 PrefChangeRegistrar registrar_; |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 class ProfileObserverBridge : public NotificationObserver { | 95 class ProfileObserverBridge : public NotificationObserver { |
| 96 public: | 96 public: |
| 97 ProfileObserverBridge(ExtensionActionContextMenu* owner, | 97 ProfileObserverBridge(ExtensionActionContextMenu* owner, |
| 98 const Profile* profile) | 98 const Profile* profile) |
| 99 : owner_(owner), | 99 : owner_(owner), |
| 100 profile_(profile) { | 100 profile_(profile) { |
| 101 registrar_.Add(this, NotificationType::PROFILE_DESTROYED, | 101 registrar_.Add(this, chrome::PROFILE_DESTROYED, |
| 102 Source<Profile>(profile)); | 102 Source<Profile>(profile)); |
| 103 } | 103 } |
| 104 | 104 |
| 105 ~ProfileObserverBridge() {} | 105 ~ProfileObserverBridge() {} |
| 106 | 106 |
| 107 // Overridden from NotificationObserver | 107 // Overridden from NotificationObserver |
| 108 void Observe(NotificationType type, | 108 void Observe(NotificationType type, |
| 109 const NotificationSource& source, | 109 const NotificationSource& source, |
| 110 const NotificationDetails& details) { | 110 const NotificationDetails& details) { |
| 111 if (type == NotificationType::PROFILE_DESTROYED && | 111 if (type == chrome::PROFILE_DESTROYED && |
| 112 source == Source<Profile>(profile_)) { | 112 source == Source<Profile>(profile_)) { |
| 113 [owner_ invalidateProfile]; | 113 [owner_ invalidateProfile]; |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 private: | 117 private: |
| 118 ExtensionActionContextMenu* owner_; | 118 ExtensionActionContextMenu* owner_; |
| 119 const Profile* profile_; | 119 const Profile* profile_; |
| 120 NotificationRegistrar registrar_; | 120 NotificationRegistrar registrar_; |
| 121 }; | 121 }; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 } | 316 } |
| 317 return YES; | 317 return YES; |
| 318 } | 318 } |
| 319 | 319 |
| 320 - (void)invalidateProfile { | 320 - (void)invalidateProfile { |
| 321 observer_.reset(); | 321 observer_.reset(); |
| 322 profile_ = NULL; | 322 profile_ = NULL; |
| 323 } | 323 } |
| 324 | 324 |
| 325 @end | 325 @end |
| OLD | NEW |