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

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

Issue 489183005: Make a ShowExtensionActionPopup function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Peter's Created 6 years, 3 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
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_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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 void PopulateMissingValues(const Extension& extension, 90 void PopulateMissingValues(const Extension& extension,
91 ExtensionAction* action) { 91 ExtensionAction* action) {
92 // If the title is missing from |action|, set it to |extension|'s name. 92 // If the title is missing from |action|, set it to |extension|'s name.
93 if (action->GetTitle(ExtensionAction::kDefaultTabId).empty()) 93 if (action->GetTitle(ExtensionAction::kDefaultTabId).empty())
94 action->SetTitle(ExtensionAction::kDefaultTabId, extension.name()); 94 action->SetTitle(ExtensionAction::kDefaultTabId, extension.name());
95 95
96 scoped_ptr<ExtensionIconSet> default_icon(new ExtensionIconSet()); 96 scoped_ptr<ExtensionIconSet> default_icon(new ExtensionIconSet());
97 if (action->default_icon()) 97 if (action->default_icon())
98 *default_icon = *action->default_icon(); 98 *default_icon = *action->default_icon();
99 99
100 const ExtensionIconSet& extension_icons = 100 const ExtensionIconSet& extension_icons = IconsInfo::GetIcons(&extension);
101 extensions::IconsInfo::GetIcons(&extension);
102 std::string largest_icon = extension_icons.Get( 101 std::string largest_icon = extension_icons.Get(
103 extension_misc::EXTENSION_ICON_GIGANTOR, 102 extension_misc::EXTENSION_ICON_GIGANTOR,
104 ExtensionIconSet::MATCH_SMALLER); 103 ExtensionIconSet::MATCH_SMALLER);
105 104
106 if (!largest_icon.empty()) { 105 if (!largest_icon.empty()) {
107 int largest_icon_size = extension_icons.GetIconSizeFromPath(largest_icon); 106 int largest_icon_size = extension_icons.GetIconSizeFromPath(largest_icon);
108 // Replace any missing extension action icons with the largest icon 107 // Replace any missing extension action icons with the largest icon
109 // retrieved from |extension|'s manifest so long as the largest icon is 108 // retrieved from |extension|'s manifest so long as the largest icon is
110 // larger than the current key. 109 // larger than the current key.
111 for (int i = extension_misc::kNumExtensionActionIconSizes - 1; 110 for (int i = extension_misc::kNumExtensionActionIconSizes - 1;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 PopulateMissingValues(extension, new_action.get()); 185 PopulateMissingValues(extension, new_action.get());
187 return new_action.Pass(); 186 return new_action.Pass();
188 } 187 }
189 188
190 ExtensionAction* ExtensionActionManager::GetSystemIndicator( 189 ExtensionAction* ExtensionActionManager::GetSystemIndicator(
191 const Extension& extension) const { 190 const Extension& extension) const {
192 // If it does not already exist, create the SystemIndicatorManager for the 191 // If it does not already exist, create the SystemIndicatorManager for the
193 // given profile. This could return NULL if the system indicator area is 192 // given profile. This could return NULL if the system indicator area is
194 // unavailable on the current system. If so, return NULL to signal that 193 // unavailable on the current system. If so, return NULL to signal that
195 // the system indicator area is unusable. 194 // the system indicator area is unusable.
196 if (!extensions::SystemIndicatorManagerFactory::GetForProfile(profile_)) 195 if (!SystemIndicatorManagerFactory::GetForProfile(profile_))
197 return NULL; 196 return NULL;
198 197
199 return GetOrCreateOrNull(&system_indicators_, extension, 198 return GetOrCreateOrNull(&system_indicators_, extension,
200 ActionInfo::TYPE_SYSTEM_INDICATOR, 199 ActionInfo::TYPE_SYSTEM_INDICATOR,
201 ActionInfo::GetSystemIndicatorInfo(&extension), 200 ActionInfo::GetSystemIndicatorInfo(&extension),
202 profile_); 201 profile_);
203 } 202 }
204 203
204 ExtensionAction* ExtensionActionManager::GetExtensionAction(
205 const Extension& extension) const {
206 ExtensionAction* action = GetBrowserAction(extension);
207 return action ? action : GetPageAction(extension);
208 }
209
205 } // namespace extensions 210 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_action_manager.h ('k') | chrome/browser/extensions/extension_toolbar_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698