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

Side by Side Diff: chrome/browser/ui/views/tab_contents/render_view_context_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
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 "chrome/browser/ui/views/tab_contents/render_view_context_menu_views.h" 5 #include "chrome/browser/ui/views/tab_contents/render_view_context_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 "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h" 10 #include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
11 #include "content/browser/renderer_host/render_widget_host_view.h" 11 #include "content/browser/renderer_host/render_widget_host_view.h"
12 #include "content/browser/tab_contents/tab_contents.h" 12 #include "content/browser/tab_contents/tab_contents.h"
13 #include "content/browser/tab_contents/tab_contents_view.h" 13 #include "content/browser/tab_contents/tab_contents_view.h"
14 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
15 #include "ui/base/keycodes/keyboard_codes.h" 15 #include "ui/base/keycodes/keyboard_codes.h"
16 #include "views/accelerator.h" 16 #include "ui/base/models/accelerator.h"
17 #include "views/controls/menu/menu_item_view.h" 17 #include "views/controls/menu/menu_item_view.h"
18 #include "views/controls/menu/menu_model_adapter.h" 18 #include "views/controls/menu/menu_model_adapter.h"
19 #include "views/controls/menu/menu_runner.h" 19 #include "views/controls/menu/menu_runner.h"
20 20
21 //////////////////////////////////////////////////////////////////////////////// 21 ////////////////////////////////////////////////////////////////////////////////
22 // RenderViewContextMenuViews, public: 22 // RenderViewContextMenuViews, public:
23 23
24 RenderViewContextMenuViews::RenderViewContextMenuViews( 24 RenderViewContextMenuViews::RenderViewContextMenuViews(
25 TabContents* tab_contents, 25 TabContents* tab_contents,
26 const ContextMenuParams& params) 26 const ContextMenuParams& params)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 UpdateMenuItemStates(); 62 UpdateMenuItemStates();
63 } 63 }
64 64
65 bool RenderViewContextMenuViews::GetAcceleratorForCommandId( 65 bool RenderViewContextMenuViews::GetAcceleratorForCommandId(
66 int command_id, 66 int command_id,
67 ui::Accelerator* accel) { 67 ui::Accelerator* accel) {
68 // There are no formally defined accelerators we can query so we assume 68 // There are no formally defined accelerators we can query so we assume
69 // that Ctrl+C, Ctrl+V, Ctrl+X, Ctrl-A, etc do what they normally do. 69 // that Ctrl+C, Ctrl+V, Ctrl+X, Ctrl-A, etc do what they normally do.
70 switch (command_id) { 70 switch (command_id) {
71 case IDC_CONTENT_CONTEXT_UNDO: 71 case IDC_CONTENT_CONTEXT_UNDO:
72 *accel = views::Accelerator(ui::VKEY_Z, false, true, false); 72 *accel = ui::Accelerator(ui::VKEY_Z, false, true, false);
73 return true; 73 return true;
74 74
75 case IDC_CONTENT_CONTEXT_REDO: 75 case IDC_CONTENT_CONTEXT_REDO:
76 // TODO(jcampan): should it be Ctrl-Y? 76 // TODO(jcampan): should it be Ctrl-Y?
77 *accel = views::Accelerator(ui::VKEY_Z, true, true, false); 77 *accel = ui::Accelerator(ui::VKEY_Z, true, true, false);
78 return true; 78 return true;
79 79
80 case IDC_CONTENT_CONTEXT_CUT: 80 case IDC_CONTENT_CONTEXT_CUT:
81 *accel = views::Accelerator(ui::VKEY_X, false, true, false); 81 *accel = ui::Accelerator(ui::VKEY_X, false, true, false);
82 return true; 82 return true;
83 83
84 case IDC_CONTENT_CONTEXT_COPY: 84 case IDC_CONTENT_CONTEXT_COPY:
85 *accel = views::Accelerator(ui::VKEY_C, false, true, false); 85 *accel = ui::Accelerator(ui::VKEY_C, false, true, false);
86 return true; 86 return true;
87 87
88 case IDC_CONTENT_CONTEXT_PASTE: 88 case IDC_CONTENT_CONTEXT_PASTE:
89 *accel = views::Accelerator(ui::VKEY_V, false, true, false); 89 *accel = ui::Accelerator(ui::VKEY_V, false, true, false);
90 return true; 90 return true;
91 91
92 case IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE: 92 case IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE:
93 *accel = views::Accelerator(ui::VKEY_V, true, true, false); 93 *accel = ui::Accelerator(ui::VKEY_V, true, true, false);
94 return true; 94 return true;
95 95
96 case IDC_CONTENT_CONTEXT_SELECTALL: 96 case IDC_CONTENT_CONTEXT_SELECTALL:
97 *accel = views::Accelerator(ui::VKEY_A, false, true, false); 97 *accel = ui::Accelerator(ui::VKEY_A, false, true, false);
98 return true; 98 return true;
99 99
100 default: 100 default:
101 return false; 101 return false;
102 } 102 }
103 } 103 }
104 104
105 void RenderViewContextMenuViews::UpdateMenuItem(int command_id, 105 void RenderViewContextMenuViews::UpdateMenuItem(int command_id,
106 bool enabled, 106 bool enabled,
107 bool hidden, 107 bool hidden,
108 const string16& title) { 108 const string16& title) {
109 views::MenuItemView* item = menu_->GetMenuItemByID(command_id); 109 views::MenuItemView* item = menu_->GetMenuItemByID(command_id);
110 if (!item) 110 if (!item)
111 return; 111 return;
112 112
113 item->SetEnabled(enabled); 113 item->SetEnabled(enabled);
114 item->SetTitle(title); 114 item->SetTitle(title);
115 item->SetVisible(!hidden); 115 item->SetVisible(!hidden);
116 116
117 views::MenuItemView* parent = item->GetParentMenuItem(); 117 views::MenuItemView* parent = item->GetParentMenuItem();
118 if (!parent) 118 if (!parent)
119 return; 119 return;
120 120
121 parent->ChildrenChanged(); 121 parent->ChildrenChanged();
122 } 122 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/location_bar_view.h ('k') | chrome/browser/ui/views/task_manager_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698