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

Side by Side Diff: chrome/browser/notifications/application_notifier_source.cc

Issue 2819413003: Refactor extension app icon. (Closed)
Patch Set: nit Created 3 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
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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/notifications/application_notifier_source.h" 5 #include "chrome/browser/notifications/application_notifier_source.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/extensions/chrome_app_icon_loader.h"
8 #include "chrome/browser/notifications/notifier_state_tracker.h" 9 #include "chrome/browser/notifications/notifier_state_tracker.h"
9 #include "chrome/browser/notifications/notifier_state_tracker_factory.h" 10 #include "chrome/browser/notifications/notifier_state_tracker_factory.h"
10 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
11 #include "extensions/common/constants.h" 12 #include "extensions/common/constants.h"
12 #include "extensions/common/extension_set.h" 13 #include "extensions/common/extension_set.h"
13 #include "extensions/common/permissions/api_permission.h" 14 #include "extensions/common/permissions/api_permission.h"
14 #include "extensions/common/permissions/permissions_data.h" 15 #include "extensions/common/permissions/permissions_data.h"
15 #include "ui/message_center/notifier_settings.h" 16 #include "ui/message_center/notifier_settings.h"
16 17
17 ApplicationNotifierSource::ApplicationNotifierSource(Observer* observer) 18 ApplicationNotifierSource::ApplicationNotifierSource(Observer* observer)
18 : observer_(observer) {} 19 : observer_(observer) {}
19 20
20 ApplicationNotifierSource::~ApplicationNotifierSource() {} 21 ApplicationNotifierSource::~ApplicationNotifierSource() {}
21 22
22 std::vector<std::unique_ptr<message_center::Notifier>> 23 std::vector<std::unique_ptr<message_center::Notifier>>
23 ApplicationNotifierSource::GetNotifierList(Profile* profile) { 24 ApplicationNotifierSource::GetNotifierList(Profile* profile) {
24 std::vector<std::unique_ptr<message_center::Notifier>> notifiers; 25 std::vector<std::unique_ptr<message_center::Notifier>> notifiers;
25 const extensions::ExtensionSet& extension_set = 26 const extensions::ExtensionSet& extension_set =
26 extensions::ExtensionRegistry::Get(profile)->enabled_extensions(); 27 extensions::ExtensionRegistry::Get(profile)->enabled_extensions();
27 // The extension icon size has to be 32x32 at least to load bigger icons if 28 // The extension icon size has to be 32x32 at least to load bigger icons if
28 // the icon doesn't exist for the specified size, and in that case it falls 29 // the icon doesn't exist for the specified size, and in that case it falls
29 // back to the default icon. The fetched icon will be resized in the 30 // back to the default icon. The fetched icon will be resized in the
30 // settings dialog. See chrome/browser/extensions/extension_icon_image.cc 31 // settings dialog. See chrome/browser/extensions/extension_icon_image.cc
31 // and crbug.com/222931 32 // and crbug.com/222931
32 app_icon_loader_.reset(new extensions::ExtensionAppIconLoader( 33 app_icon_loader_.reset(new extensions::ChromeAppIconLoader(
33 profile, extension_misc::EXTENSION_ICON_SMALL, this)); 34 profile, extension_misc::EXTENSION_ICON_SMALL, this));
34 for (extensions::ExtensionSet::const_iterator iter = extension_set.begin(); 35 for (extensions::ExtensionSet::const_iterator iter = extension_set.begin();
35 iter != extension_set.end(); ++iter) { 36 iter != extension_set.end(); ++iter) {
36 const extensions::Extension* extension = iter->get(); 37 const extensions::Extension* extension = iter->get();
37 if (!extension->permissions_data()->HasAPIPermission( 38 if (!extension->permissions_data()->HasAPIPermission(
38 extensions::APIPermission::kNotifications)) { 39 extensions::APIPermission::kNotifications)) {
39 continue; 40 continue;
40 } 41 }
41 42
42 // Hosted apps are no longer able to affect the notifications permission 43 // Hosted apps are no longer able to affect the notifications permission
(...skipping 29 matching lines...) Expand all
72 ApplicationNotifierSource::GetNotifierType() { 73 ApplicationNotifierSource::GetNotifierType() {
73 return message_center::NotifierId::APPLICATION; 74 return message_center::NotifierId::APPLICATION;
74 } 75 }
75 76
76 void ApplicationNotifierSource::OnAppImageUpdated(const std::string& id, 77 void ApplicationNotifierSource::OnAppImageUpdated(const std::string& id,
77 const gfx::ImageSkia& image) { 78 const gfx::ImageSkia& image) {
78 observer_->OnIconImageUpdated( 79 observer_->OnIconImageUpdated(
79 message_center::NotifierId(message_center::NotifierId::APPLICATION, id), 80 message_center::NotifierId(message_center::NotifierId::APPLICATION, id),
80 gfx::Image(image)); 81 gfx::Image(image));
81 } 82 }
OLDNEW
« no previous file with comments | « chrome/browser/notifications/application_notifier_source.h ('k') | chrome/browser/ui/app_icon_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698