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

Side by Side Diff: views/controls/menu/native_menu_views.cc

Issue 8508055: Move views::Accelerator to ui in order to use it from aura code. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase Created 9 years, 1 month 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 | « views/controls/menu/native_menu_views.h ('k') | views/controls/menu/native_menu_win.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/controls/menu/native_menu_views.h" 5 #include "views/controls/menu/native_menu_views.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "ui/base/models/menu_model.h" 9 #include "ui/base/models/menu_model.h"
10 #include "ui/gfx/canvas_skia.h" 10 #include "ui/gfx/canvas_skia.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 93 }
94 94
95 void NativeMenuViews::ExecuteCommand(int cmd) { 95 void NativeMenuViews::ExecuteCommand(int cmd) {
96 int index; 96 int index;
97 ui::MenuModel* model = model_; 97 ui::MenuModel* model = model_;
98 if (!ui::MenuModel::GetModelAndIndexForCommandId(cmd, &model, &index)) 98 if (!ui::MenuModel::GetModelAndIndexForCommandId(cmd, &model, &index))
99 return; 99 return;
100 model->ActivatedAt(index); 100 model->ActivatedAt(index);
101 } 101 }
102 102
103 bool NativeMenuViews::GetAccelerator(int id, views::Accelerator* accelerator) { 103 bool NativeMenuViews::GetAccelerator(int id, ui::Accelerator* accelerator) {
104 int index; 104 int index;
105 ui::MenuModel* model = model_; 105 ui::MenuModel* model = model_;
106 if (!ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index)) 106 if (!ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index))
107 return false; 107 return false;
108 108
109 ui::Accelerator menu_accelerator; 109 ui::Accelerator menu_accelerator;
110 if (!model->GetAcceleratorAt(index, &menu_accelerator)) 110 if (!model->GetAcceleratorAt(index, &menu_accelerator))
111 return false; 111 return false;
112 112
113 *accelerator = views::Accelerator(menu_accelerator.key_code(), 113 *accelerator = ui::Accelerator(menu_accelerator.key_code(),
114 menu_accelerator.modifiers()); 114 menu_accelerator.modifiers());
115 return true; 115 return true;
116 } 116 }
117 117
118 // private 118 // private
119 void NativeMenuViews::AddMenuItemsFromModel(MenuItemView* parent, 119 void NativeMenuViews::AddMenuItemsFromModel(MenuItemView* parent,
120 ui::MenuModel* model) { 120 ui::MenuModel* model) {
121 for (int i = 0; i < model->GetItemCount(); ++i) { 121 for (int i = 0; i < model->GetItemCount(); ++i) {
122 int index = i + model->GetFirstItemIndex(NULL); 122 int index = i + model->GetFirstItemIndex(NULL);
123 MenuItemView* child = parent->AppendMenuItemFromModel(model, index, 123 MenuItemView* child = parent->AppendMenuItemFromModel(model, index,
124 model->GetCommandIdAt(index)); 124 model->GetCommandIdAt(index));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 162 }
163 163
164 // MenuWrapper, public: 164 // MenuWrapper, public:
165 165
166 // static 166 // static
167 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) { 167 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) {
168 return new NativeMenuViews(menu); 168 return new NativeMenuViews(menu);
169 } 169 }
170 170
171 } // namespace views 171 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/menu/native_menu_views.h ('k') | views/controls/menu/native_menu_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698