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

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

Issue 6914021: Modifying the BackgroundModeManager to handle multiple profiles. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_application_list_model.h" 5 #include "chrome/browser/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-inl.h" 10 #include "base/stl_util-inl.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 bool HasBackgroundAppPermission( 90 bool HasBackgroundAppPermission(
91 const std::set<std::string>& api_permissions) { 91 const std::set<std::string>& api_permissions) {
92 return Extension::HasApiPermission( 92 return Extension::HasApiPermission(
93 api_permissions, Extension::kBackgroundPermission); 93 api_permissions, Extension::kBackgroundPermission);
94 } 94 }
95 } // namespace 95 } // namespace
96 96
97 void 97 void
98 BackgroundApplicationListModel::Observer::OnApplicationDataChanged( 98 BackgroundApplicationListModel::Observer::OnApplicationDataChanged(
99 const Extension* extension) { 99 const Extension* extension, Profile* profile) {
100 } 100 }
101 101
102 void 102 void
103 BackgroundApplicationListModel::Observer::OnApplicationListChanged() { 103 BackgroundApplicationListModel::Observer::OnApplicationListChanged(
104 Profile* profile) {
104 } 105 }
105 106
106 BackgroundApplicationListModel::Observer::~Observer() { 107 BackgroundApplicationListModel::Observer::~Observer() {
107 } 108 }
108 109
109 BackgroundApplicationListModel::Application::~Application() { 110 BackgroundApplicationListModel::Application::~Application() {
110 } 111 }
111 112
112 BackgroundApplicationListModel::Application::Application( 113 BackgroundApplicationListModel::Application::Application(
113 BackgroundApplicationListModel* model, 114 BackgroundApplicationListModel* model,
114 const Extension* extension) 115 const Extension* extension)
115 : extension_(extension), 116 : extension_(extension),
116 icon_(NULL), 117 icon_(NULL),
117 model_(model), 118 model_(model),
118 ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)) { 119 ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)) {
119 } 120 }
120 121
121 void BackgroundApplicationListModel::Application::OnImageLoaded( 122 void BackgroundApplicationListModel::Application::OnImageLoaded(
122 SkBitmap* image, 123 SkBitmap* image,
123 const ExtensionResource& resource, 124 const ExtensionResource& resource,
124 int index) { 125 int index) {
125 if (!image) 126 if (!image)
126 return; 127 return;
127 icon_.reset(new SkBitmap(*image)); 128 icon_.reset(new SkBitmap(*image));
128 model_->OnApplicationDataChanged(extension_); 129 model_->SendApplicationDataChangedNotifications(extension_);
129 } 130 }
130 131
131 void BackgroundApplicationListModel::Application::RequestIcon( 132 void BackgroundApplicationListModel::Application::RequestIcon(
132 Extension::Icons size) { 133 Extension::Icons size) {
133 ExtensionResource resource = extension_->GetIconResource( 134 ExtensionResource resource = extension_->GetIconResource(
134 size, ExtensionIconSet::MATCH_BIGGER); 135 size, ExtensionIconSet::MATCH_BIGGER);
135 tracker_.LoadImage(extension_, resource, gfx::Size(size, size), 136 tracker_.LoadImage(extension_, resource, gfx::Size(size, size),
136 ImageLoadingTracker::CACHE); 137 ImageLoadingTracker::CACHE);
137 } 138 }
138 139
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 OnExtensionLoaded(Details<Extension>(details).ptr()); 257 OnExtensionLoaded(Details<Extension>(details).ptr());
257 break; 258 break;
258 case NotificationType::EXTENSION_UNLOADED: 259 case NotificationType::EXTENSION_UNLOADED:
259 OnExtensionUnloaded(Details<UnloadedExtensionInfo>(details)->extension); 260 OnExtensionUnloaded(Details<UnloadedExtensionInfo>(details)->extension);
260 break; 261 break;
261 default: 262 default:
262 NOTREACHED() << "Received unexpected notification"; 263 NOTREACHED() << "Received unexpected notification";
263 } 264 }
264 } 265 }
265 266
266 void BackgroundApplicationListModel::OnApplicationDataChanged( 267 void BackgroundApplicationListModel::SendApplicationDataChangedNotifications(
267 const Extension* extension) { 268 const Extension* extension) {
268 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationDataChanged(extension)); 269 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationDataChanged(extension,
270 profile_));
269 } 271 }
270 272
271 void BackgroundApplicationListModel::OnExtensionLoaded(Extension* extension) { 273 void BackgroundApplicationListModel::OnExtensionLoaded(Extension* extension) {
272 // We only care about extensions that are background applications 274 // We only care about extensions that are background applications
273 if (!IsBackgroundApp(*extension)) 275 if (!IsBackgroundApp(*extension))
274 return; 276 return;
275 AssociateApplicationData(extension); 277 AssociateApplicationData(extension);
276 Update(); 278 Update();
277 } 279 }
278 280
(...skipping 24 matching lines...) Expand all
303 ExtensionList::const_iterator new_cursor = extensions.begin(); 305 ExtensionList::const_iterator new_cursor = extensions.begin();
304 while (old_cursor != extensions_.end() && 306 while (old_cursor != extensions_.end() &&
305 new_cursor != extensions.end() && 307 new_cursor != extensions.end() &&
306 (*old_cursor)->name() == (*new_cursor)->name() && 308 (*old_cursor)->name() == (*new_cursor)->name() &&
307 (*old_cursor)->id() == (*new_cursor)->id()) { 309 (*old_cursor)->id() == (*new_cursor)->id()) {
308 ++old_cursor; 310 ++old_cursor;
309 ++new_cursor; 311 ++new_cursor;
310 } 312 }
311 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { 313 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) {
312 extensions_ = extensions; 314 extensions_ = extensions;
313 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged()); 315 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged(profile_));
314 } 316 }
315 } 317 }
OLDNEW
« no previous file with comments | « chrome/browser/background_application_list_model.h ('k') | chrome/browser/background_mode_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698