| 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/app_driver/app_driver.h" | 5 #include "mash/app_driver/app_driver.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 "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "mash/public/interfaces/launchable.mojom.h" | 11 #include "mash/public/interfaces/launchable.mojom.h" |
| 12 #include "services/shell/public/cpp/connection.h" | 12 #include "services/shell/public/cpp/connection.h" |
| 13 #include "services/shell/public/cpp/connector.h" | 13 #include "services/shell/public/cpp/connector.h" |
| 14 #include "services/ui/common/event_matcher_util.h" | 14 #include "services/ui/common/event_matcher_util.h" |
| 15 | 15 |
| 16 using mash::mojom::LaunchablePtr; | 16 using mash::mojom::LaunchablePtr; |
| 17 using mash::mojom::LaunchMode; | 17 using mash::mojom::LaunchMode; |
| 18 | 18 |
| 19 namespace mash { | 19 namespace mash { |
| 20 namespace app_driver { | 20 namespace app_driver { |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 enum class Accelerator : uint32_t { | 23 enum class Accelerator : uint32_t { |
| 24 NewChromeWindow, | 24 NewChromeWindow, |
| 25 NewChromeTab, | 25 NewChromeTab, |
| 26 NewChromeIncognitoWindow, | 26 NewChromeIncognitoWindow, |
| 27 ShowTaskManager, | 27 ShowTaskManager, |
| 28 ToggleTouchHud, | |
| 29 }; | 28 }; |
| 30 | 29 |
| 31 struct AcceleratorSpec { | 30 struct AcceleratorSpec { |
| 32 Accelerator id; | 31 Accelerator id; |
| 33 ui::mojom::KeyboardCode keyboard_code; | 32 ui::mojom::KeyboardCode keyboard_code; |
| 34 // A bitfield of kEventFlag* and kMouseEventFlag* values in | 33 // A bitfield of kEventFlag* and kMouseEventFlag* values in |
| 35 // input_event_constants.mojom. | 34 // input_event_constants.mojom. |
| 36 int event_flags; | 35 int event_flags; |
| 37 }; | 36 }; |
| 38 | 37 |
| 39 AcceleratorSpec g_spec[] = { | 38 AcceleratorSpec g_spec[] = { |
| 40 {Accelerator::NewChromeWindow, ui::mojom::KeyboardCode::N, | 39 {Accelerator::NewChromeWindow, ui::mojom::KeyboardCode::N, |
| 41 ui::mojom::kEventFlagControlDown}, | 40 ui::mojom::kEventFlagControlDown}, |
| 42 {Accelerator::NewChromeTab, ui::mojom::KeyboardCode::T, | 41 {Accelerator::NewChromeTab, ui::mojom::KeyboardCode::T, |
| 43 ui::mojom::kEventFlagControlDown}, | 42 ui::mojom::kEventFlagControlDown}, |
| 44 {Accelerator::NewChromeIncognitoWindow, ui::mojom::KeyboardCode::N, | 43 {Accelerator::NewChromeIncognitoWindow, ui::mojom::KeyboardCode::N, |
| 45 ui::mojom::kEventFlagControlDown | ui::mojom::kEventFlagShiftDown}, | 44 ui::mojom::kEventFlagControlDown | ui::mojom::kEventFlagShiftDown}, |
| 46 {Accelerator::ShowTaskManager, ui::mojom::KeyboardCode::ESCAPE, | 45 {Accelerator::ShowTaskManager, ui::mojom::KeyboardCode::ESCAPE, |
| 47 ui::mojom::kEventFlagShiftDown}, | 46 ui::mojom::kEventFlagShiftDown}, |
| 48 {Accelerator::ToggleTouchHud, ui::mojom::KeyboardCode::P, | |
| 49 ui::mojom::kEventFlagControlDown | ui::mojom::kEventFlagAltDown}, | |
| 50 }; | 47 }; |
| 51 | 48 |
| 52 void AssertTrue(bool success) { | 49 void AssertTrue(bool success) { |
| 53 DCHECK(success); | 50 DCHECK(success); |
| 54 } | 51 } |
| 55 | 52 |
| 56 void DoNothing() {} | 53 void DoNothing() {} |
| 57 | 54 |
| 58 } // namespace | 55 } // namespace |
| 59 | 56 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 109 |
| 113 std::map<Accelerator, LaunchOptions> options{ | 110 std::map<Accelerator, LaunchOptions> options{ |
| 114 {Accelerator::NewChromeWindow, | 111 {Accelerator::NewChromeWindow, |
| 115 {mojom::kWindow, "exe:chrome", LaunchMode::MAKE_NEW}}, | 112 {mojom::kWindow, "exe:chrome", LaunchMode::MAKE_NEW}}, |
| 116 {Accelerator::NewChromeTab, | 113 {Accelerator::NewChromeTab, |
| 117 {mojom::kDocument, "exe:chrome", LaunchMode::MAKE_NEW}}, | 114 {mojom::kDocument, "exe:chrome", LaunchMode::MAKE_NEW}}, |
| 118 {Accelerator::NewChromeIncognitoWindow, | 115 {Accelerator::NewChromeIncognitoWindow, |
| 119 {mojom::kIncognitoWindow, "exe:chrome", LaunchMode::MAKE_NEW}}, | 116 {mojom::kIncognitoWindow, "exe:chrome", LaunchMode::MAKE_NEW}}, |
| 120 {Accelerator::ShowTaskManager, | 117 {Accelerator::ShowTaskManager, |
| 121 {mojom::kWindow, "mojo:task_viewer", LaunchMode::DEFAULT}}, | 118 {mojom::kWindow, "mojo:task_viewer", LaunchMode::DEFAULT}}, |
| 122 {Accelerator::ToggleTouchHud, | |
| 123 {mojom::kWindow, "mojo:touch_hud", LaunchMode::DEFAULT}}, | |
| 124 }; | 119 }; |
| 125 | 120 |
| 126 const auto iter = options.find(static_cast<Accelerator>(id)); | 121 const auto iter = options.find(static_cast<Accelerator>(id)); |
| 127 DCHECK(iter != options.end()); | 122 DCHECK(iter != options.end()); |
| 128 const LaunchOptions& entry = iter->second; | 123 const LaunchOptions& entry = iter->second; |
| 129 LaunchablePtr launchable; | 124 LaunchablePtr launchable; |
| 130 connector()->ConnectToInterface(entry.app, &launchable); | 125 connector()->ConnectToInterface(entry.app, &launchable); |
| 131 launchable->Launch(entry.option, entry.mode); | 126 launchable->Launch(entry.option, entry.mode); |
| 132 } | 127 } |
| 133 | 128 |
| 134 void AppDriver::AddAccelerators() { | 129 void AppDriver::AddAccelerators() { |
| 135 connector()->ConnectToInterface("mojo:catalog", &catalog_); | 130 connector()->ConnectToInterface("mojo:catalog", &catalog_); |
| 136 catalog_->GetEntriesProvidingClass( | 131 catalog_->GetEntriesProvidingClass( |
| 137 "mus:window_manager", base::Bind(&AppDriver::OnAvailableCatalogEntries, | 132 "mus:window_manager", base::Bind(&AppDriver::OnAvailableCatalogEntries, |
| 138 weak_factory_.GetWeakPtr())); | 133 weak_factory_.GetWeakPtr())); |
| 139 } | 134 } |
| 140 | 135 |
| 141 } // namespace app_driver | 136 } // namespace app_driver |
| 142 } // namespace mash | 137 } // namespace mash |
| OLD | NEW |