blob: b97bc841b5e831222be541987a1d9781ed6c4acb [file] [log] [blame]
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001// 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 "ui/message_center/views/notifier_settings_view.h"
6
Ben Murdocheb525c52013-07-10 11:40:50 +01007#include <set>
8#include <string>
9
10#include "base/strings/string16.h"
Ben Murdochbb1529c2013-08-08 10:24:53 +010011#include "base/strings/utf_string_conversions.h"
Ben Murdocheb525c52013-07-10 11:40:50 +010012#include "grit/ui_resources.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000013#include "grit/ui_strings.h"
Ben Murdochbb1529c2013-08-08 10:24:53 +010014#include "skia/ext/image_operations.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000015#include "third_party/skia/include/core/SkColor.h"
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010016#include "ui/base/keycodes/keyboard_codes.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000017#include "ui/base/l10n/l10n_util.h"
Ben Murdochbb1529c2013-08-08 10:24:53 +010018#include "ui/base/models/simple_menu_model.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000019#include "ui/base/resource/resource_bundle.h"
20#include "ui/gfx/canvas.h"
21#include "ui/gfx/image/image.h"
Ben Murdochbb1529c2013-08-08 10:24:53 +010022#include "ui/gfx/image/image_skia_operations.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000023#include "ui/gfx/size.h"
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010024#include "ui/message_center/message_center_style.h"
Ben Murdocheb525c52013-07-10 11:40:50 +010025#include "ui/message_center/views/message_center_view.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000026#include "ui/views/background.h"
27#include "ui/views/border.h"
28#include "ui/views/controls/button/checkbox.h"
29#include "ui/views/controls/button/custom_button.h"
Ben Murdochbb1529c2013-08-08 10:24:53 +010030#include "ui/views/controls/button/menu_button.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000031#include "ui/views/controls/image_view.h"
32#include "ui/views/controls/label.h"
Ben Murdochbb1529c2013-08-08 10:24:53 +010033#include "ui/views/controls/menu/menu_runner.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000034#include "ui/views/controls/scroll_view.h"
Torne (Richard Coles)5e3f23d2013-06-11 16:24:11 +010035#include "ui/views/controls/scrollbar/overlay_scroll_bar.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000036#include "ui/views/layout/box_layout.h"
Ben Murdocheb525c52013-07-10 11:40:50 +010037#include "ui/views/layout/grid_layout.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000038#include "ui/views/widget/widget.h"
39
40#if defined(USE_AURA)
41#include "ui/aura/window.h"
42#endif
43
44namespace message_center {
45namespace {
46
47const int kSpaceInButtonComponents = 16;
48const int kMarginWidth = 16;
49const int kMinimumWindowWidth = 320;
50const int kMinimumWindowHeight = 480;
51const int kEntryHeight = kMinimumWindowHeight / 10;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000052
53// The view to guarantee the 48px height and place the contents at the
54// middle. It also guarantee the left margin.
55class EntryView : public views::View {
56 public:
57 EntryView(views::View* contents);
58 virtual ~EntryView();
59
60 // Overridden from views::View:
61 virtual void Layout() OVERRIDE;
62 virtual gfx::Size GetPreferredSize() OVERRIDE;
Torne (Richard Coles)b2df76e2013-05-13 16:52:09 +010063 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010064 virtual void OnFocus() OVERRIDE;
65 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE;
66 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
67 virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000068
69 private:
70 DISALLOW_COPY_AND_ASSIGN(EntryView);
71};
72
73EntryView::EntryView(views::View* contents) {
74 AddChildView(contents);
75}
76
77EntryView::~EntryView() {
78}
79
80void EntryView::Layout() {
81 DCHECK_EQ(1, child_count());
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010082 views::View* content = child_at(0);
83 int content_width = width() - kMarginWidth * 2;
84 int content_height = content->GetHeightForWidth(content_width);
85 int y = std::max((height() - content_height) / 2, 0);
86 content->SetBounds(kMarginWidth, y, content_width, content_height);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000087}
88
89gfx::Size EntryView::GetPreferredSize() {
90 DCHECK_EQ(1, child_count());
91 gfx::Size size = child_at(0)->GetPreferredSize();
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010092 size.SetToMax(gfx::Size(kMinimumWindowWidth, kEntryHeight));
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000093 return size;
94}
95
Torne (Richard Coles)b2df76e2013-05-13 16:52:09 +010096void EntryView::GetAccessibleState(ui::AccessibleViewState* state) {
97 DCHECK_EQ(1, child_count());
98 child_at(0)->GetAccessibleState(state);
99}
100
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100101void EntryView::OnFocus() {
Torne (Richard Coles)b2df76e2013-05-13 16:52:09 +0100102 views::View::OnFocus();
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100103 ScrollRectToVisible(GetLocalBounds());
104}
105
106void EntryView::OnPaintFocusBorder(gfx::Canvas* canvas) {
107 if (HasFocus() && (focusable() || IsAccessibilityFocusable())) {
108 canvas->DrawRect(gfx::Rect(2, 1, width() - 4, height() - 3),
109 kFocusBorderColor);
110 }
111}
112
113bool EntryView::OnKeyPressed(const ui::KeyEvent& event) {
114 return child_at(0)->OnKeyPressed(event);
115}
116
117bool EntryView::OnKeyReleased(const ui::KeyEvent& event) {
118 return child_at(0)->OnKeyReleased(event);
119}
120
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000121} // namespace
122
Ben Murdochbb1529c2013-08-08 10:24:53 +0100123// NotifierGroupMenuModel //////////////////////////////////////////////////////
124////////////////////////////////////////////////////////////////////////////////
125class NotifierGroupMenuModel : public ui::SimpleMenuModel,
126 public ui::SimpleMenuModel::Delegate {
127 public:
128 NotifierGroupMenuModel(NotifierSettingsProvider* notifier_settings_provider);
129 virtual ~NotifierGroupMenuModel();
130
131 // Overridden from ui::SimpleMenuModel::Delegate:
132 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
133 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
134 virtual bool GetAcceleratorForCommandId(
135 int command_id,
136 ui::Accelerator* accelerator) OVERRIDE;
137 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
138
139 private:
140 NotifierSettingsProvider* notifier_settings_provider_;
141};
142
143NotifierGroupMenuModel::NotifierGroupMenuModel(
144 NotifierSettingsProvider* notifier_settings_provider)
145 : ui::SimpleMenuModel(this),
146 notifier_settings_provider_(notifier_settings_provider) {
147 if (!notifier_settings_provider_)
148 return;
149
150 size_t num_menu_items = notifier_settings_provider_->GetNotifierGroupCount();
151 for (size_t i = 0; i < num_menu_items; ++i) {
152 const NotifierGroup& group =
153 notifier_settings_provider_->GetNotifierGroupAt(i);
154
155 AddItem(i, group.login_info.empty() ? group.name : group.login_info);
156
157 gfx::ImageSkia resized_icon = gfx::ImageSkiaOperations::CreateResizedImage(
158 *group.icon.ToImageSkia(),
159 skia::ImageOperations::RESIZE_BETTER,
160 gfx::Size(kSettingsIconSize, kSettingsIconSize));
161
162 SetIcon(i, gfx::Image(resized_icon));
163 }
164}
165
166NotifierGroupMenuModel::~NotifierGroupMenuModel() {}
167
168bool NotifierGroupMenuModel::IsCommandIdChecked(int command_id) const {
169 return false;
170}
171
172bool NotifierGroupMenuModel::IsCommandIdEnabled(int command_id) const {
173 return true;
174}
175
176bool NotifierGroupMenuModel::GetAcceleratorForCommandId(
177 int command_id,
178 ui::Accelerator* accelerator) {
179 return false;
180}
181
182void NotifierGroupMenuModel::ExecuteCommand(int command_id, int event_flags) {
183 if (!notifier_settings_provider_)
184 return;
185
186 size_t notifier_group_index = static_cast<size_t>(command_id);
187 size_t num_notifier_groups =
188 notifier_settings_provider_->GetNotifierGroupCount();
189 if (notifier_group_index >= num_notifier_groups)
190 return;
191
192 notifier_settings_provider_->SwitchToNotifierGroup(notifier_group_index);
193}
194
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000195// We do not use views::Checkbox class directly because it doesn't support
196// showing 'icon'.
197class NotifierSettingsView::NotifierButton : public views::CustomButton,
198 public views::ButtonListener {
199 public:
200 NotifierButton(Notifier* notifier, views::ButtonListener* listener)
201 : views::CustomButton(listener),
202 notifier_(notifier),
203 icon_view_(NULL),
204 checkbox_(new views::Checkbox(string16())) {
205 DCHECK(notifier);
206 SetLayoutManager(new views::BoxLayout(
207 views::BoxLayout::kHorizontal, 0, 0, kSpaceInButtonComponents));
208 checkbox_->SetChecked(notifier_->enabled);
209 checkbox_->set_listener(this);
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100210 checkbox_->set_focusable(false);
Torne (Richard Coles)b2df76e2013-05-13 16:52:09 +0100211 checkbox_->SetAccessibleName(notifier_->name);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000212 AddChildView(checkbox_);
213 UpdateIconImage(notifier_->icon);
214 AddChildView(new views::Label(notifier_->name));
215 }
216
217 void UpdateIconImage(const gfx::Image& icon) {
218 notifier_->icon = icon;
219 if (icon.IsEmpty()) {
220 delete icon_view_;
221 icon_view_ = NULL;
222 } else {
223 if (!icon_view_) {
224 icon_view_ = new views::ImageView();
225 AddChildViewAt(icon_view_, 1);
226 }
227 icon_view_->SetImage(icon.ToImageSkia());
228 icon_view_->SetImageSize(gfx::Size(kSettingsIconSize, kSettingsIconSize));
229 }
230 Layout();
231 SchedulePaint();
232 }
233
234 void SetChecked(bool checked) {
235 checkbox_->SetChecked(checked);
236 notifier_->enabled = checked;
237 }
238
239 bool checked() const {
240 return checkbox_->checked();
241 }
242
243 const Notifier& notifier() const {
244 return *notifier_.get();
245 }
246
247 private:
248 // Overridden from views::ButtonListener:
249 virtual void ButtonPressed(views::Button* button,
250 const ui::Event& event) OVERRIDE {
251 DCHECK(button == checkbox_);
252 // The checkbox state has already changed at this point, but we'll update
253 // the state on NotifierSettingsView::ButtonPressed() too, so here change
254 // back to the previous state.
255 checkbox_->SetChecked(!checkbox_->checked());
256 CustomButton::NotifyClick(event);
257 }
258
Torne (Richard Coles)b2df76e2013-05-13 16:52:09 +0100259 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE {
260 static_cast<views::View*>(checkbox_)->GetAccessibleState(state);
261 }
262
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000263 scoped_ptr<Notifier> notifier_;
264 views::ImageView* icon_view_;
265 views::Checkbox* checkbox_;
266
267 DISALLOW_COPY_AND_ASSIGN(NotifierButton);
268};
269
Ben Murdocheb525c52013-07-10 11:40:50 +0100270NotifierSettingsView::NotifierSettingsView(NotifierSettingsProvider* provider)
271 : provider_(provider) {
272 // |provider_| may be NULL in tests.
273 if (provider_)
274 provider_->AddObserver(this);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000275
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100276 set_focusable(true);
277 set_focus_border(NULL);
Ben Murdocheb525c52013-07-10 11:40:50 +0100278 set_background(views::Background::CreateSolidBackground(
279 kMessageCenterBackgroundColor));
280 if (get_use_acceleration_when_possible())
281 SetPaintToLayer(true);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000282
Ben Murdocheb525c52013-07-10 11:40:50 +0100283 ResourceBundle& bundle = ResourceBundle::GetSharedInstance();
284
285 views::View* title_container = new views::View;
286 // The title_arrow and title_label aren't aligned well in Windows for the
287 // horizontal BoxLayout. That's why GridLayout with vertical alignment is
288 // used here.
289 views::GridLayout* title_layout = new views::GridLayout(title_container);
290 title_container->SetLayoutManager(title_layout);
291 views::ColumnSet* columns = title_layout->AddColumnSet(0);
292 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
293 0, views::GridLayout::USE_PREF, 0, 0);
294 columns->AddPaddingColumn(0, kMarginWidth);
295 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
296 1, views::GridLayout::USE_PREF, 0, 0);
297 title_arrow_ = new views::ImageButton(this);
298 title_arrow_->SetImage(views::Button::STATE_NORMAL, bundle.GetImageSkiaNamed(
299 IDR_NOTIFICATION_ARROW));
300 title_arrow_->SetImage(views::Button::STATE_HOVERED, bundle.GetImageSkiaNamed(
301 IDR_NOTIFICATION_ARROW_HOVER));
302 title_arrow_->SetImage(views::Button::STATE_PRESSED, bundle.GetImageSkiaNamed(
303 IDR_NOTIFICATION_ARROW_PRESSED));
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000304 gfx::Font title_font =
305 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont);
306 views::Label* title_label = new views::Label(
307 l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_SETTINGS_BUTTON_LABEL),
308 title_font);
309 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
310 title_label->SetMultiLine(true);
Ben Murdocheb525c52013-07-10 11:40:50 +0100311 title_layout->StartRow(0, 0);
312 title_layout->AddView(title_arrow_);
313 title_layout->AddView(title_label);
314 title_entry_ = new EntryView(title_container);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000315 AddChildView(title_entry_);
316
317 scroller_ = new views::ScrollView();
Torne (Richard Coles)5e3f23d2013-06-11 16:24:11 +0100318 scroller_->SetVerticalScrollBar(new views::OverlayScrollBar(false));
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000319 AddChildView(scroller_);
320
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000321 std::vector<Notifier*> notifiers;
Ben Murdocheb525c52013-07-10 11:40:50 +0100322 if (provider_)
323 provider_->GetNotifierList(&notifiers);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000324
Ben Murdochbb1529c2013-08-08 10:24:53 +0100325 UpdateContentsView(notifiers);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000326}
327
328NotifierSettingsView::~NotifierSettingsView() {
Ben Murdocheb525c52013-07-10 11:40:50 +0100329 // |provider_| may be NULL in tests.
330 if (provider_)
331 provider_->RemoveObserver(this);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000332}
333
Ben Murdocheb525c52013-07-10 11:40:50 +0100334bool NotifierSettingsView::IsScrollable() {
335 return scroller_->height() < scroller_->contents()->height();
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100336}
337
Ben Murdocheb525c52013-07-10 11:40:50 +0100338void NotifierSettingsView::UpdateIconImage(const NotifierId& notifier_id,
339 const gfx::Image& icon) {
340 for (std::set<NotifierButton*>::iterator iter = buttons_.begin();
341 iter != buttons_.end(); ++iter) {
342 if ((*iter)->notifier().notifier_id == notifier_id) {
343 (*iter)->UpdateIconImage(icon);
344 return;
345 }
346 }
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000347}
348
Ben Murdochbb1529c2013-08-08 10:24:53 +0100349void NotifierSettingsView::NotifierGroupChanged() {
350 std::vector<Notifier*> notifiers;
351 if (provider_)
352 provider_->GetNotifierList(&notifiers);
353
354 UpdateContentsView(notifiers);
355}
356
357void NotifierSettingsView::UpdateContentsView(
358 const std::vector<Notifier*>& notifiers) {
359 buttons_.clear();
360
361 views::View* contents_view = new views::View();
362 contents_view->SetLayoutManager(
363 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
364
365 views::View* contents_title_view = new views::View();
366 contents_title_view->SetLayoutManager(
367 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 5));
368 views::Label* top_label = new views::Label(l10n_util::GetStringUTF16(
369 IDS_MESSAGE_CENTER_SETTINGS_DIALOG_DESCRIPTION));
370 top_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
371 top_label->SetMultiLine(true);
372 contents_title_view->AddChildView(top_label);
373
374 string16 notifier_group_text;
375 if (provider_) {
376 const NotifierGroup& active_group = provider_->GetActiveNotifierGroup();
377 notifier_group_text = active_group.login_info.empty()
378 ? active_group.name
379 : active_group.login_info;
380 }
381
382 views::View* notifier_group_selector =
383 new views::MenuButton(NULL, notifier_group_text, this, true);
384 contents_title_view->AddChildView(notifier_group_selector);
385 contents_view->AddChildView(new EntryView(contents_title_view));
386
387 for (size_t i = 0; i < notifiers.size(); ++i) {
388 NotifierButton* button = new NotifierButton(notifiers[i], this);
389 EntryView* entry = new EntryView(button);
390 entry->set_focusable(true);
391 contents_view->AddChildView(entry);
392 buttons_.insert(button);
393 }
394 scroller_->SetContents(contents_view);
395
396 contents_view->SetBoundsRect(gfx::Rect(contents_view->GetPreferredSize()));
397 InvalidateLayout();
398}
399
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000400void NotifierSettingsView::Layout() {
Ben Murdocheb525c52013-07-10 11:40:50 +0100401 int title_height = title_entry_->GetHeightForWidth(width());
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000402 title_entry_->SetBounds(0, 0, width(), title_height);
Ben Murdocheb525c52013-07-10 11:40:50 +0100403
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100404 views::View* contents_view = scroller_->contents();
405 int content_width = width();
406 int content_height = contents_view->GetHeightForWidth(content_width);
Ben Murdocheb525c52013-07-10 11:40:50 +0100407 if (title_height + content_height > height()) {
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100408 content_width -= scroller_->GetScrollBarWidth();
409 content_height = contents_view->GetHeightForWidth(content_width);
410 }
411 contents_view->SetBounds(0, 0, content_width, content_height);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000412 scroller_->SetBounds(0, title_height, width(), height() - title_height);
413}
414
415gfx::Size NotifierSettingsView::GetMinimumSize() {
416 gfx::Size size(kMinimumWindowWidth, kMinimumWindowHeight);
417 int total_height = title_entry_->GetPreferredSize().height() +
418 scroller_->contents()->GetPreferredSize().height();
419 if (total_height > kMinimumWindowHeight)
420 size.Enlarge(scroller_->GetScrollBarWidth(), 0);
421 return size;
422}
423
424gfx::Size NotifierSettingsView::GetPreferredSize() {
Ben Murdocheb525c52013-07-10 11:40:50 +0100425 gfx::Size preferred_size;
426 std::vector<gfx::Size> child_sizes;
427 gfx::Size title_size = title_entry_->GetPreferredSize();
428 gfx::Size content_size = scroller_->contents()->GetPreferredSize();
429 return gfx::Size(std::max(title_size.width(), content_size.width()),
430 title_size.height() + content_size.height());
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000431}
432
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100433bool NotifierSettingsView::OnKeyPressed(const ui::KeyEvent& event) {
434 if (event.key_code() == ui::VKEY_ESCAPE) {
435 GetWidget()->Close();
436 return true;
437 }
438
439 return scroller_->OnKeyPressed(event);
440}
441
442bool NotifierSettingsView::OnMouseWheel(const ui::MouseWheelEvent& event) {
443 return scroller_->OnMouseWheel(event);
444}
445
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000446void NotifierSettingsView::ButtonPressed(views::Button* sender,
447 const ui::Event& event) {
Ben Murdocheb525c52013-07-10 11:40:50 +0100448 if (sender == title_arrow_) {
449 MessageCenterView* center_view = static_cast<MessageCenterView*>(parent());
450 center_view->SetSettingsVisible(!center_view->settings_visible());
451 return;
452 }
453
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000454 std::set<NotifierButton*>::iterator iter = buttons_.find(
455 static_cast<NotifierButton*>(sender));
Ben Murdochbb1529c2013-08-08 10:24:53 +0100456
457 if (iter == buttons_.end())
458 return;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000459
460 (*iter)->SetChecked(!(*iter)->checked());
Ben Murdocheb525c52013-07-10 11:40:50 +0100461 if (provider_)
462 provider_->SetNotifierEnabled((*iter)->notifier(), (*iter)->checked());
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000463}
464
Ben Murdochbb1529c2013-08-08 10:24:53 +0100465void NotifierSettingsView::OnMenuButtonClicked(views::View* source,
466 const gfx::Point& point) {
467 notifier_group_menu_model_.reset(new NotifierGroupMenuModel(provider_));
468 notifier_group_menu_runner_.reset(
469 new views::MenuRunner(notifier_group_menu_model_.get()));
470 if (views::MenuRunner::MENU_DELETED ==
471 notifier_group_menu_runner_->RunMenuAt(GetWidget(),
472 NULL,
473 source->GetBoundsInScreen(),
474 views::MenuItemView::BUBBLE_ABOVE,
475 ui::MENU_SOURCE_MOUSE,
476 views::MenuRunner::CONTEXT_MENU))
477 return;
478 MessageCenterView* center_view = static_cast<MessageCenterView*>(parent());
479 center_view->OnSettingsChanged();
480}
481
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000482} // namespace message_center