| 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/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_mode_manager.h" | 13 #include "chrome/browser/background/background_mode_manager.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/extensions/extension_prefs.h" | 15 #include "chrome/browser/extensions/extension_prefs.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/extensions/image_loading_tracker.h" | 17 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
| 20 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
| 21 #include "chrome/common/extensions/extension_icon_set.h" | 21 #include "chrome/common/extensions/extension_icon_set.h" |
| 22 #include "chrome/common/extensions/extension_resource.h" | 22 #include "chrome/common/extensions/extension_resource.h" |
| 23 #include "content/public/browser/notification_details.h" | 23 #include "content/public/browser/notification_details.h" |
| 24 #include "content/public/browser/notification_source.h" | 24 #include "content/public/browser/notification_source.h" |
| 25 #include "ui/base/l10n/l10n_util_collator.h" | 25 #include "ui/base/l10n/l10n_util_collator.h" |
| 26 #include "ui/gfx/image/image.h" |
| 26 | 27 |
| 27 class ExtensionNameComparator { | 28 class ExtensionNameComparator { |
| 28 public: | 29 public: |
| 29 explicit ExtensionNameComparator(icu::Collator* collator); | 30 explicit ExtensionNameComparator(icu::Collator* collator); |
| 30 bool operator()(const Extension* x, const Extension* y); | 31 bool operator()(const Extension* x, const Extension* y); |
| 31 | 32 |
| 32 private: | 33 private: |
| 33 icu::Collator* collator_; | 34 icu::Collator* collator_; |
| 34 }; | 35 }; |
| 35 | 36 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 48 // BackgroundApplicationListModel class. | 49 // BackgroundApplicationListModel class. |
| 49 class BackgroundApplicationListModel::Application | 50 class BackgroundApplicationListModel::Application |
| 50 : public ImageLoadingTracker::Observer { | 51 : public ImageLoadingTracker::Observer { |
| 51 public: | 52 public: |
| 52 Application(BackgroundApplicationListModel* model, | 53 Application(BackgroundApplicationListModel* model, |
| 53 const Extension* an_extension); | 54 const Extension* an_extension); |
| 54 | 55 |
| 55 virtual ~Application(); | 56 virtual ~Application(); |
| 56 | 57 |
| 57 // Invoked when a request icon is available. | 58 // Invoked when a request icon is available. |
| 58 virtual void OnImageLoaded(SkBitmap* image, | 59 virtual void OnImageLoaded(const gfx::Image& image, |
| 59 const ExtensionResource& resource, | 60 const std::string& extension_id, |
| 60 int index); | 61 int index) OVERRIDE; |
| 61 | 62 |
| 62 // Uses the FILE thread to request this extension's icon, sized | 63 // Uses the FILE thread to request this extension's icon, sized |
| 63 // appropriately. | 64 // appropriately. |
| 64 void RequestIcon(ExtensionIconSet::Icons size); | 65 void RequestIcon(ExtensionIconSet::Icons size); |
| 65 | 66 |
| 66 const Extension* extension_; | 67 const Extension* extension_; |
| 67 scoped_ptr<SkBitmap> icon_; | 68 scoped_ptr<SkBitmap> icon_; |
| 68 BackgroundApplicationListModel* model_; | 69 BackgroundApplicationListModel* model_; |
| 69 ImageLoadingTracker tracker_; | 70 ImageLoadingTracker tracker_; |
| 70 }; | 71 }; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 BackgroundApplicationListModel::Application::Application( | 123 BackgroundApplicationListModel::Application::Application( |
| 123 BackgroundApplicationListModel* model, | 124 BackgroundApplicationListModel* model, |
| 124 const Extension* extension) | 125 const Extension* extension) |
| 125 : extension_(extension), | 126 : extension_(extension), |
| 126 icon_(NULL), | 127 icon_(NULL), |
| 127 model_(model), | 128 model_(model), |
| 128 ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)) { | 129 ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)) { |
| 129 } | 130 } |
| 130 | 131 |
| 131 void BackgroundApplicationListModel::Application::OnImageLoaded( | 132 void BackgroundApplicationListModel::Application::OnImageLoaded( |
| 132 SkBitmap* image, | 133 const gfx::Image& image, |
| 133 const ExtensionResource& resource, | 134 const std::string& extension_id, |
| 134 int index) { | 135 int index) { |
| 135 if (!image) | 136 if (image.IsEmpty()) |
| 136 return; | 137 return; |
| 137 icon_.reset(new SkBitmap(*image)); | 138 icon_.reset(new SkBitmap(*image.ToSkBitmap())); |
| 138 model_->SendApplicationDataChangedNotifications(extension_); | 139 model_->SendApplicationDataChangedNotifications(extension_); |
| 139 } | 140 } |
| 140 | 141 |
| 141 void BackgroundApplicationListModel::Application::RequestIcon( | 142 void BackgroundApplicationListModel::Application::RequestIcon( |
| 142 ExtensionIconSet::Icons size) { | 143 ExtensionIconSet::Icons size) { |
| 143 ExtensionResource resource = extension_->GetIconResource( | 144 ExtensionResource resource = extension_->GetIconResource( |
| 144 size, ExtensionIconSet::MATCH_BIGGER); | 145 size, ExtensionIconSet::MATCH_BIGGER); |
| 145 tracker_.LoadImage(extension_, resource, gfx::Size(size, size), | 146 tracker_.LoadImage(extension_, resource, gfx::Size(size, size), |
| 146 ImageLoadingTracker::CACHE); | 147 ImageLoadingTracker::CACHE); |
| 147 } | 148 } |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 (*old_cursor)->name() == (*new_cursor)->name() && | 351 (*old_cursor)->name() == (*new_cursor)->name() && |
| 351 (*old_cursor)->id() == (*new_cursor)->id()) { | 352 (*old_cursor)->id() == (*new_cursor)->id()) { |
| 352 ++old_cursor; | 353 ++old_cursor; |
| 353 ++new_cursor; | 354 ++new_cursor; |
| 354 } | 355 } |
| 355 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { | 356 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { |
| 356 extensions_ = extensions; | 357 extensions_ = extensions; |
| 357 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged(profile_)); | 358 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged(profile_)); |
| 358 } | 359 } |
| 359 } | 360 } |
| OLD | NEW |