Commit d6d837f5 authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

NotifierSource cleanup.

- Remove unused function NotifierSource::GetNotifierType
- Rename NotifierSource to NotifierController
- Add docs

Bug: 755413
Change-Id: Ib214b452548c348661569fe4496a06e67004809e
Reviewed-on: https://chromium-review.googlesource.com/682108Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#505266}
parent 4731f0a3
......@@ -3325,10 +3325,10 @@ split_static_library("browser") {
"metrics/tab_usage_recorder.h",
"net/firefox_proxy_settings.cc",
"net/firefox_proxy_settings.h",
"notifications/application_notifier_source.cc",
"notifications/application_notifier_source.h",
"notifications/arc_application_notifier_source_chromeos.cc",
"notifications/arc_application_notifier_source_chromeos.h",
"notifications/arc_application_notifier_controller_chromeos.cc",
"notifications/arc_application_notifier_controller_chromeos.h",
"notifications/extension_notifier_controller.cc",
"notifications/extension_notifier_controller.h",
"notifications/message_center_notification_manager.cc",
"notifications/message_center_notification_manager.h",
"notifications/message_center_settings_controller.cc",
......@@ -3338,13 +3338,13 @@ split_static_library("browser") {
"notifications/notification_system_observer.cc",
"notifications/notification_system_observer.h",
"notifications/notification_ui_manager_desktop.cc",
"notifications/notifier_source.h",
"notifications/notifier_controller.h",
"notifications/profile_notification.cc",
"notifications/profile_notification.h",
"notifications/system_component_notifier_source_chromeos.cc",
"notifications/system_component_notifier_source_chromeos.h",
"notifications/web_page_notifier_source.cc",
"notifications/web_page_notifier_source.h",
"notifications/system_component_notifier_controller_chromeos.cc",
"notifications/system_component_notifier_controller_chromeos.h",
"notifications/web_page_notifier_controller.cc",
"notifications/web_page_notifier_controller.h",
"obsolete_system/obsolete_system.h",
"obsolete_system/obsolete_system_linux.cc",
"obsolete_system/obsolete_system_mac.cc",
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/notifications/arc_application_notifier_source_chromeos.h"
#include "chrome/browser/notifications/arc_application_notifier_controller_chromeos.h"
#include <set>
......@@ -19,16 +19,18 @@ namespace {
constexpr int kArcAppIconSizeInDp = 48;
} // namespace
ArcApplicationNotifierSourceChromeOS::ArcApplicationNotifierSourceChromeOS(
NotifierSource::Observer* observer)
ArcApplicationNotifierControllerChromeOS::
ArcApplicationNotifierControllerChromeOS(
NotifierController::Observer* observer)
: observer_(observer), last_profile_(nullptr) {}
ArcApplicationNotifierSourceChromeOS::~ArcApplicationNotifierSourceChromeOS() {
ArcApplicationNotifierControllerChromeOS::
~ArcApplicationNotifierControllerChromeOS() {
StopObserving();
}
std::vector<std::unique_ptr<message_center::Notifier>>
ArcApplicationNotifierSourceChromeOS::GetNotifierList(Profile* profile) {
ArcApplicationNotifierControllerChromeOS::GetNotifierList(Profile* profile) {
package_to_app_ids_.clear();
icons_.clear();
StopObserving();
......@@ -79,7 +81,7 @@ ArcApplicationNotifierSourceChromeOS::GetNotifierList(Profile* profile) {
return results;
}
void ArcApplicationNotifierSourceChromeOS::SetNotifierEnabled(
void ArcApplicationNotifierControllerChromeOS::SetNotifierEnabled(
Profile* profile,
const message_center::NotifierId& notifier_id,
bool enabled) {
......@@ -88,7 +90,7 @@ void ArcApplicationNotifierSourceChromeOS::SetNotifierEnabled(
// OnNotifierEnabledChanged will be invoked via ArcAppListPrefs::Observer.
}
void ArcApplicationNotifierSourceChromeOS::OnNotificationsEnabledChanged(
void ArcApplicationNotifierControllerChromeOS::OnNotificationsEnabledChanged(
const std::string& package_name,
bool enabled) {
auto it = package_to_app_ids_.find(package_name);
......@@ -100,25 +102,20 @@ void ArcApplicationNotifierSourceChromeOS::OnNotificationsEnabledChanged(
enabled);
}
void ArcApplicationNotifierSourceChromeOS::OnNotifierSettingsClosing() {
void ArcApplicationNotifierControllerChromeOS::OnNotifierSettingsClosing() {
icons_.clear();
package_to_app_ids_.clear();
StopObserving();
}
message_center::NotifierId::NotifierType
ArcApplicationNotifierSourceChromeOS::GetNotifierType() {
return message_center::NotifierId::ARC_APPLICATION;
}
void ArcApplicationNotifierSourceChromeOS::OnIconUpdated(ArcAppIcon* icon) {
void ArcApplicationNotifierControllerChromeOS::OnIconUpdated(ArcAppIcon* icon) {
observer_->OnIconImageUpdated(
message_center::NotifierId(message_center::NotifierId::ARC_APPLICATION,
icon->app_id()),
gfx::Image(icon->image_skia()));
}
void ArcApplicationNotifierSourceChromeOS::StopObserving() {
void ArcApplicationNotifierControllerChromeOS::StopObserving() {
if (!last_profile_)
return;
ArcAppListPrefs* const app_list = ArcAppListPrefs::Get(last_profile_);
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_NOTIFICATIONS_ARC_APPLICATION_NOTIFIER_SOURCE_CHROMEOS_H_
#define CHROME_BROWSER_NOTIFICATIONS_ARC_APPLICATION_NOTIFIER_SOURCE_CHROMEOS_H_
#ifndef CHROME_BROWSER_NOTIFICATIONS_ARC_APPLICATION_NOTIFIER_CONTROLLER_CHROMEOS_H_
#define CHROME_BROWSER_NOTIFICATIONS_ARC_APPLICATION_NOTIFIER_CONTROLLER_CHROMEOS_H_
#include <map>
#include <memory>
......@@ -11,7 +11,7 @@
#include <vector>
#include "base/macros.h"
#include "chrome/browser/notifications/notifier_source.h"
#include "chrome/browser/notifications/notifier_controller.h"
#include "chrome/browser/ui/app_list/arc/arc_app_icon.h"
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
......@@ -24,14 +24,15 @@ struct Notifier;
namespace arc {
// TODO(hirono): Observe enabled flag change and notify it to message center.
class ArcApplicationNotifierSourceChromeOS : public NotifierSource,
public ArcAppIcon::Observer,
public ArcAppListPrefs::Observer {
class ArcApplicationNotifierControllerChromeOS
: public NotifierController,
public ArcAppIcon::Observer,
public ArcAppListPrefs::Observer {
public:
explicit ArcApplicationNotifierSourceChromeOS(
NotifierSource::Observer* observer);
explicit ArcApplicationNotifierControllerChromeOS(
NotifierController::Observer* observer);
~ArcApplicationNotifierSourceChromeOS() override;
~ArcApplicationNotifierControllerChromeOS() override;
// TODO(hirono): Rewrite the function with new API to fetch package list.
std::vector<std::unique_ptr<message_center::Notifier>> GetNotifierList(
......@@ -40,7 +41,6 @@ class ArcApplicationNotifierSourceChromeOS : public NotifierSource,
const message_center::NotifierId& notifier_id,
bool enabled) override;
void OnNotifierSettingsClosing() override;
message_center::NotifierId::NotifierType GetNotifierType() override;
private:
// Overriden from ArcAppIcon::Observer.
......@@ -51,7 +51,7 @@ class ArcApplicationNotifierSourceChromeOS : public NotifierSource,
void OnNotificationsEnabledChanged(const std::string& package_name,
bool enabled) override;
NotifierSource::Observer* observer_;
NotifierController::Observer* observer_;
std::vector<std::unique_ptr<ArcAppIcon>> icons_;
std::map<std::string, std::string> package_to_app_ids_;
Profile* last_profile_;
......@@ -59,4 +59,4 @@ class ArcApplicationNotifierSourceChromeOS : public NotifierSource,
} // namespace arc
#endif // CHROME_BROWSER_NOTIFICATIONS_ARC_APPLICATION_NOTIFIER_SOURCE_CHROMEOS_H_
#endif // CHROME_BROWSER_NOTIFICATIONS_ARC_APPLICATION_NOTIFIER_CONTROLLER_CHROMEOS_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/notifications/application_notifier_source.h"
#include "chrome/browser/notifications/extension_notifier_controller.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/extensions/chrome_app_icon_loader.h"
......@@ -15,13 +15,13 @@
#include "extensions/common/permissions/permissions_data.h"
#include "ui/message_center/notifier_settings.h"
ApplicationNotifierSource::ApplicationNotifierSource(Observer* observer)
ExtensionNotifierController::ExtensionNotifierController(Observer* observer)
: observer_(observer) {}
ApplicationNotifierSource::~ApplicationNotifierSource() {}
ExtensionNotifierController::~ExtensionNotifierController() {}
std::vector<std::unique_ptr<message_center::Notifier>>
ApplicationNotifierSource::GetNotifierList(Profile* profile) {
ExtensionNotifierController::GetNotifierList(Profile* profile) {
std::vector<std::unique_ptr<message_center::Notifier>> notifiers;
const extensions::ExtensionSet& extension_set =
extensions::ExtensionRegistry::Get(profile)->enabled_extensions();
......@@ -60,7 +60,7 @@ ApplicationNotifierSource::GetNotifierList(Profile* profile) {
return notifiers;
}
void ApplicationNotifierSource::SetNotifierEnabled(
void ExtensionNotifierController::SetNotifierEnabled(
Profile* profile,
const message_center::NotifierId& notifier_id,
bool enabled) {
......@@ -69,13 +69,9 @@ void ApplicationNotifierSource::SetNotifierEnabled(
observer_->OnNotifierEnabledChanged(notifier_id, enabled);
}
message_center::NotifierId::NotifierType
ApplicationNotifierSource::GetNotifierType() {
return message_center::NotifierId::APPLICATION;
}
void ApplicationNotifierSource::OnAppImageUpdated(const std::string& id,
const gfx::ImageSkia& image) {
void ExtensionNotifierController::OnAppImageUpdated(
const std::string& id,
const gfx::ImageSkia& image) {
observer_->OnIconImageUpdated(
message_center::NotifierId(message_center::NotifierId::APPLICATION, id),
gfx::Image(image));
......
......@@ -2,19 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_NOTIFICATIONS_APPLICATION_NOTIFIER_SOURCE_H_
#define CHROME_BROWSER_NOTIFICATIONS_APPLICATION_NOTIFIER_SOURCE_H_
#ifndef CHROME_BROWSER_NOTIFICATIONS_EXTENSION_NOTIFIER_CONTROLLER_H_
#define CHROME_BROWSER_NOTIFICATIONS_EXTENSION_NOTIFIER_CONTROLLER_H_
#include "chrome/browser/notifications/notifier_source.h"
#include "chrome/browser/notifications/notifier_controller.h"
#include "chrome/browser/ui/app_icon_loader_delegate.h"
class AppIconLoader;
class ApplicationNotifierSource : public NotifierSource,
public AppIconLoaderDelegate {
// Controls extensions and apps. Each extension gets its own row in the settings
// ui.
class ExtensionNotifierController : public NotifierController,
public AppIconLoaderDelegate {
public:
explicit ApplicationNotifierSource(Observer* observer);
~ApplicationNotifierSource() override;
explicit ExtensionNotifierController(Observer* observer);
~ExtensionNotifierController() override;
std::vector<std::unique_ptr<message_center::Notifier>> GetNotifierList(
Profile* profile) override;
......@@ -23,8 +25,6 @@ class ApplicationNotifierSource : public NotifierSource,
const message_center::NotifierId& notifier_id,
bool enabled) override;
message_center::NotifierId::NotifierType GetNotifierType() override;
private:
// Overridden from AppIconLoaderDelegate.
void OnAppImageUpdated(const std::string& id,
......@@ -36,4 +36,4 @@ class ApplicationNotifierSource : public NotifierSource,
Observer* observer_;
};
#endif // CHROME_BROWSER_NOTIFICATIONS_APPLICATION_NOTIFIER_SOURCE_H_
#endif // CHROME_BROWSER_NOTIFICATIONS_EXTENSION_NOTIFIER_CONTROLLER_H_
......@@ -16,8 +16,8 @@
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/notifications/application_notifier_source.h"
#include "chrome/browser/notifications/web_page_notifier_source.h"
#include "chrome/browser/notifications/extension_notifier_controller.h"
#include "chrome/browser/notifications/web_page_notifier_controller.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_attributes_entry.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
......@@ -30,8 +30,8 @@
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/notifications/arc_application_notifier_source_chromeos.h"
#include "chrome/browser/notifications/system_component_notifier_source_chromeos.h"
#include "chrome/browser/notifications/arc_application_notifier_controller_chromeos.h"
#include "chrome/browser/notifications/system_component_notifier_controller_chromeos.h"
#endif
using message_center::Notifier;
......@@ -58,7 +58,8 @@ class ProfileNotifierGroup : public message_center::NotifierGroup {
ProfileNotifierGroup::ProfileNotifierGroup(const base::string16& display_name,
const base::string16& login_info,
const base::FilePath& profile_path)
: message_center::NotifierGroup(display_name, login_info), profile_(NULL) {
: message_center::NotifierGroup(display_name, login_info),
profile_(nullptr) {
// Try to get the profile
profile_ =
g_browser_process->profile_manager()->GetProfileByPath(profile_path);
......@@ -104,26 +105,23 @@ MessageCenterSettingsController::MessageCenterSettingsController(
profile_attributes_storage_.AddObserver(this);
RebuildNotifierGroups(false);
sources_.insert(
std::make_pair(NotifierId::APPLICATION,
std::make_unique<ExtensionNotifierController>(this)));
sources_.insert(std::make_pair(
NotifierId::APPLICATION,
std::unique_ptr<NotifierSource>(new ApplicationNotifierSource(this))));
sources_.insert(std::make_pair(
NotifierId::WEB_PAGE,
std::unique_ptr<NotifierSource>(new WebPageNotifierSource(this))));
NotifierId::WEB_PAGE, std::make_unique<WebPageNotifierController>(this)));
#if defined(OS_CHROMEOS)
// UserManager may not exist in some tests.
if (user_manager::UserManager::IsInitialized())
user_manager::UserManager::Get()->AddSessionStateObserver(this);
// For system components.
sources_.insert(
std::make_pair(NotifierId::SYSTEM_COMPONENT,
std::unique_ptr<NotifierSource>(
new SystemComponentNotifierSourceChromeOS(this))));
sources_.insert(
std::make_pair(NotifierId::ARC_APPLICATION,
std::unique_ptr<NotifierSource>(
new arc::ArcApplicationNotifierSourceChromeOS(this))));
sources_.insert(std::make_pair(
NotifierId::SYSTEM_COMPONENT,
std::make_unique<SystemComponentNotifierControllerChromeOS>(this)));
sources_.insert(std::make_pair(
NotifierId::ARC_APPLICATION,
std::make_unique<arc::ArcApplicationNotifierControllerChromeOS>(this)));
#endif
}
......@@ -194,7 +192,7 @@ void MessageCenterSettingsController::GetNotifierList(
UErrorCode error = U_ZERO_ERROR;
std::unique_ptr<icu::Collator> collator(icu::Collator::createInstance(error));
NotifierComparator comparator(U_SUCCESS(error) ? collator.get() : NULL);
NotifierComparator comparator(U_SUCCESS(error) ? collator.get() : nullptr);
std::sort(notifiers->begin(), notifiers->end(), comparator);
}
......@@ -258,12 +256,12 @@ void MessageCenterSettingsController::OnNotifierAdvancedSettingsRequested(
Profile* profile = notifier_groups_[current_notifier_group_]->profile();
extensions::EventRouter* event_router = extensions::EventRouter::Get(profile);
std::unique_ptr<base::ListValue> args(new base::ListValue());
auto args = std::make_unique<base::ListValue>();
std::unique_ptr<extensions::Event> event(new extensions::Event(
auto event = std::make_unique<extensions::Event>(
extensions::events::NOTIFICATIONS_ON_SHOW_SETTINGS,
extensions::api::notifications::OnShowSettings::kEventName,
std::move(args)));
std::move(args));
event_router->DispatchEventToExtension(extension_id, std::move(event));
}
......@@ -332,9 +330,8 @@ void MessageCenterSettingsController::CreateNotifierGroupForGuestLogin() {
chromeos::ProfileHelper::Get()->GetProfileByUserUnsafe(user);
DCHECK(profile);
std::unique_ptr<message_center::ProfileNotifierGroup> group(
new message_center::ProfileNotifierGroup(
user->GetDisplayName(), user->GetDisplayName(), profile));
auto group = std::make_unique<message_center::ProfileNotifierGroup>(
user->GetDisplayName(), user->GetDisplayName(), profile);
notifier_groups_.push_back(std::move(group));
DispatchNotifierGroupChanged();
......@@ -348,10 +345,9 @@ void MessageCenterSettingsController::RebuildNotifierGroups(bool notify) {
std::vector<ProfileAttributesEntry*> entries =
profile_attributes_storage_.GetAllProfilesAttributesSortedByName();
for (auto* entry : entries) {
std::unique_ptr<message_center::ProfileNotifierGroup> group(
new message_center::ProfileNotifierGroup(
entry->GetName(), entry->GetUserName(), entry->GetPath()));
if (group->profile() == NULL)
auto group = std::make_unique<message_center::ProfileNotifierGroup>(
entry->GetName(), entry->GetUserName(), entry->GetPath());
if (!group->profile())
continue;
#if defined(OS_CHROMEOS)
......
......@@ -15,7 +15,7 @@
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "build/build_config.h"
#include "chrome/browser/notifications/notifier_source.h"
#include "chrome/browser/notifications/notifier_controller.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/ui/app_icon_loader.h"
#include "components/content_settings/core/common/content_settings.h"
......@@ -26,7 +26,7 @@
#include "components/user_manager/user_manager.h"
#endif
class NotifierSource;
class NotifierController;
namespace message_center {
class ProfileNotifierGroup;
......@@ -40,7 +40,7 @@ class MessageCenterSettingsController
#if defined(OS_CHROMEOS)
public user_manager::UserManager::UserSessionStateObserver,
#endif
public NotifierSource::Observer {
public NotifierController::Observer {
public:
explicit MessageCenterSettingsController(
ProfileAttributesStorage& profile_attributes_storage);
......@@ -81,7 +81,7 @@ class MessageCenterSettingsController
const base::string16& old_profile_name) override;
void OnProfileAuthInfoChanged(const base::FilePath& profile_path) override;
// Overridden from NotifierSource::Observer.
// Overridden from NotifierController::Observer.
void OnIconImageUpdated(const message_center::NotifierId&,
const gfx::Image&) override;
void OnNotifierEnabledChanged(const message_center::NotifierId&,
......@@ -112,7 +112,7 @@ class MessageCenterSettingsController
// Notifier source for each notifier type.
std::map<message_center::NotifierId::NotifierType,
std::unique_ptr<NotifierSource>>
std::unique_ptr<NotifierController>>
sources_;
size_t current_notifier_group_;
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFIER_SOURCE_H_
#define CHROME_BROWSER_NOTIFICATIONS_NOTIFIER_SOURCE_H_
#ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFIER_CONTROLLER_H_
#define CHROME_BROWSER_NOTIFICATIONS_NOTIFIER_CONTROLLER_H_
#include <memory>
#include <vector>
......@@ -17,7 +17,10 @@ namespace message_center {
struct Notifier;
}
class NotifierSource {
// An interface to control Notifiers, grouped by NotifierType. Controllers are
// responsible for both collating display data and toggling settings in response
// to user inputs.
class NotifierController {
public:
class Observer {
public:
......@@ -27,11 +30,11 @@ class NotifierSource {
bool enabled) = 0;
};
NotifierSource() = default;
virtual ~NotifierSource() = default;
NotifierController() = default;
virtual ~NotifierController() = default;
// Returns notifiers.
// If the source starts loading for icon images, it needs to call
// Returns notifiers to display in the settings UI. Not all notifiers appear
// in settings. If the source starts loading for icon images, it needs to call
// Observer::OnIconImageUpdated after the icon is loaded.
virtual std::vector<std::unique_ptr<message_center::Notifier>>
GetNotifierList(Profile* profile) = 0;
......@@ -47,11 +50,8 @@ class NotifierSource {
// time.
virtual void OnNotifierSettingsClosing() {}
// Notifier type provided by the source.
virtual message_center::NotifierId::NotifierType GetNotifierType() = 0;
private:
DISALLOW_COPY_AND_ASSIGN(NotifierSource);
DISALLOW_COPY_AND_ASSIGN(NotifierController);
};
#endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFIER_SOURCE_H_
#endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFIER_CONTROLLER_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/notifications/system_component_notifier_source_chromeos.h"
#include "chrome/browser/notifications/system_component_notifier_controller_chromeos.h"
#include "ash/system/system_notifier.h"
#include "chrome/browser/notifications/notifier_state_tracker.h"
......@@ -13,12 +13,12 @@
#include "ui/message_center/notifier_settings.h"
#include "ui/strings/grit/ui_strings.h"
SystemComponentNotifierSourceChromeOS::SystemComponentNotifierSourceChromeOS(
Observer* observer)
SystemComponentNotifierControllerChromeOS::
SystemComponentNotifierControllerChromeOS(Observer* observer)
: observer_(observer) {}
std::vector<std::unique_ptr<message_center::Notifier>>
SystemComponentNotifierSourceChromeOS::GetNotifierList(Profile* profile) {
SystemComponentNotifierControllerChromeOS::GetNotifierList(Profile* profile) {
std::vector<std::unique_ptr<message_center::Notifier>> notifiers;
NotifierStateTracker* const notifier_state_tracker =
NotifierStateTrackerFactory::GetForProfile(profile);
......@@ -41,7 +41,7 @@ SystemComponentNotifierSourceChromeOS::GetNotifierList(Profile* profile) {
return notifiers;
}
void SystemComponentNotifierSourceChromeOS::SetNotifierEnabled(
void SystemComponentNotifierControllerChromeOS::SetNotifierEnabled(
Profile* profile,
const message_center::NotifierId& notifier_id,
bool enabled) {
......@@ -49,8 +49,3 @@ void SystemComponentNotifierSourceChromeOS::SetNotifierEnabled(
notifier_id, enabled);
observer_->OnNotifierEnabledChanged(notifier_id, enabled);
}
message_center::NotifierId::NotifierType
SystemComponentNotifierSourceChromeOS::GetNotifierType() {
return message_center::NotifierId::SYSTEM_COMPONENT;
}
......@@ -2,24 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_NOTIFICATIONS_SYSTEM_COMPONENT_NOTIFIER_SOURCE_CHROMEOS_H_
#define CHROME_BROWSER_NOTIFICATIONS_SYSTEM_COMPONENT_NOTIFIER_SOURCE_CHROMEOS_H_
#ifndef CHROME_BROWSER_NOTIFICATIONS_SYSTEM_COMPONENT_NOTIFIER_CONTROLLER_CHROMEOS_H_
#define CHROME_BROWSER_NOTIFICATIONS_SYSTEM_COMPONENT_NOTIFIER_CONTROLLER_CHROMEOS_H_
#include "chrome/browser/notifications/notifier_source.h"
#include "chrome/browser/notifications/notifier_controller.h"
class SystemComponentNotifierSourceChromeOS : public NotifierSource {
// TODO(estade): remove this class. See crbug.com/766846
class SystemComponentNotifierControllerChromeOS : public NotifierController {
public:
explicit SystemComponentNotifierSourceChromeOS(Observer* observer);
explicit SystemComponentNotifierControllerChromeOS(Observer* observer);
std::vector<std::unique_ptr<message_center::Notifier>> GetNotifierList(
Profile* profile) override;
void SetNotifierEnabled(Profile* profile,
const message_center::NotifierId& notifier_id,
bool enabled) override;
message_center::NotifierId::NotifierType GetNotifierType() override;
private:
// Lifetime of parent must be longer than the source.
Observer* observer_;
};
#endif // CHROME_BROWSER_NOTIFICATIONS_SYSTEM_COMPONENT_NOTIFIER_SOURCE_CHROMEOS_H_
#endif // CHROME_BROWSER_NOTIFICATIONS_SYSTEM_COMPONENT_NOTIFIER_CONTROLLER_CHROMEOS_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/notifications/web_page_notifier_source.h"
#include "chrome/browser/notifications/web_page_notifier_controller.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/cancelable_task_tracker.h"
......@@ -15,13 +15,13 @@
#include "components/content_settings/core/common/content_settings.h"
#include "components/favicon/core/favicon_service.h"
WebPageNotifierSource::WebPageNotifierSource(Observer* observer)
WebPageNotifierController::WebPageNotifierController(Observer* observer)
: observer_(observer) {}
WebPageNotifierSource::~WebPageNotifierSource() {}
WebPageNotifierController::~WebPageNotifierController() {}
std::vector<std::unique_ptr<message_center::Notifier>>
WebPageNotifierSource::GetNotifierList(Profile* profile) {
WebPageNotifierController::GetNotifierList(Profile* profile) {
std::vector<std::unique_ptr<message_center::Notifier>> notifiers;
ContentSettingsForOneType settings;
......@@ -55,7 +55,7 @@ WebPageNotifierSource::GetNotifierList(Profile* profile) {
// that URL.
favicon_service->GetFaviconImageForPageURL(
url,
base::Bind(&WebPageNotifierSource::OnFaviconLoaded,
base::Bind(&WebPageNotifierController::OnFaviconLoaded,
base::Unretained(this), url),
favicon_tracker_.get());
}
......@@ -63,7 +63,7 @@ WebPageNotifierSource::GetNotifierList(Profile* profile) {
return notifiers;
}
void WebPageNotifierSource::SetNotifierEnabled(
void WebPageNotifierController::SetNotifierEnabled(
Profile* profile,
const message_center::NotifierId& notifier_id,
bool enabled) {
......@@ -127,18 +127,13 @@ void WebPageNotifierSource::SetNotifierEnabled(
observer_->OnNotifierEnabledChanged(notifier_id, enabled);
}
void WebPageNotifierSource::OnNotifierSettingsClosing() {
void WebPageNotifierController::OnNotifierSettingsClosing() {
DCHECK(favicon_tracker_.get());
favicon_tracker_->TryCancelAll();
patterns_.clear();
}
message_center::NotifierId::NotifierType
WebPageNotifierSource::GetNotifierType() {
return message_center::NotifierId::WEB_PAGE;
}
void WebPageNotifierSource::OnFaviconLoaded(
void WebPageNotifierController::OnFaviconLoaded(
const GURL& url,
const favicon_base::FaviconImageResult& favicon_result) {
observer_->OnIconImageUpdated(message_center::NotifierId(url),
......
......@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_NOTIFICATIONS_WEB_PAGE_NOTIFIER_SOURCE_H_
#define CHROME_BROWSER_NOTIFICATIONS_WEB_PAGE_NOTIFIER_SOURCE_H_
#ifndef CHROME_BROWSER_NOTIFICATIONS_WEB_PAGE_NOTIFIER_CONTROLLER_H_
#define CHROME_BROWSER_NOTIFICATIONS_WEB_PAGE_NOTIFIER_CONTROLLER_H_
#include "chrome/browser/notifications/notifier_source.h"
#include "chrome/browser/notifications/notifier_controller.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
namespace base {
......@@ -16,10 +16,10 @@ namespace favicon_base {
struct FaviconImageResult;
}
class WebPageNotifierSource : public NotifierSource {
class WebPageNotifierController : public NotifierController {
public:
explicit WebPageNotifierSource(Observer* observer);
~WebPageNotifierSource() override;
explicit WebPageNotifierController(Observer* observer);
~WebPageNotifierController() override;
std::vector<std::unique_ptr<message_center::Notifier>> GetNotifierList(
Profile* profile) override;
......@@ -30,8 +30,6 @@ class WebPageNotifierSource : public NotifierSource {
void OnNotifierSettingsClosing() override;
message_center::NotifierId::NotifierType GetNotifierType() override;
private:
void OnFaviconLoaded(const GURL& url,
const favicon_base::FaviconImageResult& favicon_result);
......@@ -45,4 +43,4 @@ class WebPageNotifierSource : public NotifierSource {
Observer* observer_;
};
#endif // CHROME_BROWSER_NOTIFICATIONS_WEB_PAGE_NOTIFIER_SOURCE_H_
#endif // CHROME_BROWSER_NOTIFICATIONS_WEB_PAGE_NOTIFIER_CONTROLLER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment