Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "chrome/browser/profiles/profile.h" | 5 #include "chrome/browser/profiles/profile.h" |
| 6 #include "chrome/browser/ui/host_desktop.h" | |
| 6 #include "chrome/browser/ui/views/accelerator_table.h" | 7 #include "chrome/browser/ui/views/accelerator_table.h" |
| 7 #include "ui/base/accelerators/accelerator.h" | 8 #include "ui/base/accelerators/accelerator.h" |
| 8 | 9 |
| 9 #if defined(USE_ASH) | 10 #if defined(USE_ASH) |
| 10 #include "ash/accelerators/accelerator_table.h" | 11 #include "ash/accelerators/accelerator_table.h" |
| 11 #endif // USE_ASH | 12 #endif // USE_ASH |
| 12 | 13 |
| 13 namespace chrome { | 14 namespace chrome { |
| 14 | 15 |
| 15 bool IsChromeAccelerator(const ui::Accelerator& accelerator, Profile* profile) { | 16 bool IsChromeAccelerator(const ui::Accelerator& accelerator, Profile* profile) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 28 for (std::vector<chrome::AcceleratorMapping>::const_iterator it = | 29 for (std::vector<chrome::AcceleratorMapping>::const_iterator it = |
| 29 accelerators.begin(); it != accelerators.end(); ++it) { | 30 accelerators.begin(); it != accelerators.end(); ++it) { |
| 30 if (it->keycode == accelerator.key_code() && | 31 if (it->keycode == accelerator.key_code() && |
| 31 it->modifiers == accelerator.modifiers()) | 32 it->modifiers == accelerator.modifiers()) |
| 32 return true; | 33 return true; |
| 33 } | 34 } |
| 34 | 35 |
| 35 return false; | 36 return false; |
| 36 } | 37 } |
| 37 | 38 |
| 39 ui::Accelerator GetPrimaryChromeAcceleratorForCommandId(int command_id) { | |
| 40 ui::Accelerator accelerator; | |
| 41 if (GetStandardAcceleratorForCommandId(command_id, &accelerator)) | |
|
sky
2014/02/06 16:03:16
nit: I would likely combine this if and 43.
| |
| 42 return accelerator; | |
| 43 if (GetAshAcceleratorForCommandId(command_id, | |
| 44 chrome::GetActiveDesktop(), | |
|
sky
2014/02/06 16:03:16
Using activedesktop like this is a bit dicey. Is t
Mike Wittman
2014/02/06 19:35:42
This is invoked from the extension command service
| |
| 45 &accelerator)) { | |
| 46 return accelerator; | |
| 47 } | |
| 48 | |
| 49 std::vector<chrome::AcceleratorMapping> accelerators = | |
| 50 chrome::GetAcceleratorList(); | |
| 51 for (size_t i = 0; i < accelerators.size(); ++i) { | |
| 52 if (accelerators[i].command_id == command_id) { | |
| 53 return ui::Accelerator(accelerators[i].keycode, | |
| 54 accelerators[i].modifiers); | |
| 55 } | |
| 56 } | |
| 57 | |
| 58 return ui::Accelerator(); | |
| 59 } | |
| 60 | |
| 38 } // namespace chrome | 61 } // namespace chrome |
| OLD | NEW |