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

Side by Side Diff: mash/app_driver/app_driver.cc

Issue 2092343002: Touch HUD app for mustash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change window manager connection unittest to original Created 4 years, 5 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
« no previous file with comments | « mash/app_driver/BUILD.gn ('k') | mash/touch_hud/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 EnableTouchHud,
24 NewChromeWindow, 25 NewChromeWindow,
25 NewChromeTab, 26 NewChromeTab,
26 NewChromeIncognitoWindow, 27 NewChromeIncognitoWindow,
27 ShowTaskManager, 28 ShowTaskManager,
28 }; 29 };
29 30
30 struct AcceleratorSpec { 31 struct AcceleratorSpec {
31 Accelerator id; 32 Accelerator id;
32 ui::mojom::KeyboardCode keyboard_code; 33 ui::mojom::KeyboardCode keyboard_code;
33 // A bitfield of kEventFlag* and kMouseEventFlag* values in 34 // A bitfield of kEventFlag* and kMouseEventFlag* values in
34 // input_event_constants.mojom. 35 // input_event_constants.mojom.
35 int event_flags; 36 int event_flags;
36 }; 37 };
37 38
38 AcceleratorSpec g_spec[] = { 39 AcceleratorSpec g_spec[] = {
40 {Accelerator::EnableTouchHud, ui::mojom::KeyboardCode::P,
41 ui::mojom::kEventFlagControlDown | ui::mojom::kEventFlagAltDown},
39 {Accelerator::NewChromeWindow, ui::mojom::KeyboardCode::N, 42 {Accelerator::NewChromeWindow, ui::mojom::KeyboardCode::N,
40 ui::mojom::kEventFlagControlDown}, 43 ui::mojom::kEventFlagControlDown},
41 {Accelerator::NewChromeTab, ui::mojom::KeyboardCode::T, 44 {Accelerator::NewChromeTab, ui::mojom::KeyboardCode::T,
42 ui::mojom::kEventFlagControlDown}, 45 ui::mojom::kEventFlagControlDown},
43 {Accelerator::NewChromeIncognitoWindow, ui::mojom::KeyboardCode::N, 46 {Accelerator::NewChromeIncognitoWindow, ui::mojom::KeyboardCode::N,
44 ui::mojom::kEventFlagControlDown | ui::mojom::kEventFlagShiftDown}, 47 ui::mojom::kEventFlagControlDown | ui::mojom::kEventFlagShiftDown},
45 {Accelerator::ShowTaskManager, ui::mojom::KeyboardCode::ESCAPE, 48 {Accelerator::ShowTaskManager, ui::mojom::KeyboardCode::ESCAPE,
46 ui::mojom::kEventFlagShiftDown}, 49 ui::mojom::kEventFlagShiftDown},
47 }; 50 };
48 51
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 106 }
104 107
105 void AppDriver::OnAccelerator(uint32_t id, std::unique_ptr<ui::Event> event) { 108 void AppDriver::OnAccelerator(uint32_t id, std::unique_ptr<ui::Event> event) {
106 struct LaunchOptions { 109 struct LaunchOptions {
107 uint32_t option; 110 uint32_t option;
108 const char* app; 111 const char* app;
109 LaunchMode mode; 112 LaunchMode mode;
110 }; 113 };
111 114
112 std::map<Accelerator, LaunchOptions> options{ 115 std::map<Accelerator, LaunchOptions> options{
116 {Accelerator::EnableTouchHud,
117 {mojom::kWindow, "mojo:touch_hud", LaunchMode::DEFAULT}},
113 {Accelerator::NewChromeWindow, 118 {Accelerator::NewChromeWindow,
114 {mojom::kWindow, "exe:chrome", LaunchMode::MAKE_NEW}}, 119 {mojom::kWindow, "exe:chrome", LaunchMode::MAKE_NEW}},
115 {Accelerator::NewChromeTab, 120 {Accelerator::NewChromeTab,
116 {mojom::kDocument, "exe:chrome", LaunchMode::MAKE_NEW}}, 121 {mojom::kDocument, "exe:chrome", LaunchMode::MAKE_NEW}},
117 {Accelerator::NewChromeIncognitoWindow, 122 {Accelerator::NewChromeIncognitoWindow,
118 {mojom::kIncognitoWindow, "exe:chrome", LaunchMode::MAKE_NEW}}, 123 {mojom::kIncognitoWindow, "exe:chrome", LaunchMode::MAKE_NEW}},
119 {Accelerator::ShowTaskManager, 124 {Accelerator::ShowTaskManager,
120 {mojom::kWindow, "mojo:task_viewer", LaunchMode::DEFAULT}}, 125 {mojom::kWindow, "mojo:task_viewer", LaunchMode::DEFAULT}},
121 }; 126 };
122 127
123 const auto iter = options.find(static_cast<Accelerator>(id)); 128 const auto iter = options.find(static_cast<Accelerator>(id));
124 DCHECK(iter != options.end()); 129 DCHECK(iter != options.end());
125 const LaunchOptions& entry = iter->second; 130 const LaunchOptions& entry = iter->second;
126 LaunchablePtr launchable; 131 LaunchablePtr launchable;
127 connector_->ConnectToInterface(entry.app, &launchable); 132 connector_->ConnectToInterface(entry.app, &launchable);
128 launchable->Launch(entry.option, entry.mode); 133 launchable->Launch(entry.option, entry.mode);
129 } 134 }
130 135
131 void AppDriver::AddAccelerators() { 136 void AppDriver::AddAccelerators() {
132 connector_->ConnectToInterface("mojo:catalog", &catalog_); 137 connector_->ConnectToInterface("mojo:catalog", &catalog_);
133 catalog_->GetEntriesProvidingClass( 138 catalog_->GetEntriesProvidingClass(
134 "mus:window_manager", base::Bind(&AppDriver::OnAvailableCatalogEntries, 139 "mus:window_manager", base::Bind(&AppDriver::OnAvailableCatalogEntries,
135 weak_factory_.GetWeakPtr())); 140 weak_factory_.GetWeakPtr()));
136 } 141 }
137 142
138 } // namespace app_driver 143 } // namespace app_driver
139 } // namespace mash 144 } // namespace mash
OLDNEW
« no previous file with comments | « mash/app_driver/BUILD.gn ('k') | mash/touch_hud/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698