Chromium Code Reviews| Index: chrome/browser/notifications/message_center_settings_controller.cc |
| diff --git a/chrome/browser/notifications/message_center_settings_controller.cc b/chrome/browser/notifications/message_center_settings_controller.cc |
| index 1e0dc01b34d2f02d8a6ef774ff4e0367cd97e305..3bbb7c4ac5a076d671c14a4b29c7c4dfba1bf64a 100644 |
| --- a/chrome/browser/notifications/message_center_settings_controller.cc |
| +++ b/chrome/browser/notifications/message_center_settings_controller.cc |
| @@ -20,6 +20,7 @@ |
| #include "chrome/browser/extensions/extension_app_icon_loader.h" |
| #include "chrome/browser/favicon/favicon_service_factory.h" |
| #include "chrome/browser/notifications/desktop_notification_profile_util.h" |
| +#include "chrome/browser/notifications/notifier_source.h" |
| #include "chrome/browser/notifications/notifier_state_tracker.h" |
| #include "chrome/browser/notifications/notifier_state_tracker_factory.h" |
| #include "chrome/browser/profiles/profile.h" |
| @@ -49,8 +50,7 @@ |
| #if defined(OS_CHROMEOS) |
| #include "ash/system/system_notifier.h" |
| #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| -#include "chrome/browser/notifications/arc_notifier_manager.h" |
| -#include "components/arc/arc_bridge_service.h" |
| +#include "chrome/browser/notifications/arc_notifier_source.h" |
| #endif |
| using message_center::Notifier; |
| @@ -98,6 +98,7 @@ ProfileNotifierGroup::ProfileNotifierGroup(const gfx::Image& icon, |
| } // namespace message_center |
| namespace { |
| + |
| class NotifierComparator { |
| public: |
| explicit NotifierComparator(icu::Collator* collator) : collator_(collator) {} |
| @@ -117,6 +118,255 @@ class NotifierComparator { |
| icu::Collator* collator_; |
| }; |
| +class ApplicationNotifiereSource : public NotifierSource, |
|
dewittj
2016/06/16 19:45:36
I think this deserves its own h/cc files. Probabl
hirono
2016/06/17 04:56:46
Separating files is done. The names of source clas
|
| + public AppIconLoaderDelegate { |
| + public: |
| + explicit ApplicationNotifiereSource( |
|
dewittj
2016/06/16 19:45:36
This should be spelled ApplicationNotifierSource,
hirono
2016/06/17 04:56:46
Oops, yes!
|
| + message_center::NotifierSettingsObserver* parent) |
| + : NotifierSource(parent) {} |
| + |
| + std::vector<std::unique_ptr<message_center::Notifier>> GetNotifierList( |
| + Profile* profile) override { |
| + std::vector<std::unique_ptr<message_center::Notifier>> notifiers; |
| + NotifierStateTracker* const notifier_state_tracker = |
| + NotifierStateTrackerFactory::GetForProfile(profile); |
| + const extensions::ExtensionSet& extension_set = |
| + extensions::ExtensionRegistry::Get(profile)->enabled_extensions(); |
| + // The extension icon size has to be 32x32 at least to load bigger icons if |
| + // the icon doesn't exist for the specified size, and in that case it falls |
| + // back to the default icon. The fetched icon will be resized in the |
| + // settings dialog. See chrome/browser/extensions/extension_icon_image.cc |
| + // and crbug.com/222931 |
| + app_icon_loader_.reset(new extensions::ExtensionAppIconLoader( |
| + profile, extension_misc::EXTENSION_ICON_SMALL, this)); |
| + for (extensions::ExtensionSet::const_iterator iter = extension_set.begin(); |
| + iter != extension_set.end(); ++iter) { |
| + const extensions::Extension* extension = iter->get(); |
| + if (!extension->permissions_data()->HasAPIPermission( |
| + extensions::APIPermission::kNotifications)) { |
| + continue; |
| + } |
| + |
| + // Hosted apps are no longer able to affect the notifications permission |
| + // state for web notifications. |
| + // TODO(dewittj): Deprecate the 'notifications' permission for hosted |
| + // apps. |
| + if (extension->is_hosted_app()) |
| + continue; |
| + |
| + NotifierId notifier_id(NotifierId::APPLICATION, extension->id()); |
| + notifiers.emplace_back( |
| + new Notifier(notifier_id, base::UTF8ToUTF16(extension->name()), |
| + notifier_state_tracker->IsNotifierEnabled(notifier_id))); |
| + app_icon_loader_->FetchImage(extension->id()); |
| + } |
| + |
| + return notifiers; |
| + } |
| + |
| + void SetNotifierEnabled(Profile* profile, |
| + const message_center::Notifier& notifier, |
| + bool enabled) override { |
| + NotifierStateTrackerFactory::GetForProfile(profile)->SetNotifierEnabled( |
| + notifier.notifier_id, enabled); |
| + parent_->NotifierEnabledChanged(notifier.notifier_id, enabled); |
| + } |
| + |
| + message_center::NotifierId::NotifierType GetNotifierType() override { |
| + return NotifierId::APPLICATION; |
| + } |
| + |
| + private: |
| + // Overridden from AppIconLoaderDelegate. |
| + void OnAppImageUpdated(const std::string& id, |
| + const gfx::ImageSkia& image) override { |
| + parent_->UpdateIconImage(NotifierId(NotifierId::APPLICATION, id), |
| + gfx::Image(image)); |
| + } |
| + |
| + std::unique_ptr<AppIconLoader> app_icon_loader_; |
| +}; |
| + |
| +class WebPageNotifiereSource : public NotifierSource { |
| + public: |
| + explicit WebPageNotifiereSource( |
| + message_center::NotifierSettingsObserver* parent) |
| + : NotifierSource(parent) {} |
| + |
| + std::vector<std::unique_ptr<message_center::Notifier>> GetNotifierList( |
| + Profile* profile) override { |
| + std::vector<std::unique_ptr<message_center::Notifier>> notifiers; |
| + NotifierStateTracker* const notifier_state_tracker = |
| + NotifierStateTrackerFactory::GetForProfile(profile); |
| + ContentSettingsForOneType settings; |
| + DesktopNotificationProfileUtil::GetNotificationsSettings(profile, |
| + &settings); |
| + |
| + favicon::FaviconService* const favicon_service = |
| + FaviconServiceFactory::GetForProfile( |
| + profile, ServiceAccessType::EXPLICIT_ACCESS); |
| + favicon_tracker_.reset(new base::CancelableTaskTracker()); |
| + patterns_.clear(); |
| + for (ContentSettingsForOneType::const_iterator iter = settings.begin(); |
| + iter != settings.end(); ++iter) { |
| + if (iter->primary_pattern == ContentSettingsPattern::Wildcard() && |
| + iter->secondary_pattern == ContentSettingsPattern::Wildcard() && |
| + iter->source != "preference") { |
| + continue; |
| + } |
| + |
| + std::string url_pattern = iter->primary_pattern.ToString(); |
| + base::string16 name = base::UTF8ToUTF16(url_pattern); |
| + GURL url(url_pattern); |
| + NotifierId notifier_id(url); |
| + notifiers.emplace_back( |
| + new Notifier(notifier_id, name, |
| + notifier_state_tracker->IsNotifierEnabled(notifier_id))); |
| + patterns_[name] = iter->primary_pattern; |
| + // Note that favicon service obtains the favicon from history. This means |
| + // that it will fail to obtain the image if there are no history data for |
| + // that URL. |
| + favicon_service->GetFaviconImageForPageURL( |
| + url, base::Bind(&WebPageNotifiereSource::OnFaviconLoaded, |
| + base::Unretained(this), url), |
| + favicon_tracker_.get()); |
| + } |
| + |
| + return notifiers; |
| + } |
| + |
| + void SetNotifierEnabled(Profile* profile, |
| + const message_center::Notifier& notifier, |
| + bool enabled) override { |
| + // WEB_PAGE notifier cannot handle in DesktopNotificationService |
| + // since it has the exact URL pattern. |
| + // TODO(mukai): fix this. |
| + ContentSetting default_setting = |
| + HostContentSettingsMapFactory::GetForProfile(profile) |
| + ->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| + NULL); |
| + |
| + DCHECK(default_setting == CONTENT_SETTING_ALLOW || |
| + default_setting == CONTENT_SETTING_BLOCK || |
| + default_setting == CONTENT_SETTING_ASK); |
| + |
| + // The content setting for notifications needs to clear when it changes to |
| + // the default value or get explicitly set when it differs from the |
| + // default. |
| + bool differs_from_default_value = |
| + (default_setting != CONTENT_SETTING_ALLOW && enabled) || |
| + (default_setting == CONTENT_SETTING_ALLOW && !enabled); |
| + |
| + if (differs_from_default_value) { |
| + if (notifier.notifier_id.url.is_valid()) { |
| + if (enabled) { |
| + DesktopNotificationProfileUtil::GrantPermission( |
| + profile, notifier.notifier_id.url); |
| + } else { |
| + DesktopNotificationProfileUtil::DenyPermission( |
| + profile, notifier.notifier_id.url); |
| + } |
| + } else { |
| + LOG(ERROR) << "Invalid url pattern: " |
| + << notifier.notifier_id.url.spec(); |
| + } |
| + } else { |
| + ContentSettingsPattern pattern; |
| + |
| + const auto& iter = patterns_.find(notifier.name); |
| + if (iter != patterns_.end()) { |
| + pattern = iter->second; |
| + } else if (notifier.notifier_id.url.is_valid()) { |
| + pattern = |
| + ContentSettingsPattern::FromURLNoWildcard(notifier.notifier_id.url); |
| + } else { |
| + LOG(ERROR) << "Invalid url pattern: " |
| + << notifier.notifier_id.url.spec(); |
| + } |
| + |
| + if (pattern.IsValid()) { |
| + // Note that we don't use |
| + // DesktopNotificationProfileUtil::ClearSetting() |
| + // here because pattern might be from user manual input and not match |
| + // the default one used by ClearSetting(). |
| + HostContentSettingsMapFactory::GetForProfile(profile) |
| + ->SetContentSettingCustomScope( |
| + pattern, ContentSettingsPattern::Wildcard(), |
| + CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| + content_settings::ResourceIdentifier(), |
| + CONTENT_SETTING_DEFAULT); |
| + } |
| + } |
| + |
| + parent_->NotifierEnabledChanged(notifier.notifier_id, enabled); |
| + } |
| + |
| + void OnNotifierSettingsClosing() override { |
| + DCHECK(favicon_tracker_.get()); |
| + favicon_tracker_->TryCancelAll(); |
| + patterns_.clear(); |
| + } |
| + |
| + message_center::NotifierId::NotifierType GetNotifierType() override { |
| + return NotifierId::WEB_PAGE; |
| + } |
| + |
| + private: |
| + void OnFaviconLoaded(const GURL& url, |
| + const favicon_base::FaviconImageResult& favicon_result) { |
| + parent_->UpdateIconImage(NotifierId(url), favicon_result.image); |
| + } |
| + |
| + std::map<base::string16, ContentSettingsPattern> patterns_; |
| + |
| + // The task tracker for loading favicons. |
| + std::unique_ptr<base::CancelableTaskTracker> favicon_tracker_; |
| +}; |
| + |
| +#if defined(OS_CHROMEOS) |
| +class SystemComponentNotifierSource : public NotifierSource { |
| + public: |
| + explicit SystemComponentNotifierSource( |
| + message_center::NotifierSettingsObserver* parent) |
| + : NotifierSource(parent) {} |
| + |
| + std::vector<std::unique_ptr<message_center::Notifier>> GetNotifierList( |
| + Profile* profile) override { |
| + std::vector<std::unique_ptr<message_center::Notifier>> notifiers; |
| + NotifierStateTracker* const notifier_state_tracker = |
| + NotifierStateTrackerFactory::GetForProfile(profile); |
| + |
| + // Screenshot notification feature is only for ChromeOS. See |
| + // crbug.com/238358 |
| + const base::string16& screenshot_name = |
| + l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_NOTIFIER_SCREENSHOT_NAME); |
| + NotifierId screenshot_notifier_id( |
| + NotifierId::SYSTEM_COMPONENT, |
| + ash::system_notifier::kNotifierScreenshot); |
| + Notifier* const screenshot_notifier = new Notifier( |
| + screenshot_notifier_id, screenshot_name, |
| + notifier_state_tracker->IsNotifierEnabled(screenshot_notifier_id)); |
| + screenshot_notifier->icon = |
| + ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| + IDR_SCREENSHOT_NOTIFICATION_ICON); |
| + notifiers.emplace_back(screenshot_notifier); |
| + return notifiers; |
| + } |
| + |
| + void SetNotifierEnabled(Profile* profile, |
| + const message_center::Notifier& notifier, |
| + bool enabled) override { |
| + NotifierStateTrackerFactory::GetForProfile(profile)->SetNotifierEnabled( |
| + notifier.notifier_id, enabled); |
| + parent_->NotifierEnabledChanged(notifier.notifier_id, enabled); |
| + } |
| + |
| + message_center::NotifierId::NotifierType GetNotifierType() override { |
| + return NotifierId::SYSTEM_COMPONENT; |
| + } |
| +}; |
| +#endif |
| + |
| } // namespace |
| MessageCenterSettingsController::MessageCenterSettingsController( |
| @@ -139,13 +389,24 @@ MessageCenterSettingsController::MessageCenterSettingsController( |
| profile_attributes_storage_.AddObserver(this); |
| RebuildNotifierGroups(false); |
| + sources_.insert(std::make_pair( |
| + NotifierId::APPLICATION, |
| + std::unique_ptr<NotifierSource>(new ApplicationNotifiereSource(this)))); |
| + sources_.insert(std::make_pair( |
| + NotifierId::WEB_PAGE, |
| + std::unique_ptr<NotifierSource>(new WebPageNotifiereSource(this)))); |
| + |
| #if defined(OS_CHROMEOS) |
| // UserManager may not exist in some tests. |
| if (user_manager::UserManager::IsInitialized()) |
| user_manager::UserManager::Get()->AddSessionStateObserver(this); |
| - // Check if ARC is enabled. |
| - if (arc::ArcBridgeService::Get()) |
| - arc_notifier_manager_.reset(new arc::ArcNotifierManager()); |
| + // FOr system components. |
| + sources_.insert(std::make_pair(NotifierId::SYSTEM_COMPONENT, |
| + std::unique_ptr<NotifierSource>( |
| + new SystemComponentNotifierSource(this)))); |
| + sources_.insert(std::make_pair( |
| + NotifierId::ARC_APPLICATION, |
| + std::unique_ptr<NotifierSource>(new arc::ArcNotifierSource(this)))); |
| #endif |
| } |
| @@ -195,9 +456,7 @@ void MessageCenterSettingsController::SwitchToNotifierGroup(size_t index) { |
| return; |
| current_notifier_group_ = index; |
| - FOR_EACH_OBSERVER(message_center::NotifierSettingsObserver, |
| - observers_, |
| - NotifierGroupChanged()); |
| + NotifierGroupChanged(); |
| } |
| void MessageCenterSettingsController::GetNotifierList( |
| @@ -209,101 +468,13 @@ void MessageCenterSettingsController::GetNotifierList( |
| // the default profile is not loaded. |
| Profile* profile = notifier_groups_[current_notifier_group_]->profile(); |
| - NotifierStateTracker* notifier_state_tracker = |
| - NotifierStateTrackerFactory::GetForProfile(profile); |
| - |
| - const extensions::ExtensionSet& extension_set = |
| - extensions::ExtensionRegistry::Get(profile)->enabled_extensions(); |
| - // The extension icon size has to be 32x32 at least to load bigger icons if |
| - // the icon doesn't exist for the specified size, and in that case it falls |
| - // back to the default icon. The fetched icon will be resized in the settings |
| - // dialog. See chrome/browser/extensions/extension_icon_image.cc and |
| - // crbug.com/222931 |
| - app_icon_loader_.reset(new extensions::ExtensionAppIconLoader( |
| - profile, extension_misc::EXTENSION_ICON_SMALL, this)); |
| - for (extensions::ExtensionSet::const_iterator iter = extension_set.begin(); |
| - iter != extension_set.end(); |
| - ++iter) { |
| - const extensions::Extension* extension = iter->get(); |
| - if (!extension->permissions_data()->HasAPIPermission( |
| - extensions::APIPermission::kNotifications)) { |
| - continue; |
| - } |
| - |
| - // Hosted apps are no longer able to affect the notifications permission |
| - // state for web notifications. |
| - // TODO(dewittj): Deprecate the 'notifications' permission for hosted apps. |
| - if (extension->is_hosted_app()) |
| - continue; |
| - |
| - NotifierId notifier_id(NotifierId::APPLICATION, extension->id()); |
| - notifiers->push_back(new Notifier( |
| - notifier_id, |
| - base::UTF8ToUTF16(extension->name()), |
| - notifier_state_tracker->IsNotifierEnabled(notifier_id))); |
| - app_icon_loader_->FetchImage(extension->id()); |
| - } |
| - |
| - ContentSettingsForOneType settings; |
| - DesktopNotificationProfileUtil::GetNotificationsSettings(profile, &settings); |
| - |
| - favicon::FaviconService* favicon_service = |
| - FaviconServiceFactory::GetForProfile(profile, |
| - ServiceAccessType::EXPLICIT_ACCESS); |
| - favicon_tracker_.reset(new base::CancelableTaskTracker()); |
| - patterns_.clear(); |
| - for (ContentSettingsForOneType::const_iterator iter = settings.begin(); |
| - iter != settings.end(); ++iter) { |
| - if (iter->primary_pattern == ContentSettingsPattern::Wildcard() && |
| - iter->secondary_pattern == ContentSettingsPattern::Wildcard() && |
| - iter->source != "preference") { |
| - continue; |
| - } |
| - |
| - std::string url_pattern = iter->primary_pattern.ToString(); |
| - base::string16 name = base::UTF8ToUTF16(url_pattern); |
| - GURL url(url_pattern); |
| - NotifierId notifier_id(url); |
| - notifiers->push_back(new Notifier( |
| - notifier_id, |
| - name, |
| - notifier_state_tracker->IsNotifierEnabled(notifier_id))); |
| - patterns_[name] = iter->primary_pattern; |
| - // Note that favicon service obtains the favicon from history. This means |
| - // that it will fail to obtain the image if there are no history data for |
| - // that URL. |
| - favicon_service->GetFaviconImageForPageURL( |
| - url, |
| - base::Bind(&MessageCenterSettingsController::OnFaviconLoaded, |
| - base::Unretained(this), |
| - url), |
| - favicon_tracker_.get()); |
| - } |
| - |
| -#if defined(OS_CHROMEOS) |
| - // Add ARC++ apps. |
| - if (arc_notifier_manager_) { |
| - auto list = arc_notifier_manager_->GetNotifiers(profile); |
| - for (auto& notifier : list) { |
| + for (auto& source : sources_) { |
| + auto source_notifiers = source.second->GetNotifierList(profile); |
| + for (auto& notifier : source_notifiers) { |
| notifiers->push_back(notifier.release()); |
| } |
| } |
| - // Screenshot notification feature is only for ChromeOS. See crbug.com/238358 |
| - const base::string16& screenshot_name = |
| - l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_NOTIFIER_SCREENSHOT_NAME); |
| - NotifierId screenshot_notifier_id( |
| - NotifierId::SYSTEM_COMPONENT, ash::system_notifier::kNotifierScreenshot); |
| - Notifier* const screenshot_notifier = new Notifier( |
| - screenshot_notifier_id, |
| - screenshot_name, |
| - notifier_state_tracker->IsNotifierEnabled(screenshot_notifier_id)); |
| - screenshot_notifier->icon = |
| - ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| - IDR_SCREENSHOT_NOTIFICATION_ICON); |
| - notifiers->push_back(screenshot_notifier); |
| -#endif |
| - |
| UErrorCode error = U_ZERO_ERROR; |
| std::unique_ptr<icu::Collator> collator(icu::Collator::createInstance(error)); |
| std::unique_ptr<NotifierComparator> comparator( |
| @@ -318,96 +489,19 @@ void MessageCenterSettingsController::SetNotifierEnabled( |
| DCHECK_LT(current_notifier_group_, notifier_groups_.size()); |
| Profile* profile = notifier_groups_[current_notifier_group_]->profile(); |
| - switch (notifier.notifier_id.type) { |
| - case NotifierId::WEB_PAGE: { |
| - // WEB_PAGE notifier cannot handle in DesktopNotificationService |
| - // since it has the exact URL pattern. |
| - // TODO(mukai): fix this. |
| - ContentSetting default_setting = |
| - HostContentSettingsMapFactory::GetForProfile(profile) |
| - ->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| - NULL); |
| - |
| - DCHECK(default_setting == CONTENT_SETTING_ALLOW || |
| - default_setting == CONTENT_SETTING_BLOCK || |
| - default_setting == CONTENT_SETTING_ASK); |
| - |
| - // The content setting for notifications needs to clear when it changes to |
| - // the default value or get explicitly set when it differs from the |
| - // default. |
| - bool differs_from_default_value = |
| - (default_setting != CONTENT_SETTING_ALLOW && enabled) || |
| - (default_setting == CONTENT_SETTING_ALLOW && !enabled); |
| - |
| - if (differs_from_default_value) { |
| - if (notifier.notifier_id.url.is_valid()) { |
| - if (enabled) { |
| - DesktopNotificationProfileUtil::GrantPermission( |
| - profile, notifier.notifier_id.url); |
| - } else { |
| - DesktopNotificationProfileUtil::DenyPermission( |
| - profile, notifier.notifier_id.url); |
| - } |
| - } else { |
| - LOG(ERROR) << "Invalid url pattern: " |
| - << notifier.notifier_id.url.spec(); |
| - } |
| - } else { |
| - ContentSettingsPattern pattern; |
| - |
| - const auto& iter = patterns_.find(notifier.name); |
| - if (iter != patterns_.end()) { |
| - pattern = iter->second; |
| - } else if (notifier.notifier_id.url.is_valid()) { |
| - pattern = ContentSettingsPattern::FromURLNoWildcard( |
| - notifier.notifier_id.url); |
| - } else { |
| - LOG(ERROR) << "Invalid url pattern: " |
| - << notifier.notifier_id.url.spec(); |
| - } |
| - |
| - if (pattern.IsValid()) { |
| - // Note that we don't use |
| - // DesktopNotificationProfileUtil::ClearSetting() |
| - // here because pattern might be from user manual input and not match |
| - // the default one used by ClearSetting(). |
| - HostContentSettingsMapFactory::GetForProfile(profile) |
| - ->SetContentSettingCustomScope( |
| - pattern, ContentSettingsPattern::Wildcard(), |
| - CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| - content_settings::ResourceIdentifier(), |
| - CONTENT_SETTING_DEFAULT); |
| - } |
| - } |
| - break; |
| - } |
| - case NotifierId::APPLICATION: |
| - case NotifierId::SYSTEM_COMPONENT: { |
| - NotifierStateTrackerFactory::GetForProfile(profile)->SetNotifierEnabled( |
| - notifier.notifier_id, enabled); |
| - break; |
| - } |
| - case NotifierId::ARC_APPLICATION: { |
| -#if defined(OS_CHROMEOS) |
| - if (arc_notifier_manager_) { |
| - arc_notifier_manager_->SetNotifierEnabled(notifier.notifier_id.id, |
| - enabled); |
| - } |
| -#else |
| - NOTREACHED(); |
| -#endif |
| - break; |
| - } |
| + if (!sources_.count(notifier.notifier_id.type)) { |
| + NOTREACHED(); |
| + return; |
| } |
| - FOR_EACH_OBSERVER(message_center::NotifierSettingsObserver, |
| - observers_, |
| - NotifierEnabledChanged(notifier.notifier_id, enabled)); |
| + |
| + sources_[notifier.notifier_id.type]->SetNotifierEnabled(profile, notifier, |
| + enabled); |
| } |
| void MessageCenterSettingsController::OnNotifierSettingsClosing() { |
| - DCHECK(favicon_tracker_.get()); |
| - favicon_tracker_->TryCancelAll(); |
| - patterns_.clear(); |
| + for (auto& source : sources_) { |
| + source.second->OnNotifierSettingsClosing(); |
| + } |
| } |
| bool MessageCenterSettingsController::NotifierHasAdvancedSettings( |
| @@ -453,15 +547,6 @@ void MessageCenterSettingsController::OnNotifierAdvancedSettingsRequested( |
| event_router->DispatchEventToExtension(extension_id, std::move(event)); |
| } |
| -void MessageCenterSettingsController::OnFaviconLoaded( |
| - const GURL& url, |
| - const favicon_base::FaviconImageResult& favicon_result) { |
| - FOR_EACH_OBSERVER(message_center::NotifierSettingsObserver, |
| - observers_, |
| - UpdateIconImage(NotifierId(url), favicon_result.image)); |
| -} |
| - |
| - |
| #if defined(OS_CHROMEOS) |
| void MessageCenterSettingsController::ActiveUserChanged( |
| const user_manager::User* active_user) { |
| @@ -469,14 +554,6 @@ void MessageCenterSettingsController::ActiveUserChanged( |
| } |
| #endif |
| -void MessageCenterSettingsController::OnAppImageUpdated( |
| - const std::string& id, const gfx::ImageSkia& image) { |
| - FOR_EACH_OBSERVER(message_center::NotifierSettingsObserver, |
| - observers_, |
| - UpdateIconImage(NotifierId(NotifierId::APPLICATION, id), |
| - gfx::Image(image))); |
| -} |
| - |
| void MessageCenterSettingsController::Observe( |
| int type, |
| const content::NotificationSource& source, |
| @@ -510,6 +587,25 @@ void MessageCenterSettingsController::OnProfileAuthInfoChanged( |
| RebuildNotifierGroups(true); |
| } |
| +void MessageCenterSettingsController::UpdateIconImage( |
| + const message_center::NotifierId& id, |
| + const gfx::Image& image) { |
| + FOR_EACH_OBSERVER(message_center::NotifierSettingsObserver, observers_, |
| + UpdateIconImage(id, image)); |
| +} |
| + |
| +void MessageCenterSettingsController::NotifierGroupChanged() { |
| + FOR_EACH_OBSERVER(message_center::NotifierSettingsObserver, observers_, |
| + NotifierGroupChanged()); |
| +} |
| + |
| +void MessageCenterSettingsController::NotifierEnabledChanged( |
| + const message_center::NotifierId& id, |
| + bool enabled) { |
| + FOR_EACH_OBSERVER(message_center::NotifierSettingsObserver, observers_, |
| + NotifierEnabledChanged(id, enabled)); |
| +} |
| + |
| #if defined(OS_CHROMEOS) |
| void MessageCenterSettingsController::CreateNotifierGroupForGuestLogin() { |
| // Already created. |
| @@ -532,10 +628,7 @@ void MessageCenterSettingsController::CreateNotifierGroupForGuestLogin() { |
| user->GetDisplayName(), profile)); |
| notifier_groups_.push_back(std::move(group)); |
| - |
| - FOR_EACH_OBSERVER(message_center::NotifierSettingsObserver, |
| - observers_, |
| - NotifierGroupChanged()); |
| + NotifierGroupChanged(); |
| } |
| #endif |
| @@ -595,9 +688,6 @@ void MessageCenterSettingsController::RebuildNotifierGroups(bool notify) { |
| } |
| #endif |
| - if (notify) { |
| - FOR_EACH_OBSERVER(message_center::NotifierSettingsObserver, |
| - observers_, |
| - NotifierGroupChanged()); |
| - } |
| + if (notify) |
| + NotifierGroupChanged(); |
| } |