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 "base/message_loop/message_loop.h" |
10 #include "components/mus/public/cpp/event_matcher.h" | 11 #include "components/mus/public/cpp/event_matcher.h" |
11 #include "mojo/shell/public/cpp/connection.h" | 12 #include "mojo/shell/public/cpp/connection.h" |
12 #include "mojo/shell/public/cpp/connector.h" | 13 #include "mojo/shell/public/cpp/connector.h" |
13 | 14 |
14 namespace mash { | 15 namespace mash { |
15 namespace browser_driver { | 16 namespace browser_driver { |
16 namespace { | 17 namespace { |
17 | 18 |
18 enum class Accelerator : uint32_t { | 19 enum class Accelerator : uint32_t { |
19 NewWindow, | 20 NewWindow, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 uint32_t id) { | 57 uint32_t id) { |
57 connector_ = connector; | 58 connector_ = connector; |
58 AddAccelerators(); | 59 AddAccelerators(); |
59 } | 60 } |
60 | 61 |
61 bool BrowserDriverApplicationDelegate::AcceptConnection( | 62 bool BrowserDriverApplicationDelegate::AcceptConnection( |
62 mojo::Connection* connection) { | 63 mojo::Connection* connection) { |
63 return true; | 64 return true; |
64 } | 65 } |
65 | 66 |
| 67 void BrowserDriverApplicationDelegate::ShellConnectionLost() { |
| 68 base::MessageLoop::current()->QuitWhenIdle(); |
| 69 } |
| 70 |
66 void BrowserDriverApplicationDelegate::OnAccelerator( | 71 void BrowserDriverApplicationDelegate::OnAccelerator( |
67 uint32_t id, mus::mojom::EventPtr event) { | 72 uint32_t id, mus::mojom::EventPtr event) { |
68 switch (static_cast<Accelerator>(id)) { | 73 switch (static_cast<Accelerator>(id)) { |
69 case Accelerator::NewWindow: | 74 case Accelerator::NewWindow: |
70 case Accelerator::NewTab: | 75 case Accelerator::NewTab: |
71 case Accelerator::NewIncognitoWindow: | 76 case Accelerator::NewIncognitoWindow: |
72 connector_->Connect("exe:chrome"); | 77 connector_->Connect("exe:chrome"); |
73 // TODO(beng): have Chrome export a service that allows it to be driven by | 78 // TODO(beng): have Chrome export a service that allows it to be driven by |
74 // this driver, e.g. to open new tabs, incognito windows, etc. | 79 // this driver, e.g. to open new tabs, incognito windows, etc. |
75 break; | 80 break; |
(...skipping 21 matching lines...) Expand all Loading... |
97 for (const AcceleratorSpec& spec : g_spec) { | 102 for (const AcceleratorSpec& spec : g_spec) { |
98 registrar->AddAccelerator( | 103 registrar->AddAccelerator( |
99 static_cast<uint32_t>(spec.id), | 104 static_cast<uint32_t>(spec.id), |
100 mus::CreateKeyMatcher(spec.keyboard_code, spec.event_flags), | 105 mus::CreateKeyMatcher(spec.keyboard_code, spec.event_flags), |
101 base::Bind(&AssertTrue)); | 106 base::Bind(&AssertTrue)); |
102 } | 107 } |
103 } | 108 } |
104 | 109 |
105 } // namespace browser_driver | 110 } // namespace browser_driver |
106 } // namespace main | 111 } // namespace main |
OLD | NEW |