OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |