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

Side by Side Diff: chrome/browser/extensions/extension_action_manager.cc

Issue 204703002: Rename NOTIFICATION_EXTENSION_UNLOADED to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: maybe upload wont do something bizarre this time Created 6 years, 9 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) 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/extensions/extension_action_manager.h" 5 #include "chrome/browser/extensions/extension_action_manager.h"
6 6
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/extensions/api/system_indicator/system_indicator_manage r.h" 8 #include "chrome/browser/extensions/api/system_indicator/system_indicator_manage r.h"
9 #include "chrome/browser/extensions/api/system_indicator/system_indicator_manage r_factory.h" 9 #include "chrome/browser/extensions/api/system_indicator/system_indicator_manage r_factory.h"
10 #include "chrome/browser/extensions/extension_action.h" 10 #include "chrome/browser/extensions/extension_action.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 ExtensionActionManagerFactory::GetInstance() { 60 ExtensionActionManagerFactory::GetInstance() {
61 return Singleton<ExtensionActionManagerFactory>::get(); 61 return Singleton<ExtensionActionManagerFactory>::get();
62 } 62 }
63 63
64 } // namespace 64 } // namespace
65 65
66 ExtensionActionManager::ExtensionActionManager(Profile* profile) 66 ExtensionActionManager::ExtensionActionManager(Profile* profile)
67 : profile_(profile) { 67 : profile_(profile) {
68 CHECK_EQ(profile, profile->GetOriginalProfile()) 68 CHECK_EQ(profile, profile->GetOriginalProfile())
69 << "Don't instantiate this with an incognito profile."; 69 << "Don't instantiate this with an incognito profile.";
70 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 70 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
71 content::Source<Profile>(profile)); 71 content::Source<Profile>(profile));
72 } 72 }
73 73
74 ExtensionActionManager::~ExtensionActionManager() { 74 ExtensionActionManager::~ExtensionActionManager() {
75 // Don't assert that the ExtensionAction maps are empty because Extensions are 75 // Don't assert that the ExtensionAction maps are empty because Extensions are
76 // sometimes (only in tests?) not unloaded before the Profile is destroyed. 76 // sometimes (only in tests?) not unloaded before the Profile is destroyed.
77 } 77 }
78 78
79 ExtensionActionManager* ExtensionActionManager::Get(Profile* profile) { 79 ExtensionActionManager* ExtensionActionManager::Get(Profile* profile) {
80 return ExtensionActionManagerFactory::GetForProfile(profile); 80 return ExtensionActionManagerFactory::GetForProfile(profile);
81 } 81 }
82 82
83 void ExtensionActionManager::Observe( 83 void ExtensionActionManager::Observe(
84 int type, 84 int type,
85 const content::NotificationSource& source, 85 const content::NotificationSource& source,
86 const content::NotificationDetails& details) { 86 const content::NotificationDetails& details) {
87 switch (type) { 87 switch (type) {
88 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { 88 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: {
89 const Extension* extension = 89 const Extension* extension =
90 content::Details<UnloadedExtensionInfo>(details)->extension; 90 content::Details<UnloadedExtensionInfo>(details)->extension;
91 page_actions_.erase(extension->id()); 91 page_actions_.erase(extension->id());
92 browser_actions_.erase(extension->id()); 92 browser_actions_.erase(extension->id());
93 system_indicators_.erase(extension->id()); 93 system_indicators_.erase(extension->id());
94 break; 94 break;
95 } 95 }
96 } 96 }
97 } 97 }
98 98
(...skipping 10 matching lines...) Expand all
109 Profile* profile) { 109 Profile* profile) {
110 std::map<std::string, linked_ptr<ExtensionAction> >::const_iterator it = 110 std::map<std::string, linked_ptr<ExtensionAction> >::const_iterator it =
111 map->find(extension_id); 111 map->find(extension_id);
112 if (it != map->end()) 112 if (it != map->end())
113 return it->second.get(); 113 return it->second.get();
114 if (!action_info) 114 if (!action_info)
115 return NULL; 115 return NULL;
116 116
117 // Only create action info for enabled extensions. 117 // Only create action info for enabled extensions.
118 // This avoids bugs where actions are recreated just after being removed 118 // This avoids bugs where actions are recreated just after being removed
119 // in response to NOTIFICATION_EXTENSION_UNLOADED in 119 // in response to NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED in
120 // ExtensionActionManager::Observe() 120 // ExtensionActionManager::Observe()
121 ExtensionService* service = 121 ExtensionService* service =
122 ExtensionSystem::Get(profile)->extension_service(); 122 ExtensionSystem::Get(profile)->extension_service();
123 if (!service->GetExtensionById(extension_id, false)) 123 if (!service->GetExtensionById(extension_id, false))
124 return NULL; 124 return NULL;
125 125
126 linked_ptr<ExtensionAction> action(new ExtensionAction( 126 linked_ptr<ExtensionAction> action(new ExtensionAction(
127 extension_id, action_type, *action_info)); 127 extension_id, action_type, *action_info));
128 (*map)[extension_id] = action; 128 (*map)[extension_id] = action;
129 return action.get(); 129 return action.get();
(...skipping 26 matching lines...) Expand all
156 if (!extensions::SystemIndicatorManagerFactory::GetForProfile(profile_)) 156 if (!extensions::SystemIndicatorManagerFactory::GetForProfile(profile_))
157 return NULL; 157 return NULL;
158 158
159 return GetOrCreateOrNull(&system_indicators_, extension.id(), 159 return GetOrCreateOrNull(&system_indicators_, extension.id(),
160 ActionInfo::TYPE_SYSTEM_INDICATOR, 160 ActionInfo::TYPE_SYSTEM_INDICATOR,
161 ActionInfo::GetSystemIndicatorInfo(&extension), 161 ActionInfo::GetSystemIndicatorInfo(&extension),
162 profile_); 162 profile_);
163 } 163 }
164 164
165 } // namespace extensions 165 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc ('k') | chrome/browser/extensions/extension_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698