Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: ui/views/examples/menu_example.cc

Issue 2133013002: AcceleratorProvider: Make GetAcceleratorForCommandId const. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix overrides on Mac and Chrome OS. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | ui/views/examples/tree_view_example.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/views/examples/menu_example.h" 5 #include "ui/views/examples/menu_example.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 14 matching lines...) Expand all
25 25
26 class ExampleMenuModel : public ui::SimpleMenuModel, 26 class ExampleMenuModel : public ui::SimpleMenuModel,
27 public ui::SimpleMenuModel::Delegate { 27 public ui::SimpleMenuModel::Delegate {
28 public: 28 public:
29 ExampleMenuModel(); 29 ExampleMenuModel();
30 30
31 // ui::SimpleMenuModel::Delegate: 31 // ui::SimpleMenuModel::Delegate:
32 bool IsCommandIdChecked(int command_id) const override; 32 bool IsCommandIdChecked(int command_id) const override;
33 bool IsCommandIdEnabled(int command_id) const override; 33 bool IsCommandIdEnabled(int command_id) const override;
34 bool GetAcceleratorForCommandId(int command_id, 34 bool GetAcceleratorForCommandId(int command_id,
35 ui::Accelerator* accelerator) override; 35 ui::Accelerator* accelerator) const override;
36 void ExecuteCommand(int command_id, int event_flags) override; 36 void ExecuteCommand(int command_id, int event_flags) override;
37 37
38 private: 38 private:
39 enum GroupID { 39 enum GroupID {
40 GROUP_MAKE_DECISION, 40 GROUP_MAKE_DECISION,
41 }; 41 };
42 42
43 enum CommandID { 43 enum CommandID {
44 COMMAND_DO_SOMETHING, 44 COMMAND_DO_SOMETHING,
45 COMMAND_SELECT_ASCII, 45 COMMAND_SELECT_ASCII,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 return false; 114 return false;
115 } 115 }
116 116
117 bool ExampleMenuModel::IsCommandIdEnabled(int command_id) const { 117 bool ExampleMenuModel::IsCommandIdEnabled(int command_id) const {
118 // All commands are enabled except for COMMAND_GO_HOME. 118 // All commands are enabled except for COMMAND_GO_HOME.
119 return command_id != COMMAND_GO_HOME; 119 return command_id != COMMAND_GO_HOME;
120 } 120 }
121 121
122 bool ExampleMenuModel::GetAcceleratorForCommandId( 122 bool ExampleMenuModel::GetAcceleratorForCommandId(
123 int command_id, 123 int command_id,
124 ui::Accelerator* accelerator) { 124 ui::Accelerator* accelerator) const {
125 // We don't use this in the example. 125 // We don't use this in the example.
126 return false; 126 return false;
127 } 127 }
128 128
129 void ExampleMenuModel::ExecuteCommand(int command_id, int event_flags) { 129 void ExampleMenuModel::ExecuteCommand(int command_id, int event_flags) {
130 switch (command_id) { 130 switch (command_id) {
131 case COMMAND_DO_SOMETHING: { 131 case COMMAND_DO_SOMETHING: {
132 VLOG(0) << "Done something"; 132 VLOG(0) << "Done something";
133 break; 133 break;
134 } 134 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 void MenuExample::CreateExampleView(View* container) { 217 void MenuExample::CreateExampleView(View* container) {
218 // We add a button to open a menu. 218 // We add a button to open a menu.
219 ExampleMenuButton* menu_button = new ExampleMenuButton( 219 ExampleMenuButton* menu_button = new ExampleMenuButton(
220 ASCIIToUTF16("Open a menu")); 220 ASCIIToUTF16("Open a menu"));
221 container->SetLayoutManager(new FillLayout); 221 container->SetLayoutManager(new FillLayout);
222 container->AddChildView(menu_button); 222 container->AddChildView(menu_button);
223 } 223 }
224 224
225 } // namespace examples 225 } // namespace examples
226 } // namespace views 226 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | ui/views/examples/tree_view_example.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698