Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / message_center / fake_notifier_settings_provider.cc
blob79c153a878349f9e81e8e554ab106ff070619544
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.
5 #include "ui/message_center/fake_notifier_settings_provider.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "ui/gfx/image/image.h"
10 namespace message_center {
12 FakeNotifierSettingsProvider::NotifierGroupItem::NotifierGroupItem() {
15 FakeNotifierSettingsProvider::NotifierGroupItem::~NotifierGroupItem() {
18 FakeNotifierSettingsProvider::FakeNotifierSettingsProvider()
19 : closed_called_count_(0),
20 active_item_index_(0),
21 notifier_settings_requested_count_(0u) { }
23 FakeNotifierSettingsProvider::FakeNotifierSettingsProvider(
24 const std::vector<Notifier*>& notifiers)
25 : closed_called_count_(0),
26 active_item_index_(0),
27 notifier_settings_requested_count_(0u) {
28 NotifierGroupItem item;
29 item.group = new NotifierGroup(gfx::Image(),
30 base::UTF8ToUTF16("Fake name"),
31 base::UTF8ToUTF16("fake@email.com"),
32 true);
33 item.notifiers = notifiers;
34 items_.push_back(item);
37 FakeNotifierSettingsProvider::~FakeNotifierSettingsProvider() {
38 for (size_t i = 0; i < items_.size(); ++i) {
39 delete items_[i].group;
43 size_t FakeNotifierSettingsProvider::GetNotifierGroupCount() const {
44 return items_.size();
47 const message_center::NotifierGroup&
48 FakeNotifierSettingsProvider::GetNotifierGroupAt(size_t index) const {
49 return *(items_[index].group);
52 bool FakeNotifierSettingsProvider::IsNotifierGroupActiveAt(
53 size_t index) const {
54 return active_item_index_ == index;
57 void FakeNotifierSettingsProvider::SwitchToNotifierGroup(size_t index) {
58 active_item_index_ = index;
61 const message_center::NotifierGroup&
62 FakeNotifierSettingsProvider::GetActiveNotifierGroup() const {
63 return *(items_[active_item_index_].group);
66 void FakeNotifierSettingsProvider::GetNotifierList(
67 std::vector<Notifier*>* notifiers) {
68 notifiers->clear();
69 for (size_t i = 0; i < items_[active_item_index_].notifiers.size(); ++i)
70 notifiers->push_back(items_[active_item_index_].notifiers[i]);
73 void FakeNotifierSettingsProvider::SetNotifierEnabled(const Notifier& notifier,
74 bool enabled) {
75 enabled_[&notifier] = enabled;
78 void FakeNotifierSettingsProvider::OnNotifierSettingsClosing() {
79 closed_called_count_++;
82 bool FakeNotifierSettingsProvider::NotifierHasAdvancedSettings(
83 const message_center::NotifierId& notifier_id) const {
84 if (!notifier_id_with_settings_handler_)
85 return false;
86 return *notifier_id_with_settings_handler_ == notifier_id;
89 void FakeNotifierSettingsProvider::OnNotifierAdvancedSettingsRequested(
90 const NotifierId& notifier_id,
91 const std::string* notification_id) {
92 notifier_settings_requested_count_++;
95 void FakeNotifierSettingsProvider::AddObserver(
96 NotifierSettingsObserver* observer) {
99 void FakeNotifierSettingsProvider::RemoveObserver(
100 NotifierSettingsObserver* observer) {
103 bool FakeNotifierSettingsProvider::WasEnabled(const Notifier& notifier) {
104 return enabled_[&notifier];
107 void FakeNotifierSettingsProvider::AddGroup(
108 NotifierGroup* group, const std::vector<Notifier*>& notifiers) {
109 NotifierGroupItem item;
110 item.group = group;
111 item.notifiers = notifiers;
112 items_.push_back(item);
115 void FakeNotifierSettingsProvider::SetNotifierHasAdvancedSettings(
116 const NotifierId& notifier_id) {
117 notifier_id_with_settings_handler_.reset(new NotifierId(notifier_id));
120 int FakeNotifierSettingsProvider::closed_called_count() {
121 return closed_called_count_;
124 size_t FakeNotifierSettingsProvider::settings_requested_count() const {
125 return notifier_settings_requested_count_;
128 } // namespace message_center