OLD | NEW |
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 Loading... |
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, Profile* profile) { | 99 const Extension* extension) { |
100 } | 100 } |
101 | 101 |
102 void | 102 void |
103 BackgroundApplicationListModel::Observer::OnApplicationListChanged( | 103 BackgroundApplicationListModel::Observer::OnApplicationListChanged() { |
104 Profile* profile) { | |
105 } | 104 } |
106 | 105 |
107 BackgroundApplicationListModel::Observer::~Observer() { | 106 BackgroundApplicationListModel::Observer::~Observer() { |
108 } | 107 } |
109 | 108 |
110 BackgroundApplicationListModel::Application::~Application() { | 109 BackgroundApplicationListModel::Application::~Application() { |
111 } | 110 } |
112 | 111 |
113 BackgroundApplicationListModel::Application::Application( | 112 BackgroundApplicationListModel::Application::Application( |
114 BackgroundApplicationListModel* model, | 113 BackgroundApplicationListModel* model, |
115 const Extension* extension) | 114 const Extension* extension) |
116 : extension_(extension), | 115 : extension_(extension), |
117 icon_(NULL), | 116 icon_(NULL), |
118 model_(model), | 117 model_(model), |
119 ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)) { | 118 ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)) { |
120 } | 119 } |
121 | 120 |
122 void BackgroundApplicationListModel::Application::OnImageLoaded( | 121 void BackgroundApplicationListModel::Application::OnImageLoaded( |
123 SkBitmap* image, | 122 SkBitmap* image, |
124 const ExtensionResource& resource, | 123 const ExtensionResource& resource, |
125 int index) { | 124 int index) { |
126 if (!image) | 125 if (!image) |
127 return; | 126 return; |
128 icon_.reset(new SkBitmap(*image)); | 127 icon_.reset(new SkBitmap(*image)); |
129 model_->SendApplicationDataChangedNotifications(extension_); | 128 model_->OnApplicationDataChanged(extension_); |
130 } | 129 } |
131 | 130 |
132 void BackgroundApplicationListModel::Application::RequestIcon( | 131 void BackgroundApplicationListModel::Application::RequestIcon( |
133 Extension::Icons size) { | 132 Extension::Icons size) { |
134 ExtensionResource resource = extension_->GetIconResource( | 133 ExtensionResource resource = extension_->GetIconResource( |
135 size, ExtensionIconSet::MATCH_BIGGER); | 134 size, ExtensionIconSet::MATCH_BIGGER); |
136 tracker_.LoadImage(extension_, resource, gfx::Size(size, size), | 135 tracker_.LoadImage(extension_, resource, gfx::Size(size, size), |
137 ImageLoadingTracker::CACHE); | 136 ImageLoadingTracker::CACHE); |
138 } | 137 } |
139 | 138 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 OnExtensionLoaded(Details<Extension>(details).ptr()); | 256 OnExtensionLoaded(Details<Extension>(details).ptr()); |
258 break; | 257 break; |
259 case NotificationType::EXTENSION_UNLOADED: | 258 case NotificationType::EXTENSION_UNLOADED: |
260 OnExtensionUnloaded(Details<UnloadedExtensionInfo>(details)->extension); | 259 OnExtensionUnloaded(Details<UnloadedExtensionInfo>(details)->extension); |
261 break; | 260 break; |
262 default: | 261 default: |
263 NOTREACHED() << "Received unexpected notification"; | 262 NOTREACHED() << "Received unexpected notification"; |
264 } | 263 } |
265 } | 264 } |
266 | 265 |
267 void BackgroundApplicationListModel::SendApplicationDataChangedNotifications( | 266 void BackgroundApplicationListModel::OnApplicationDataChanged( |
268 const Extension* extension) { | 267 const Extension* extension) { |
269 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationDataChanged(extension, | 268 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationDataChanged(extension)); |
270 profile_)); | |
271 } | 269 } |
272 | 270 |
273 void BackgroundApplicationListModel::OnExtensionLoaded(Extension* extension) { | 271 void BackgroundApplicationListModel::OnExtensionLoaded(Extension* extension) { |
274 // We only care about extensions that are background applications | 272 // We only care about extensions that are background applications |
275 if (!IsBackgroundApp(*extension)) | 273 if (!IsBackgroundApp(*extension)) |
276 return; | 274 return; |
277 AssociateApplicationData(extension); | 275 AssociateApplicationData(extension); |
278 Update(); | 276 Update(); |
279 } | 277 } |
280 | 278 |
(...skipping 24 matching lines...) Expand all Loading... |
305 ExtensionList::const_iterator new_cursor = extensions.begin(); | 303 ExtensionList::const_iterator new_cursor = extensions.begin(); |
306 while (old_cursor != extensions_.end() && | 304 while (old_cursor != extensions_.end() && |
307 new_cursor != extensions.end() && | 305 new_cursor != extensions.end() && |
308 (*old_cursor)->name() == (*new_cursor)->name() && | 306 (*old_cursor)->name() == (*new_cursor)->name() && |
309 (*old_cursor)->id() == (*new_cursor)->id()) { | 307 (*old_cursor)->id() == (*new_cursor)->id()) { |
310 ++old_cursor; | 308 ++old_cursor; |
311 ++new_cursor; | 309 ++new_cursor; |
312 } | 310 } |
313 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { | 311 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { |
314 extensions_ = extensions; | 312 extensions_ = extensions; |
315 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged(profile_)); | 313 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged()); |
316 } | 314 } |
317 } | 315 } |
OLD | NEW |