| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mash/browser_driver/browser_driver_application_delegate.h" | 5 #include "mash/browser_driver/browser_driver_application_delegate.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "components/mus/public/cpp/event_matcher.h" | 10 #include "components/mus/public/cpp/event_matcher.h" |
| 11 #include "mojo/shell/public/cpp/application_connection.h" | 11 #include "mojo/shell/public/cpp/application_connection.h" |
| 12 #include "mojo/shell/public/cpp/application_impl.h" | 12 #include "mojo/shell/public/cpp/application_impl.h" |
| 13 | 13 |
| 14 namespace mash { | 14 namespace mash { |
| 15 namespace browser_driver { | 15 namespace browser_driver { |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 enum class Accelerator : uint32_t { | 18 enum class Accelerator : uint32_t { |
| 19 NewWindow, | 19 NewWindow, |
| 20 NewTab, | 20 NewTab, |
| 21 NewIncognitoWindow, | 21 NewIncognitoWindow, |
| 22 }; | 22 }; |
| 23 | 23 |
| 24 struct AcceleratorSpec { | 24 struct AcceleratorSpec { |
| 25 Accelerator id; | 25 Accelerator id; |
| 26 mus::mojom::KeyboardCode keyboard_code; | 26 mus::mojom::KeyboardCode keyboard_code; |
| 27 mus::mojom::EventFlags event_flags; | 27 // A bitfield of kEventFlag* and kMouseEventFlag* values in |
| 28 // input_event_constants.mojom. |
| 29 int event_flags; |
| 28 }; | 30 }; |
| 29 | 31 |
| 30 AcceleratorSpec g_spec[] = { | 32 AcceleratorSpec g_spec[] = { |
| 31 { Accelerator::NewWindow, | 33 {Accelerator::NewWindow, mus::mojom::KeyboardCode::N, |
| 32 mus::mojom::KEYBOARD_CODE_N, | 34 mus::mojom::kEventFlagControlDown}, |
| 33 mus::mojom::EVENT_FLAGS_CONTROL_DOWN }, | 35 {Accelerator::NewTab, mus::mojom::KeyboardCode::T, |
| 34 { Accelerator::NewTab, | 36 mus::mojom::kEventFlagControlDown}, |
| 35 mus::mojom::KEYBOARD_CODE_T, | 37 {Accelerator::NewIncognitoWindow, mus::mojom::KeyboardCode::N, |
| 36 mus::mojom::EVENT_FLAGS_CONTROL_DOWN }, | 38 mus::mojom::kEventFlagControlDown | mus::mojom::kEventFlagShiftDown}, |
| 37 { Accelerator::NewIncognitoWindow, | |
| 38 mus::mojom::KEYBOARD_CODE_N, | |
| 39 static_cast<mus::mojom::EventFlags>(mus::mojom::EVENT_FLAGS_CONTROL_DOWN | | |
| 40 mus::mojom::EVENT_FLAGS_SHIFT_DOWN) }, | |
| 41 }; | 39 }; |
| 42 | 40 |
| 43 void AssertTrue(bool success) { | 41 void AssertTrue(bool success) { |
| 44 DCHECK(success); | 42 DCHECK(success); |
| 45 } | 43 } |
| 46 | 44 |
| 47 } // namespace | 45 } // namespace |
| 48 | 46 |
| 49 BrowserDriverApplicationDelegate::BrowserDriverApplicationDelegate() | 47 BrowserDriverApplicationDelegate::BrowserDriverApplicationDelegate() |
| 50 : app_(nullptr), | 48 : app_(nullptr), |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 for (const AcceleratorSpec& spec : g_spec) { | 96 for (const AcceleratorSpec& spec : g_spec) { |
| 99 registrar->AddAccelerator( | 97 registrar->AddAccelerator( |
| 100 static_cast<uint32_t>(spec.id), | 98 static_cast<uint32_t>(spec.id), |
| 101 mus::CreateKeyMatcher(spec.keyboard_code, spec.event_flags), | 99 mus::CreateKeyMatcher(spec.keyboard_code, spec.event_flags), |
| 102 base::Bind(&AssertTrue)); | 100 base::Bind(&AssertTrue)); |
| 103 } | 101 } |
| 104 } | 102 } |
| 105 | 103 |
| 106 } // namespace browser_driver | 104 } // namespace browser_driver |
| 107 } // namespace main | 105 } // namespace main |
| OLD | NEW |