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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.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/frame/browser_view.h" 5 #include "chrome/browser/ui/views/frame/browser_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 if (!browser_->block_command_execution()) 464 if (!browser_->block_command_execution())
465 UpdateAcceleratorMetrics(accelerator, command_id); 465 UpdateAcceleratorMetrics(accelerator, command_id);
466 return browser_->ExecuteCommandIfEnabled(command_id); 466 return browser_->ExecuteCommandIfEnabled(command_id);
467 } 467 }
468 468
469 bool BrowserView::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) { 469 bool BrowserView::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) {
470 // The standard Ctrl-X, Ctrl-V and Ctrl-C are not defined as accelerators 470 // The standard Ctrl-X, Ctrl-V and Ctrl-C are not defined as accelerators
471 // anywhere so we need to check for them explicitly here. 471 // anywhere so we need to check for them explicitly here.
472 switch (cmd_id) { 472 switch (cmd_id) {
473 case IDC_CUT: 473 case IDC_CUT:
474 *accelerator = ui::Accelerator(ui::VKEY_X, ui::EF_CONTROL_DOWN); 474 *accelerator =
475 ui::Accelerator(ui::VKEY_X, ui::EF_CONTROL_DOWN, ui::ET_KEY_PRESSED);
475 return true; 476 return true;
476 case IDC_COPY: 477 case IDC_COPY:
477 *accelerator = ui::Accelerator(ui::VKEY_C, ui::EF_CONTROL_DOWN); 478 *accelerator =
479 ui::Accelerator(ui::VKEY_C, ui::EF_CONTROL_DOWN, ui::ET_KEY_PRESSED);
478 return true; 480 return true;
479 case IDC_PASTE: 481 case IDC_PASTE:
480 *accelerator = ui::Accelerator(ui::VKEY_V, ui::EF_CONTROL_DOWN); 482 *accelerator =
483 ui::Accelerator(ui::VKEY_V, ui::EF_CONTROL_DOWN, ui::ET_KEY_PRESSED);
481 return true; 484 return true;
482 } 485 }
483 // Else, we retrieve the accelerator information from the accelerator table. 486 // Else, we retrieve the accelerator information from the accelerator table.
484 std::map<ui::Accelerator, int>::iterator it = accelerator_table_.begin(); 487 std::map<ui::Accelerator, int>::iterator it = accelerator_table_.begin();
485 for (; it != accelerator_table_.end(); ++it) { 488 for (; it != accelerator_table_.end(); ++it) {
486 if (it->second == cmd_id) { 489 if (it->second == cmd_id) {
487 *accelerator = it->first; 490 *accelerator = it->first;
488 return true; 491 return true;
489 } 492 }
490 } 493 }
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 event.os_event.wParam, event.os_event.lParam); 1174 event.os_event.wParam, event.os_event.lParam);
1172 return true; 1175 return true;
1173 } 1176 }
1174 #endif 1177 #endif
1175 1178
1176 views::FocusManager* focus_manager = GetFocusManager(); 1179 views::FocusManager* focus_manager = GetFocusManager();
1177 DCHECK(focus_manager); 1180 DCHECK(focus_manager);
1178 1181
1179 ui::Accelerator accelerator( 1182 ui::Accelerator accelerator(
1180 static_cast<ui::KeyboardCode>(event.windowsKeyCode), 1183 static_cast<ui::KeyboardCode>(event.windowsKeyCode),
1181 content::GetModifiersFromNativeWebKeyboardEvent(event)); 1184 content::GetModifiersFromNativeWebKeyboardEvent(event),
1182 if (event.type == WebKit::WebInputEvent::KeyUp) 1185 (event.type == WebKit::WebInputEvent::KeyUp) ?
1183 accelerator.set_type(ui::ET_KEY_RELEASED); 1186 ui::ET_KEY_RELEASED : ui::ET_KEY_PRESSED);
1184 1187
1185 // What we have to do here is as follows: 1188 // What we have to do here is as follows:
1186 // - If the |browser_| is for an app, do nothing. 1189 // - If the |browser_| is for an app, do nothing.
1187 // - If the |browser_| is not for an app, and the |accelerator| is not 1190 // - If the |browser_| is not for an app, and the |accelerator| is not
1188 // associated with the browser (e.g. an Ash shortcut), process it. 1191 // associated with the browser (e.g. an Ash shortcut), process it.
1189 // - If the |browser_| is not for an app, and the |accelerator| is associated 1192 // - If the |browser_| is not for an app, and the |accelerator| is associated
1190 // with the browser, and it is a reserved one (e.g. Ctrl-t), process it. 1193 // with the browser, and it is a reserved one (e.g. Ctrl-t), process it.
1191 // - If the |browser_| is not for an app, and the |accelerator| is associated 1194 // - If the |browser_| is not for an app, and the |accelerator| is associated
1192 // with the browser, and it is not a reserved one, do nothing. 1195 // with the browser, and it is not a reserved one, do nothing.
1193 1196
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
2163 } 2166 }
2164 2167
2165 // We don't need the Windows accelerator table anymore. 2168 // We don't need the Windows accelerator table anymore.
2166 free(accelerators); 2169 free(accelerators);
2167 #else 2170 #else
2168 views::FocusManager* focus_manager = GetFocusManager(); 2171 views::FocusManager* focus_manager = GetFocusManager();
2169 DCHECK(focus_manager); 2172 DCHECK(focus_manager);
2170 // Let's fill our own accelerator table. 2173 // Let's fill our own accelerator table.
2171 for (size_t i = 0; i < browser::kAcceleratorMapLength; ++i) { 2174 for (size_t i = 0; i < browser::kAcceleratorMapLength; ++i) {
2172 ui::Accelerator accelerator(browser::kAcceleratorMap[i].keycode, 2175 ui::Accelerator accelerator(browser::kAcceleratorMap[i].keycode,
2173 browser::kAcceleratorMap[i].modifiers); 2176 browser::kAcceleratorMap[i].modifiers,
2177 ui::ET_KEY_PRESSED);
2174 accelerator_table_[accelerator] = browser::kAcceleratorMap[i].command_id; 2178 accelerator_table_[accelerator] = browser::kAcceleratorMap[i].command_id;
2175 2179
2176 // Also register with the focus manager. 2180 // Also register with the focus manager.
2177 focus_manager->RegisterAccelerator( 2181 focus_manager->RegisterAccelerator(
2178 accelerator, ui::AcceleratorManager::kNormalPriority, this); 2182 accelerator, ui::AcceleratorManager::kNormalPriority, this);
2179 } 2183 }
2180 #endif 2184 #endif
2181 } 2185 }
2182 2186
2183 int BrowserView::GetCommandIDForAppCommandID(int app_command_id) const { 2187 int BrowserView::GetCommandIDForAppCommandID(int app_command_id) const {
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
2415 return; 2419 return;
2416 2420
2417 PasswordGenerationBubbleView* bubble = 2421 PasswordGenerationBubbleView* bubble =
2418 new PasswordGenerationBubbleView(bounds, 2422 new PasswordGenerationBubbleView(bounds,
2419 this, 2423 this,
2420 web_contents->GetRenderViewHost()); 2424 web_contents->GetRenderViewHost());
2421 views::BubbleDelegateView::CreateBubble(bubble); 2425 views::BubbleDelegateView::CreateBubble(bubble);
2422 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); 2426 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
2423 bubble->Show(); 2427 bubble->Show();
2424 } 2428 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/find_bar_host.cc ('k') | chrome/browser/ui/views/fullscreen_exit_bubble_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698