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

Side by Side Diff: chrome/browser/background/background_application_list_model.cc

Issue 10843014: Generalize ExtensionIconSet to store icon paths for custom size sets (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/background/background_contents_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/background/background_application_list_model.h" 5 #include "chrome/browser/background/background_application_list_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/app/chrome_command_ids.h" 12 #include "chrome/app/chrome_command_ids.h"
13 #include "chrome/browser/background/background_contents_service.h" 13 #include "chrome/browser/background/background_contents_service.h"
14 #include "chrome/browser/background/background_contents_service_factory.h" 14 #include "chrome/browser/background/background_contents_service_factory.h"
15 #include "chrome/browser/background/background_mode_manager.h" 15 #include "chrome/browser/background/background_mode_manager.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/extensions/extension_prefs.h" 17 #include "chrome/browser/extensions/extension_prefs.h"
18 #include "chrome/browser/extensions/extension_service.h" 18 #include "chrome/browser/extensions/extension_service.h"
19 #include "chrome/browser/extensions/image_loading_tracker.h" 19 #include "chrome/browser/extensions/image_loading_tracker.h"
20 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/common/chrome_notification_types.h" 21 #include "chrome/common/chrome_notification_types.h"
22 #include "chrome/common/extensions/extension.h" 22 #include "chrome/common/extensions/extension.h"
23 #include "chrome/common/extensions/extension_constants.h"
23 #include "chrome/common/extensions/extension_icon_set.h" 24 #include "chrome/common/extensions/extension_icon_set.h"
24 #include "chrome/common/extensions/extension_resource.h" 25 #include "chrome/common/extensions/extension_resource.h"
25 #include "chrome/common/extensions/permissions/permission_set.h" 26 #include "chrome/common/extensions/permissions/permission_set.h"
26 #include "content/public/browser/notification_details.h" 27 #include "content/public/browser/notification_details.h"
27 #include "content/public/browser/notification_source.h" 28 #include "content/public/browser/notification_source.h"
28 #include "ui/base/l10n/l10n_util_collator.h" 29 #include "ui/base/l10n/l10n_util_collator.h"
29 #include "ui/gfx/image/image.h" 30 #include "ui/gfx/image/image.h"
30 #include "ui/gfx/image/image_skia.h" 31 #include "ui/gfx/image/image_skia.h"
31 32
32 using extensions::APIPermission; 33 using extensions::APIPermission;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 67
67 virtual ~Application(); 68 virtual ~Application();
68 69
69 // Invoked when a request icon is available. 70 // Invoked when a request icon is available.
70 virtual void OnImageLoaded(const gfx::Image& image, 71 virtual void OnImageLoaded(const gfx::Image& image,
71 const std::string& extension_id, 72 const std::string& extension_id,
72 int index) OVERRIDE; 73 int index) OVERRIDE;
73 74
74 // Uses the FILE thread to request this extension's icon, sized 75 // Uses the FILE thread to request this extension's icon, sized
75 // appropriately. 76 // appropriately.
76 void RequestIcon(ExtensionIconSet::Icons size); 77 void RequestIcon(extension_misc::ExtensionIcons size);
77 78
78 const Extension* extension_; 79 const Extension* extension_;
79 scoped_ptr<gfx::ImageSkia> icon_; 80 scoped_ptr<gfx::ImageSkia> icon_;
80 BackgroundApplicationListModel* model_; 81 BackgroundApplicationListModel* model_;
81 ImageLoadingTracker tracker_; 82 ImageLoadingTracker tracker_;
82 }; 83 };
83 84
84 namespace { 85 namespace {
85 void GetServiceApplications(ExtensionService* service, 86 void GetServiceApplications(ExtensionService* service,
86 ExtensionList* applications_result) { 87 ExtensionList* applications_result) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 const gfx::Image& image, 149 const gfx::Image& image,
149 const std::string& extension_id, 150 const std::string& extension_id,
150 int index) { 151 int index) {
151 if (image.IsEmpty()) 152 if (image.IsEmpty())
152 return; 153 return;
153 icon_.reset(image.CopyImageSkia()); 154 icon_.reset(image.CopyImageSkia());
154 model_->SendApplicationDataChangedNotifications(extension_); 155 model_->SendApplicationDataChangedNotifications(extension_);
155 } 156 }
156 157
157 void BackgroundApplicationListModel::Application::RequestIcon( 158 void BackgroundApplicationListModel::Application::RequestIcon(
158 ExtensionIconSet::Icons size) { 159 extension_misc::ExtensionIcons size) {
159 ExtensionResource resource = extension_->GetIconResource( 160 ExtensionResource resource = extension_->GetIconResource(
160 size, ExtensionIconSet::MATCH_BIGGER); 161 size, ExtensionIconSet::MATCH_BIGGER);
161 tracker_.LoadImage(extension_, resource, gfx::Size(size, size), 162 tracker_.LoadImage(extension_, resource, gfx::Size(size, size),
162 ImageLoadingTracker::CACHE); 163 ImageLoadingTracker::CACHE);
163 } 164 }
164 165
165 BackgroundApplicationListModel::~BackgroundApplicationListModel() { 166 BackgroundApplicationListModel::~BackgroundApplicationListModel() {
166 STLDeleteContainerPairSecondPointers(applications_.begin(), 167 STLDeleteContainerPairSecondPointers(applications_.begin(),
167 applications_.end()); 168 applications_.end());
168 } 169 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // App position is used as a dynamic command and so must be less than any 203 // App position is used as a dynamic command and so must be less than any
203 // predefined command id. 204 // predefined command id.
204 if (applications_.size() >= IDC_MinimumLabelValue) { 205 if (applications_.size() >= IDC_MinimumLabelValue) {
205 LOG(ERROR) << "Background application limit of " << IDC_MinimumLabelValue 206 LOG(ERROR) << "Background application limit of " << IDC_MinimumLabelValue
206 << " exceeded. Ignoring."; 207 << " exceeded. Ignoring.";
207 return; 208 return;
208 } 209 }
209 application = new Application(this, extension); 210 application = new Application(this, extension);
210 applications_[extension->id()] = application; 211 applications_[extension->id()] = application;
211 Update(); 212 Update();
212 application->RequestIcon(ExtensionIconSet::EXTENSION_ICON_BITTY); 213 application->RequestIcon(extension_misc::EXTENSION_ICON_BITTY);
213 } 214 }
214 } 215 }
215 216
216 void BackgroundApplicationListModel::DissociateApplicationData( 217 void BackgroundApplicationListModel::DissociateApplicationData(
217 const Extension* extension) { 218 const Extension* extension) {
218 ApplicationMap::iterator found = applications_.find(extension->id()); 219 ApplicationMap::iterator found = applications_.find(extension->id());
219 if (found != applications_.end()) { 220 if (found != applications_.end()) {
220 delete found->second; 221 delete found->second;
221 applications_.erase(found); 222 applications_.erase(found);
222 } 223 }
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 (*old_cursor)->name() == (*new_cursor)->name() && 407 (*old_cursor)->name() == (*new_cursor)->name() &&
407 (*old_cursor)->id() == (*new_cursor)->id()) { 408 (*old_cursor)->id() == (*new_cursor)->id()) {
408 ++old_cursor; 409 ++old_cursor;
409 ++new_cursor; 410 ++new_cursor;
410 } 411 }
411 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { 412 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) {
412 extensions_ = extensions; 413 extensions_ = extensions;
413 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged(profile_)); 414 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged(profile_));
414 } 415 }
415 } 416 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/background/background_contents_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698