OLD | NEW |
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_factory.h" | 7 #include "chrome/browser/extensions/api/system_indicator/system_indicator_manage
r_factory.h" |
8 #include "chrome/browser/extensions/extension_action.h" | 8 #include "chrome/browser/extensions/extension_action.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 10 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 const size_t kNumIconSizes = extension_misc::kNumExtensionActionIconSizes; | 93 const size_t kNumIconSizes = extension_misc::kNumExtensionActionIconSizes; |
94 | 94 |
95 // If the title is missing from |action|, set it to |extension|'s name. | 95 // If the title is missing from |action|, set it to |extension|'s name. |
96 if (action->GetTitle(ExtensionAction::kDefaultTabId).empty()) | 96 if (action->GetTitle(ExtensionAction::kDefaultTabId).empty()) |
97 action->SetTitle(ExtensionAction::kDefaultTabId, extension.name()); | 97 action->SetTitle(ExtensionAction::kDefaultTabId, extension.name()); |
98 | 98 |
99 scoped_ptr<ExtensionIconSet> default_icon(new ExtensionIconSet()); | 99 scoped_ptr<ExtensionIconSet> default_icon(new ExtensionIconSet()); |
100 if (action->default_icon()) | 100 if (action->default_icon()) |
101 *default_icon = *action->default_icon(); | 101 *default_icon = *action->default_icon(); |
102 | 102 |
103 const ExtensionIconSet& extension_icons = | 103 const ExtensionIconSet& extension_icons = IconsInfo::GetIcons(&extension); |
104 extensions::IconsInfo::GetIcons(&extension); | |
105 std::string largest_icon = extension_icons.Get( | 104 std::string largest_icon = extension_icons.Get( |
106 extension_misc::EXTENSION_ICON_GIGANTOR, | 105 extension_misc::EXTENSION_ICON_GIGANTOR, |
107 ExtensionIconSet::MATCH_SMALLER); | 106 ExtensionIconSet::MATCH_SMALLER); |
108 | 107 |
109 if (!largest_icon.empty()) { | 108 if (!largest_icon.empty()) { |
110 int largest_icon_size = extension_icons.GetIconSizeFromPath(largest_icon); | 109 int largest_icon_size = extension_icons.GetIconSizeFromPath(largest_icon); |
111 // Replace any missing extension action icons with the largest icon | 110 // Replace any missing extension action icons with the largest icon |
112 // retrieved from |extension|'s manifest so long as the largest icon is | 111 // retrieved from |extension|'s manifest so long as the largest icon is |
113 // larger than the current key. | 112 // larger than the current key. |
114 for (int i = kNumIconSizes - 1; i >= 0; --i) { | 113 for (int i = kNumIconSizes - 1; i >= 0; --i) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 PopulateMissingValues(extension, new_action.get()); | 187 PopulateMissingValues(extension, new_action.get()); |
189 return new_action.Pass(); | 188 return new_action.Pass(); |
190 } | 189 } |
191 | 190 |
192 ExtensionAction* ExtensionActionManager::GetSystemIndicator( | 191 ExtensionAction* ExtensionActionManager::GetSystemIndicator( |
193 const Extension& extension) const { | 192 const Extension& extension) const { |
194 // If it does not already exist, create the SystemIndicatorManager for the | 193 // If it does not already exist, create the SystemIndicatorManager for the |
195 // given profile. This could return NULL if the system indicator area is | 194 // given profile. This could return NULL if the system indicator area is |
196 // unavailable on the current system. If so, return NULL to signal that | 195 // unavailable on the current system. If so, return NULL to signal that |
197 // the system indicator area is unusable. | 196 // the system indicator area is unusable. |
198 if (!extensions::SystemIndicatorManagerFactory::GetForProfile(profile_)) | 197 if (!SystemIndicatorManagerFactory::GetForProfile(profile_)) |
199 return NULL; | 198 return NULL; |
200 | 199 |
201 return GetOrCreateOrNull(&system_indicators_, extension, | 200 return GetOrCreateOrNull(&system_indicators_, extension, |
202 ActionInfo::TYPE_SYSTEM_INDICATOR, | 201 ActionInfo::TYPE_SYSTEM_INDICATOR, |
203 ActionInfo::GetSystemIndicatorInfo(&extension), | 202 ActionInfo::GetSystemIndicatorInfo(&extension), |
204 profile_); | 203 profile_); |
205 } | 204 } |
206 | 205 |
| 206 ExtensionAction* ExtensionActionManager::GetExtensionAction( |
| 207 const Extension& extension) const { |
| 208 ExtensionAction* action = GetBrowserAction(extension); |
| 209 return action ? action : GetPageAction(extension); |
| 210 } |
| 211 |
207 } // namespace extensions | 212 } // namespace extensions |
OLD | NEW |