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

Side by Side Diff: chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc

Issue 10446010: wip: Add ui::EventType parameter. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: wip - views_unittests Created 8 years, 7 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 | Annotate | Revision Log
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 "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 "content/public/browser/render_widget_host_view.h" 10 #include "content/public/browser/render_widget_host_view.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 menu_runner_->Cancel(); 66 menu_runner_->Cancel();
67 } 67 }
68 68
69 bool RenderViewContextMenuViews::GetAcceleratorForCommandId( 69 bool RenderViewContextMenuViews::GetAcceleratorForCommandId(
70 int command_id, 70 int command_id,
71 ui::Accelerator* accel) { 71 ui::Accelerator* accel) {
72 // There are no formally defined accelerators we can query so we assume 72 // There are no formally defined accelerators we can query so we assume
73 // that Ctrl+C, Ctrl+V, Ctrl+X, Ctrl-A, etc do what they normally do. 73 // that Ctrl+C, Ctrl+V, Ctrl+X, Ctrl-A, etc do what they normally do.
74 switch (command_id) { 74 switch (command_id) {
75 case IDC_CONTENT_CONTEXT_UNDO: 75 case IDC_CONTENT_CONTEXT_UNDO:
76 *accel = ui::Accelerator(ui::VKEY_Z, ui::EF_CONTROL_DOWN); 76 *accel = ui::Accelerator(ui::VKEY_Z,
77 ui::EF_CONTROL_DOWN,
78 ui::ET_KEY_PRESSED);
77 return true; 79 return true;
78 80
79 case IDC_CONTENT_CONTEXT_REDO: 81 case IDC_CONTENT_CONTEXT_REDO:
80 // TODO(jcampan): should it be Ctrl-Y? 82 // TODO(jcampan): should it be Ctrl-Y?
81 *accel = ui::Accelerator(ui::VKEY_Z, 83 *accel = ui::Accelerator(ui::VKEY_Z,
82 ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN); 84 ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN,
85 ui::ET_KEY_PRESSED);
83 return true; 86 return true;
84 87
85 case IDC_CONTENT_CONTEXT_CUT: 88 case IDC_CONTENT_CONTEXT_CUT:
86 *accel = ui::Accelerator(ui::VKEY_X, ui::EF_CONTROL_DOWN); 89 *accel = ui::Accelerator(ui::VKEY_X,
90 ui::EF_CONTROL_DOWN,
91 ui::ET_KEY_PRESSED);
87 return true; 92 return true;
88 93
89 case IDC_CONTENT_CONTEXT_COPY: 94 case IDC_CONTENT_CONTEXT_COPY:
90 *accel = ui::Accelerator(ui::VKEY_C, ui::EF_CONTROL_DOWN); 95 *accel = ui::Accelerator(ui::VKEY_C,
96 ui::EF_CONTROL_DOWN,
97 ui::ET_KEY_PRESSED);
91 return true; 98 return true;
92 99
93 case IDC_CONTENT_CONTEXT_PASTE: 100 case IDC_CONTENT_CONTEXT_PASTE:
94 *accel = ui::Accelerator(ui::VKEY_V, ui::EF_CONTROL_DOWN); 101 *accel = ui::Accelerator(ui::VKEY_V,
102 ui::EF_CONTROL_DOWN,
103 ui::ET_KEY_PRESSED);
95 return true; 104 return true;
96 105
97 case IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE: 106 case IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE:
98 *accel = ui::Accelerator(ui::VKEY_V, 107 *accel = ui::Accelerator(ui::VKEY_V,
99 ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN); 108 ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN,
109 ui::ET_KEY_PRESSED);
100 return true; 110 return true;
101 111
102 case IDC_CONTENT_CONTEXT_SELECTALL: 112 case IDC_CONTENT_CONTEXT_SELECTALL:
103 *accel = ui::Accelerator(ui::VKEY_A, ui::EF_CONTROL_DOWN); 113 *accel = ui::Accelerator(ui::VKEY_A,
114 ui::EF_CONTROL_DOWN,
115 ui::ET_KEY_PRESSED);
104 return true; 116 return true;
105 117
106 default: 118 default:
107 return false; 119 return false;
108 } 120 }
109 } 121 }
110 122
111 void RenderViewContextMenuViews::UpdateMenuItem(int command_id, 123 void RenderViewContextMenuViews::UpdateMenuItem(int command_id,
112 bool enabled, 124 bool enabled,
113 bool hidden, 125 bool hidden,
114 const string16& title) { 126 const string16& title) {
115 views::MenuItemView* item = menu_->GetMenuItemByID(command_id); 127 views::MenuItemView* item = menu_->GetMenuItemByID(command_id);
116 if (!item) 128 if (!item)
117 return; 129 return;
118 130
119 item->SetEnabled(enabled); 131 item->SetEnabled(enabled);
120 item->SetTitle(title); 132 item->SetTitle(title);
121 item->SetVisible(!hidden); 133 item->SetVisible(!hidden);
122 134
123 views::MenuItemView* parent = item->GetParentMenuItem(); 135 views::MenuItemView* parent = item->GetParentMenuItem();
124 if (!parent) 136 if (!parent)
125 return; 137 return;
126 138
127 parent->ChildrenChanged(); 139 parent->ChildrenChanged();
128 } 140 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/keyboard_overlay_dialog_view.cc ('k') | chrome/browser/ui/views/toolbar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698