diff options
Diffstat (limited to 'ui/message_center/notifier_settings.cc')
-rw-r--r-- | ui/message_center/notifier_settings.cc | 64 |
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 |