OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/message_center/views/notifier_settings_view.h" | 5 #include "ui/message_center/views/notifier_settings_view.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 210 |
211 class NotifierGroupMenuModel : public ui::SimpleMenuModel, | 211 class NotifierGroupMenuModel : public ui::SimpleMenuModel, |
212 public ui::SimpleMenuModel::Delegate { | 212 public ui::SimpleMenuModel::Delegate { |
213 public: | 213 public: |
214 NotifierGroupMenuModel(NotifierSettingsProvider* notifier_settings_provider); | 214 NotifierGroupMenuModel(NotifierSettingsProvider* notifier_settings_provider); |
215 ~NotifierGroupMenuModel() override; | 215 ~NotifierGroupMenuModel() override; |
216 | 216 |
217 // ui::SimpleMenuModel::Delegate: | 217 // ui::SimpleMenuModel::Delegate: |
218 bool IsCommandIdChecked(int command_id) const override; | 218 bool IsCommandIdChecked(int command_id) const override; |
219 bool IsCommandIdEnabled(int command_id) const override; | 219 bool IsCommandIdEnabled(int command_id) const override; |
220 bool GetAcceleratorForCommandId(int command_id, | |
221 ui::Accelerator* accelerator) const override; | |
222 void ExecuteCommand(int command_id, int event_flags) override; | 220 void ExecuteCommand(int command_id, int event_flags) override; |
223 | 221 |
224 private: | 222 private: |
225 NotifierSettingsProvider* notifier_settings_provider_; | 223 NotifierSettingsProvider* notifier_settings_provider_; |
226 | 224 |
227 DISALLOW_COPY_AND_ASSIGN(NotifierGroupMenuModel); | 225 DISALLOW_COPY_AND_ASSIGN(NotifierGroupMenuModel); |
228 }; | 226 }; |
229 | 227 |
230 NotifierGroupMenuModel::NotifierGroupMenuModel( | 228 NotifierGroupMenuModel::NotifierGroupMenuModel( |
231 NotifierSettingsProvider* notifier_settings_provider) | 229 NotifierSettingsProvider* notifier_settings_provider) |
(...skipping 16 matching lines...) Expand all Loading... |
248 bool NotifierGroupMenuModel::IsCommandIdChecked(int command_id) const { | 246 bool NotifierGroupMenuModel::IsCommandIdChecked(int command_id) const { |
249 // If there's no provider, assume only one notifier group - the active one. | 247 // If there's no provider, assume only one notifier group - the active one. |
250 return !notifier_settings_provider_ || | 248 return !notifier_settings_provider_ || |
251 notifier_settings_provider_->IsNotifierGroupActiveAt(command_id); | 249 notifier_settings_provider_->IsNotifierGroupActiveAt(command_id); |
252 } | 250 } |
253 | 251 |
254 bool NotifierGroupMenuModel::IsCommandIdEnabled(int command_id) const { | 252 bool NotifierGroupMenuModel::IsCommandIdEnabled(int command_id) const { |
255 return true; | 253 return true; |
256 } | 254 } |
257 | 255 |
258 bool NotifierGroupMenuModel::GetAcceleratorForCommandId( | |
259 int command_id, | |
260 ui::Accelerator* accelerator) const { | |
261 return false; | |
262 } | |
263 | |
264 void NotifierGroupMenuModel::ExecuteCommand(int command_id, int event_flags) { | 256 void NotifierGroupMenuModel::ExecuteCommand(int command_id, int event_flags) { |
265 if (!notifier_settings_provider_) | 257 if (!notifier_settings_provider_) |
266 return; | 258 return; |
267 | 259 |
268 size_t notifier_group_index = static_cast<size_t>(command_id); | 260 size_t notifier_group_index = static_cast<size_t>(command_id); |
269 size_t num_notifier_groups = | 261 size_t num_notifier_groups = |
270 notifier_settings_provider_->GetNotifierGroupCount(); | 262 notifier_settings_provider_->GetNotifierGroupCount(); |
271 if (notifier_group_index >= num_notifier_groups) | 263 if (notifier_group_index >= num_notifier_groups) |
272 return; | 264 return; |
273 | 265 |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 notifier_group_selector_, | 693 notifier_group_selector_, |
702 menu_anchor, | 694 menu_anchor, |
703 views::MENU_ANCHOR_BUBBLE_ABOVE, | 695 views::MENU_ANCHOR_BUBBLE_ABOVE, |
704 ui::MENU_SOURCE_MOUSE)) | 696 ui::MENU_SOURCE_MOUSE)) |
705 return; | 697 return; |
706 MessageCenterView* center_view = static_cast<MessageCenterView*>(parent()); | 698 MessageCenterView* center_view = static_cast<MessageCenterView*>(parent()); |
707 center_view->OnSettingsChanged(); | 699 center_view->OnSettingsChanged(); |
708 } | 700 } |
709 | 701 |
710 } // namespace message_center | 702 } // namespace message_center |
OLD | NEW |