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

Side by Side Diff: chrome/browser/ui/views/accelerator_utils_views.cc

Issue 143493005: Allow extensions to remove and override the bookmark shortcut key (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "ui/base/accelerators/accelerator.h" 5 #include "ui/base/accelerators/accelerator.h"
6 #include "chrome/browser/profiles/profile.h" 6 #include "chrome/browser/profiles/profile.h"
7 #include "chrome/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/browser_finder.h" 8 #include "chrome/browser/ui/browser_finder.h"
9 #include "chrome/browser/ui/views/accelerator_table.h"
9 #include "chrome/browser/ui/views/frame/browser_view.h" 10 #include "chrome/browser/ui/views/frame/browser_view.h"
10 11
11 namespace chrome { 12 namespace chrome {
12 13
13 #if !defined(USE_AURA) 14 #if !defined(USE_AURA)
14 15
15 bool IsChromeAccelerator(const ui::Accelerator& accelerator, Profile* profile) { 16 bool IsChromeAccelerator(const ui::Accelerator& accelerator, Profile* profile) {
16 Browser* browser = chrome::FindLastActiveWithProfile( 17 Browser* browser = chrome::FindLastActiveWithProfile(
17 profile, chrome::HOST_DESKTOP_TYPE_NATIVE); 18 profile, chrome::HOST_DESKTOP_TYPE_NATIVE);
18 if (!browser) 19 if (!browser)
19 return false; 20 return false;
20 BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow( 21 BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow(
21 browser->window()->GetNativeWindow()); 22 browser->window()->GetNativeWindow());
22 return browser_view->IsAcceleratorRegistered(accelerator); 23 return browser_view->IsAcceleratorRegistered(accelerator);
23 } 24 }
24 25
25 #endif // !USE_AURA 26 #endif // !USE_AURA
26 27
28 ui::Accelerator GetChromeAcceleratorForCommandId(int command_id) {
sky 2014/02/04 22:52:54 Accelerators handled in ash aren't covered here. A
Mike Wittman 2014/02/05 18:10:46 I've added a check for Ash accelerators (and stand
sky 2014/02/06 16:03:16 Ah, ok. Good point.
29 std::vector<chrome::AcceleratorMapping> accelerators =
30 chrome::GetAcceleratorList();
31
32 for (size_t i = 0; i < accelerators.size(); ++i) {
33 if (accelerators[i].command_id == command_id) {
34 return ui::Accelerator(accelerators[i].keycode,
35 accelerators[i].modifiers);
36 }
37 }
38
39 return ui::Accelerator();
40 }
41
27 } // namespace chrome 42 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698