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

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

Issue 12042096: Move page action manifest parsing out of Extension; the first multi-key manifest handler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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/extensions/api/system_indicator/system_indicator_manage r.h" 7 #include "chrome/browser/extensions/api/system_indicator/system_indicator_manage r.h"
8 #include "chrome/browser/extensions/api/system_indicator/system_indicator_manage r_factory.h" 8 #include "chrome/browser/extensions/api/system_indicator/system_indicator_manage r_factory.h"
9 #include "chrome/browser/extensions/extension_action.h" 9 #include "chrome/browser/extensions/extension_action.h"
10 #include "chrome/browser/extensions/extension_system.h" 10 #include "chrome/browser/extensions/extension_system.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/profiles/profile_dependency_manager.h" 12 #include "chrome/browser/profiles/profile_dependency_manager.h"
13 #include "chrome/browser/profiles/profile_keyed_service_factory.h" 13 #include "chrome/browser/profiles/profile_keyed_service_factory.h"
14 #include "chrome/common/chrome_notification_types.h" 14 #include "chrome/common/chrome_notification_types.h"
15 #include "chrome/common/extensions/api/extension_action/action_info.h" 15 #include "chrome/common/extensions/api/extension_action/action_info.h"
16 #include "chrome/common/extensions/api/extension_action/page_action_handler.h"
17 #include "chrome/common/extensions/api/extension_action/script_badge_handler.h"
16 #include "chrome/common/extensions/extension.h" 18 #include "chrome/common/extensions/extension.h"
17 #include "chrome/common/extensions/feature_switch.h" 19 #include "chrome/common/extensions/feature_switch.h"
18 #include "content/public/browser/notification_service.h" 20 #include "content/public/browser/notification_service.h"
19 #include "content/public/browser/notification_source.h" 21 #include "content/public/browser/notification_source.h"
20 22
21 namespace extensions { 23 namespace extensions {
22 24
23 namespace { 25 namespace {
24 26
25 // ProfileKeyedServiceFactory for ExtensionActionManager. 27 // ProfileKeyedServiceFactory for ExtensionActionManager.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 } // namespace 119 } // namespace
118 120
119 ExtensionAction* ExtensionActionManager::GetPageAction( 121 ExtensionAction* ExtensionActionManager::GetPageAction(
120 const extensions::Extension& extension) const { 122 const extensions::Extension& extension) const {
121 // The action box changes the meaning of the page action area, so we 123 // The action box changes the meaning of the page action area, so we
122 // need to convert page actions into browser actions. 124 // need to convert page actions into browser actions.
123 if (FeatureSwitch::script_badges()->IsEnabled()) 125 if (FeatureSwitch::script_badges()->IsEnabled())
124 return NULL; 126 return NULL;
125 return GetOrCreateOrNull(&page_actions_, extension.id(), 127 return GetOrCreateOrNull(&page_actions_, extension.id(),
126 ActionInfo::TYPE_PAGE, 128 ActionInfo::TYPE_PAGE,
127 extension.page_action_info()); 129 ActionInfo::GetPageActionInfo(&extension));
128 } 130 }
129 131
130 ExtensionAction* ExtensionActionManager::GetBrowserAction( 132 ExtensionAction* ExtensionActionManager::GetBrowserAction(
131 const extensions::Extension& extension) const { 133 const extensions::Extension& extension) const {
132 const ActionInfo* action_info = ActionInfo::GetBrowserActionInfo(&extension); 134 const ActionInfo* action_info = ActionInfo::GetBrowserActionInfo(&extension);
133 ActionInfo::Type action_type = ActionInfo::TYPE_BROWSER; 135 ActionInfo::Type action_type = ActionInfo::TYPE_BROWSER;
134 if (FeatureSwitch::script_badges()->IsEnabled() && 136 if (FeatureSwitch::script_badges()->IsEnabled() &&
135 extension.page_action_info()) { 137 ActionInfo::GetPageActionInfo(&extension)) {
136 // The action box changes the meaning of the page action area, so we 138 // The action box changes the meaning of the page action area, so we
137 // need to convert page actions into browser actions. 139 // need to convert page actions into browser actions.
138 action_info = extension.page_action_info(); 140 action_info = ActionInfo::GetPageActionInfo(&extension);
139 action_type = ActionInfo::TYPE_PAGE; 141 action_type = ActionInfo::TYPE_PAGE;
140 } 142 }
141 return GetOrCreateOrNull(&browser_actions_, extension.id(), 143 return GetOrCreateOrNull(&browser_actions_, extension.id(),
142 action_type, action_info); 144 action_type, action_info);
143 } 145 }
144 146
145 ExtensionAction* ExtensionActionManager::GetSystemIndicator( 147 ExtensionAction* ExtensionActionManager::GetSystemIndicator(
146 const extensions::Extension& extension) const { 148 const extensions::Extension& extension) const {
147 // If it does not already exist, create the SystemIndicatorManager for the 149 // If it does not already exist, create the SystemIndicatorManager for the
148 // given profile. This could return NULL if the system indicator area is 150 // given profile. This could return NULL if the system indicator area is
149 // unavailable on the current system. If so, return NULL to signal that 151 // unavailable on the current system. If so, return NULL to signal that
150 // the system indicator area is unusable. 152 // the system indicator area is unusable.
151 if (!extensions::SystemIndicatorManagerFactory::GetForProfile(profile_)) 153 if (!extensions::SystemIndicatorManagerFactory::GetForProfile(profile_))
152 return NULL; 154 return NULL;
153 155
154 return GetOrCreateOrNull(&system_indicators_, extension.id(), 156 return GetOrCreateOrNull(&system_indicators_, extension.id(),
155 ActionInfo::TYPE_SYSTEM_INDICATOR, 157 ActionInfo::TYPE_SYSTEM_INDICATOR,
156 extension.system_indicator_info()); 158 extension.system_indicator_info());
157 } 159 }
158 160
159 ExtensionAction* ExtensionActionManager::GetScriptBadge( 161 ExtensionAction* ExtensionActionManager::GetScriptBadge(
160 const extensions::Extension& extension) const { 162 const extensions::Extension& extension) const {
161 return GetOrCreateOrNull(&script_badges_, extension.id(), 163 return GetOrCreateOrNull(&script_badges_, extension.id(),
162 ActionInfo::TYPE_SCRIPT_BADGE, 164 ActionInfo::TYPE_SCRIPT_BADGE,
163 ActionInfo::GetScriptBadgeInfo(&extension)); 165 ActionInfo::GetScriptBadgeInfo(&extension));
164 } 166 }
165 167
166 } // namespace extensions 168 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698