Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / views / accelerator_utils_aura.cc
blob42f45929b60645c68ec7e48c23130d798f77804a
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
3 // found in the LICENSE file.
5 #include "chrome/browser/profiles/profile.h"
6 #include "chrome/browser/ui/host_desktop.h"
7 #include "chrome/browser/ui/views/accelerator_table.h"
8 #include "ui/base/accelerators/accelerator.h"
10 #if defined(USE_ASH)
11 #include "ash/accelerators/accelerator_table.h"
12 #endif // USE_ASH
14 namespace chrome {
16 bool IsChromeAccelerator(const ui::Accelerator& accelerator, Profile* profile) {
17 #if defined(USE_ASH)
18 for (size_t i = 0; i < ash::kAcceleratorDataLength; ++i) {
19 const ash::AcceleratorData& accel_data = ash::kAcceleratorData[i];
20 if (accel_data.keycode == accelerator.key_code() &&
21 accel_data.modifiers == accelerator.modifiers()) {
22 return true;
25 #endif
27 std::vector<chrome::AcceleratorMapping> accelerators =
28 chrome::GetAcceleratorList();
29 for (std::vector<chrome::AcceleratorMapping>::const_iterator it =
30 accelerators.begin(); it != accelerators.end(); ++it) {
31 if (it->keycode == accelerator.key_code() &&
32 it->modifiers == accelerator.modifiers())
33 return true;
36 return false;
39 ui::Accelerator GetPrimaryChromeAcceleratorForCommandId(int command_id) {
40 ui::Accelerator accelerator;
41 // GetAshAcceleratorForCommandId with HOST_DESKTOP_TYPE_ASH is used so we can
42 // find Ash accelerators if Ash is supported on this platform, even if it's
43 // not currently in use.
44 if (GetStandardAcceleratorForCommandId(command_id, &accelerator) ||
45 GetAshAcceleratorForCommandId(command_id,
46 HOST_DESKTOP_TYPE_ASH,
47 &accelerator)) {
48 return accelerator;
51 std::vector<chrome::AcceleratorMapping> accelerators =
52 chrome::GetAcceleratorList();
53 for (size_t i = 0; i < accelerators.size(); ++i) {
54 if (accelerators[i].command_id == command_id) {
55 return ui::Accelerator(accelerators[i].keycode,
56 accelerators[i].modifiers);
60 return ui::Accelerator();
63 } // namespace chrome