OLD | NEW |
1 // Copyright 2016 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/webtest/webtest.h" | 5 #include "mash/webtest/webtest.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
14 #include "mash/public/interfaces/launchable.mojom.h" | 14 #include "mash/public/interfaces/launchable.mojom.h" |
15 #include "mojo/public/c/system/main.h" | 15 #include "mojo/public/c/system/main.h" |
16 #include "services/navigation/public/interfaces/view.mojom.h" | 16 #include "services/navigation/public/interfaces/view.mojom.h" |
17 #include "services/shell/public/cpp/application_runner.h" | 17 #include "services/shell/public/cpp/application_runner.h" |
18 #include "services/shell/public/cpp/connector.h" | 18 #include "services/shell/public/cpp/connector.h" |
19 #include "services/shell/public/cpp/shell_client.h" | 19 #include "services/shell/public/cpp/service.h" |
20 #include "services/tracing/public/cpp/tracing_impl.h" | 20 #include "services/tracing/public/cpp/tracing_impl.h" |
21 #include "services/ui/public/cpp/window.h" | 21 #include "services/ui/public/cpp/window.h" |
22 #include "services/ui/public/cpp/window_tree_client.h" | 22 #include "services/ui/public/cpp/window_tree_client.h" |
23 #include "ui/aura/mus/mus_util.h" | 23 #include "ui/aura/mus/mus_util.h" |
24 #include "ui/gfx/canvas.h" | 24 #include "ui/gfx/canvas.h" |
25 #include "ui/gfx/paint_throbber.h" | 25 #include "ui/gfx/paint_throbber.h" |
26 #include "ui/native_theme/native_theme.h" | 26 #include "ui/native_theme/native_theme.h" |
27 #include "ui/views/background.h" | 27 #include "ui/views/background.h" |
28 #include "ui/views/controls/button/label_button.h" | 28 #include "ui/views/controls/button/label_button.h" |
29 #include "ui/views/controls/textfield/textfield.h" | 29 #include "ui/views/controls/textfield/textfield.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 } | 150 } |
151 | 151 |
152 void Webtest::RemoveWindow(views::Widget* window) { | 152 void Webtest::RemoveWindow(views::Widget* window) { |
153 auto it = std::find(windows_.begin(), windows_.end(), window); | 153 auto it = std::find(windows_.begin(), windows_.end(), window); |
154 DCHECK(it != windows_.end()); | 154 DCHECK(it != windows_.end()); |
155 windows_.erase(it); | 155 windows_.erase(it); |
156 if (windows_.empty()) | 156 if (windows_.empty()) |
157 base::MessageLoop::current()->QuitWhenIdle(); | 157 base::MessageLoop::current()->QuitWhenIdle(); |
158 } | 158 } |
159 | 159 |
160 void Webtest::Initialize(shell::Connector* connector, | 160 void Webtest::OnStart(shell::Connector* connector, |
161 const shell::Identity& identity, | 161 const shell::Identity& identity, |
162 uint32_t id) { | 162 uint32_t id) { |
163 connector_ = connector; | 163 connector_ = connector; |
164 tracing_.Initialize(connector, identity.name()); | 164 tracing_.Initialize(connector, identity.name()); |
165 | 165 |
166 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak")); | 166 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak")); |
167 window_manager_connection_ = | 167 window_manager_connection_ = |
168 views::WindowManagerConnection::Create(connector, identity); | 168 views::WindowManagerConnection::Create(connector, identity); |
169 } | 169 } |
170 | 170 |
171 bool Webtest::AcceptConnection(shell::Connection* connection) { | 171 bool Webtest::OnConnect(shell::Connection* connection) { |
172 connection->AddInterface<mojom::Launchable>(this); | 172 connection->AddInterface<mojom::Launchable>(this); |
173 return true; | 173 return true; |
174 } | 174 } |
175 | 175 |
176 void Webtest::Launch(uint32_t what, mojom::LaunchMode how) { | 176 void Webtest::Launch(uint32_t what, mojom::LaunchMode how) { |
177 bool reuse = how == mojom::LaunchMode::REUSE || | 177 bool reuse = how == mojom::LaunchMode::REUSE || |
178 how == mojom::LaunchMode::DEFAULT; | 178 how == mojom::LaunchMode::DEFAULT; |
179 if (reuse && !windows_.empty()) { | 179 if (reuse && !windows_.empty()) { |
180 windows_.back()->Activate(); | 180 windows_.back()->Activate(); |
181 return; | 181 return; |
(...skipping 14 matching lines...) Expand all Loading... |
196 AddWindow(window); | 196 AddWindow(window); |
197 } | 197 } |
198 | 198 |
199 void Webtest::Create(shell::Connection* connection, | 199 void Webtest::Create(shell::Connection* connection, |
200 mojom::LaunchableRequest request) { | 200 mojom::LaunchableRequest request) { |
201 bindings_.AddBinding(this, std::move(request)); | 201 bindings_.AddBinding(this, std::move(request)); |
202 } | 202 } |
203 | 203 |
204 } // namespace webtest | 204 } // namespace webtest |
205 } // namespace mash | 205 } // namespace mash |
OLD | NEW |