summaryrefslogtreecommitdiffstats
path: root/ui/message_center/notifier_settings.cc
diff options
context:
space:
mode:
authormukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-02 23:04:00 +0000
committermukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-02 23:04:00 +0000
commitf0e2a92949258398ada7e5d7ecf4dfe475125c70 (patch)
treef599a4b1bf893ceb7f561f3715623e5603c51ca4 /ui/message_center/notifier_settings.cc
parentf7c01c80f61b976448dab73c5a70afbd728f8fcd (diff)
downloadchromium_src-f0e2a92949258398ada7e5d7ecf4dfe475125c70.zip
chromium_src-f0e2a92949258398ada7e5d7ecf4dfe475125c70.tar.gz
chromium_src-f0e2a92949258398ada7e5d7ecf4dfe475125c70.tar.bz2
Introduces sync notifiers as settings items.
BUG=245412 R=dewittj@chromium.org, petewil@chromium.org, sky@chromium.org, zea@chromium.org Review URL: https://codereview.chromium.org/16407002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209806 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/message_center/notifier_settings.cc')
-rw-r--r--ui/message_center/notifier_settings.cc64
1 files changed, 39 insertions, 25 deletions
diff --git a/ui/message_center/notifier_settings.cc b/ui/message_center/notifier_settings.cc
index 194c629..85c6097 100644
--- a/ui/message_center/notifier_settings.cc
+++ b/ui/message_center/notifier_settings.cc
@@ -2,58 +2,72 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/logging.h"
#include "ui/message_center/notifier_settings.h"
namespace message_center {
-Notifier::Notifier(const std::string& id,
- const string16& name,
- bool enabled)
- : id(id),
- system_component_type(NONE),
- name(name),
- enabled(enabled),
- type(APPLICATION) {
+NotifierId::NotifierId(NotifierType type,
+ const std::string& id)
+ : type(type),
+ id(id),
+ system_component_type(NONE) {
+ DCHECK(type == APPLICATION || type == SYNCED_NOTIFICATION_SERVICE);
}
-Notifier::Notifier(const GURL& url, const string16& name, bool enabled)
- : url(url),
- system_component_type(NONE),
- name(name),
- enabled(enabled),
- type(WEB_PAGE) {
+NotifierId::NotifierId(const GURL& url)
+ : type(WEB_PAGE), url(url), system_component_type(NONE) {}
+
+NotifierId::NotifierId(SystemComponentNotifierType system_component_type)
+ : type(SYSTEM_COMPONENT), system_component_type(system_component_type) {}
+
+bool NotifierId::operator==(const NotifierId& other) const {
+ if (type != other.type)
+ return false;
+
+ switch (type) {
+ case WEB_PAGE:
+ return url == other.url;
+ case SYSTEM_COMPONENT:
+ return system_component_type == other.system_component_type;
+ case APPLICATION:
+ case SYNCED_NOTIFICATION_SERVICE:
+ return id == other.id;
+ }
+
+ NOTREACHED();
+ return false;
}
-Notifier::Notifier(SystemComponentNotifierType system_component_type,
+Notifier::Notifier(const NotifierId& notifier_id,
const string16& name,
bool enabled)
- : system_component_type(system_component_type),
+ : notifier_id(notifier_id),
name(name),
- enabled(enabled),
- type(SYSTEM_COMPONENT) {
+ enabled(enabled) {
}
Notifier::~Notifier() {
}
std::string ToString(
- Notifier::SystemComponentNotifierType type) {
+ NotifierId::SystemComponentNotifierType type) {
switch (type) {
- case Notifier::SCREENSHOT:
+ case NotifierId::SCREENSHOT:
return "screenshot";
default:
- DCHECK(false);
+ NOTREACHED();
return "";
}
}
-Notifier::SystemComponentNotifierType
+NotifierId::SystemComponentNotifierType
ParseSystemComponentName(const std::string& name) {
if (name == "screenshot") {
- return Notifier::SCREENSHOT;
+ return NotifierId::SCREENSHOT;
} else {
- DCHECK(false);
- return Notifier::NONE;
+ NOTREACHED();
+ return NotifierId::NONE;
}
}
} // namespace message_center