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

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, 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) 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"
16 #include "chrome/common/extensions/api/extension_action/script_badge_handler.h" 17 #include "chrome/common/extensions/api/extension_action/script_badge_handler.h"
17 #include "chrome/common/extensions/extension.h" 18 #include "chrome/common/extensions/extension.h"
18 #include "chrome/common/extensions/feature_switch.h" 19 #include "chrome/common/extensions/feature_switch.h"
19 #include "content/public/browser/notification_service.h" 20 #include "content/public/browser/notification_service.h"
20 #include "content/public/browser/notification_source.h" 21 #include "content/public/browser/notification_source.h"
21 22
22 namespace extensions { 23 namespace extensions {
23 24
24 namespace { 25 namespace {
25 26
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } // namespace 119 } // namespace
119 120
120 ExtensionAction* ExtensionActionManager::GetPageAction( 121 ExtensionAction* ExtensionActionManager::GetPageAction(
121 const extensions::Extension& extension) const { 122 const extensions::Extension& extension) const {
122 // 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
123 // need to convert page actions into browser actions. 124 // need to convert page actions into browser actions.
124 if (FeatureSwitch::script_badges()->IsEnabled()) 125 if (FeatureSwitch::script_badges()->IsEnabled())
125 return NULL; 126 return NULL;
126 return GetOrCreateOrNull(&page_actions_, extension.id(), 127 return GetOrCreateOrNull(&page_actions_, extension.id(),
127 ActionInfo::TYPE_PAGE, 128 ActionInfo::TYPE_PAGE,
128 extension.page_action_info()); 129 ActionInfo::GetPageActionInfo(&extension));
129 } 130 }
130 131
131 ExtensionAction* ExtensionActionManager::GetBrowserAction( 132 ExtensionAction* ExtensionActionManager::GetBrowserAction(
132 const extensions::Extension& extension) const { 133 const extensions::Extension& extension) const {
133 const ActionInfo* action_info = extension.browser_action_info(); 134 const ActionInfo* action_info = extension.browser_action_info();
134 ActionInfo::Type action_type = ActionInfo::TYPE_BROWSER; 135 ActionInfo::Type action_type = ActionInfo::TYPE_BROWSER;
135 if (FeatureSwitch::script_badges()->IsEnabled() && 136 if (FeatureSwitch::script_badges()->IsEnabled() &&
136 extension.page_action_info()) { 137 ActionInfo::GetPageActionInfo(&extension)) {
137 // 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
138 // need to convert page actions into browser actions. 139 // need to convert page actions into browser actions.
139 action_info = extension.page_action_info(); 140 action_info = ActionInfo::GetPageActionInfo(&extension);
140 action_type = ActionInfo::TYPE_PAGE; 141 action_type = ActionInfo::TYPE_PAGE;
141 } 142 }
142 return GetOrCreateOrNull(&browser_actions_, extension.id(), 143 return GetOrCreateOrNull(&browser_actions_, extension.id(),
143 action_type, action_info); 144 action_type, action_info);
144 } 145 }
145 146
146 ExtensionAction* ExtensionActionManager::GetSystemIndicator( 147 ExtensionAction* ExtensionActionManager::GetSystemIndicator(
147 const extensions::Extension& extension) const { 148 const extensions::Extension& extension) const {
148 // If it does not already exist, create the SystemIndicatorManager for the 149 // If it does not already exist, create the SystemIndicatorManager for the
149 // 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
150 // 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
151 // the system indicator area is unusable. 152 // the system indicator area is unusable.
152 if (!extensions::SystemIndicatorManagerFactory::GetForProfile(profile_)) 153 if (!extensions::SystemIndicatorManagerFactory::GetForProfile(profile_))
153 return NULL; 154 return NULL;
154 155
155 return GetOrCreateOrNull(&system_indicators_, extension.id(), 156 return GetOrCreateOrNull(&system_indicators_, extension.id(),
156 ActionInfo::TYPE_SYSTEM_INDICATOR, 157 ActionInfo::TYPE_SYSTEM_INDICATOR,
157 extension.system_indicator_info()); 158 extension.system_indicator_info());
158 } 159 }
159 160
160 ExtensionAction* ExtensionActionManager::GetScriptBadge( 161 ExtensionAction* ExtensionActionManager::GetScriptBadge(
161 const extensions::Extension& extension) const { 162 const extensions::Extension& extension) const {
162 return GetOrCreateOrNull(&script_badges_, extension.id(), 163 return GetOrCreateOrNull(&script_badges_, extension.id(),
163 ActionInfo::TYPE_SCRIPT_BADGE, 164 ActionInfo::TYPE_SCRIPT_BADGE,
164 ActionInfo::GetScriptBadgeInfo(&extension)); 165 ActionInfo::GetScriptBadgeInfo(&extension));
165 } 166 }
166 167
167 } // namespace extensions 168 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698