1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "base/logging.h" 6 #include "ui/message_center/notifier_settings.h" 7 8 namespace message_center { 9 10 NotifierId::NotifierId(NotifierType type, 11 const std::string& id) 12 : type(type), 13 id(id), 14 system_component_type(NONE) { 15 DCHECK(type == APPLICATION || type == SYNCED_NOTIFICATION_SERVICE); 16 } 17 18 NotifierId::NotifierId(const GURL& url) 19 : type(WEB_PAGE), url(url), system_component_type(NONE) {} 20 21 NotifierId::NotifierId(SystemComponentNotifierType system_component_type) 22 : type(SYSTEM_COMPONENT), system_component_type(system_component_type) {} 23 24 bool NotifierId::operator==(const NotifierId& other) const { 25 if (type != other.type) 26 return false; 27 28 switch (type) { 29 case WEB_PAGE: 30 return url == other.url; 31 case SYSTEM_COMPONENT: 32 return system_component_type == other.system_component_type; 33 case APPLICATION: 34 case SYNCED_NOTIFICATION_SERVICE: 35 return id == other.id; 36 } 37 38 NOTREACHED(); 39 return false; 40 } 41 42 Notifier::Notifier(const NotifierId& notifier_id, 43 const string16& name, 44 bool enabled) 45 : notifier_id(notifier_id), 46 name(name), 47 enabled(enabled) { 48 } 49 50 Notifier::~Notifier() { 51 } 52 53 NotifierGroup::NotifierGroup(const gfx::Image& icon, 54 const string16& name, 55 const string16& login_info, 56 size_t index) 57 : icon(icon), name(name), login_info(login_info), index(index) {} 58 59 NotifierGroup::~NotifierGroup() {} 60 61 std::string ToString(NotifierId::SystemComponentNotifierType type) { 62 switch (type) { 63 case NotifierId::SCREENSHOT: 64 return "screenshot"; 65 default: 66 NOTREACHED(); 67 return ""; 68 } 69 } 70 71 NotifierId::SystemComponentNotifierType 72 ParseSystemComponentName(const std::string& name) { 73 if (name == "screenshot") { 74 return NotifierId::SCREENSHOT; 75 } else { 76 NOTREACHED(); 77 return NotifierId::NONE; 78 } 79 } 80 } // namespace message_center 81