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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/extensions/extension_action_context_menu.mm
diff --git a/chrome/browser/ui/cocoa/extensions/extension_action_context_menu.mm b/chrome/browser/ui/cocoa/extensions/extension_action_context_menu.mm
index 705276e95e3ebbaef453021d1216b7741b3b9905..b8475eac9cdb0ae944cfdb219df236101fc5a896 100644
--- a/chrome/browser/ui/cocoa/extensions/extension_action_context_menu.mm
+++ b/chrome/browser/ui/cocoa/extensions/extension_action_context_menu.mm
@@ -25,6 +25,7 @@
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/notification_details.h"
#include "chrome/common/notification_observer.h"
+#include "chrome/common/notification_source.h"
#include "chrome/common/notification_type.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
@@ -92,6 +93,34 @@ class DevmodeObserver : public NotificationObserver {
PrefChangeRegistrar registrar_;
};
+class ProfileObserverBridge : public NotificationObserver {
+ public:
+ ProfileObserverBridge(ExtensionActionContextMenu* owner,
+ const Profile* profile)
+ : owner_(owner),
+ profile_(profile) {
+ registrar_.Add(this, NotificationType::PROFILE_DESTROYED,
+ Source<Profile>(profile));
+ }
+
+ ~ProfileObserverBridge() {}
+
+ // Overridden from NotificationObserver
+ void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ if (type == NotificationType::PROFILE_DESTROYED &&
+ source == Source<Profile>(profile_)) {
+ [owner_ invalidateProfile];
+ }
+ }
+
+ private:
+ ExtensionActionContextMenu* owner_;
+ const Profile* profile_;
+ NotificationRegistrar registrar_;
+};
+
} // namespace extension_action_context_menu
@interface ExtensionActionContextMenu(Private)
@@ -177,6 +206,9 @@ int CurrentTabId() {
PrefService* service = profile_->GetPrefs();
observer_.reset(
new extension_action_context_menu::DevmodeObserver(self, service));
+ profile_observer_.reset(
+ new extension_action_context_menu::ProfileObserverBridge(self,
+ profile));
[self updateInspectorItem];
return self;
@@ -275,4 +307,9 @@ int CurrentTabId() {
return YES;
}
+- (void)invalidateProfile {
+ observer_.reset();
+ profile_ = NULL;
+}
+
@end

Powered by Google App Engine
This is Rietveld 408576698