| 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" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 } | 149 } |
| 150 | 150 |
| 151 void Webtest::RemoveWindow(views::Widget* window) { | 151 void Webtest::RemoveWindow(views::Widget* window) { |
| 152 auto it = std::find(windows_.begin(), windows_.end(), window); | 152 auto it = std::find(windows_.begin(), windows_.end(), window); |
| 153 DCHECK(it != windows_.end()); | 153 DCHECK(it != windows_.end()); |
| 154 windows_.erase(it); | 154 windows_.erase(it); |
| 155 if (windows_.empty()) | 155 if (windows_.empty()) |
| 156 base::MessageLoop::current()->QuitWhenIdle(); | 156 base::MessageLoop::current()->QuitWhenIdle(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void Webtest::OnStart(const shell::Identity& identity) { | 159 void Webtest::OnStart(const service_manager::Identity& identity) { |
| 160 tracing_.Initialize(connector(), identity.name()); | 160 tracing_.Initialize(connector(), identity.name()); |
| 161 | 161 |
| 162 aura_init_.reset( | 162 aura_init_.reset( |
| 163 new views::AuraInit(connector(), "views_mus_resources.pak")); | 163 new views::AuraInit(connector(), "views_mus_resources.pak")); |
| 164 window_manager_connection_ = | 164 window_manager_connection_ = |
| 165 views::WindowManagerConnection::Create(connector(), identity); | 165 views::WindowManagerConnection::Create(connector(), identity); |
| 166 } | 166 } |
| 167 | 167 |
| 168 bool Webtest::OnConnect(const shell::Identity& remote_identity, | 168 bool Webtest::OnConnect(const service_manager::Identity& remote_identity, |
| 169 shell::InterfaceRegistry* registry) { | 169 service_manager::InterfaceRegistry* registry) { |
| 170 registry->AddInterface<mojom::Launchable>(this); | 170 registry->AddInterface<mojom::Launchable>(this); |
| 171 return true; | 171 return true; |
| 172 } | 172 } |
| 173 | 173 |
| 174 void Webtest::Launch(uint32_t what, mojom::LaunchMode how) { | 174 void Webtest::Launch(uint32_t what, mojom::LaunchMode how) { |
| 175 bool reuse = how == mojom::LaunchMode::REUSE || | 175 bool reuse = how == mojom::LaunchMode::REUSE || |
| 176 how == mojom::LaunchMode::DEFAULT; | 176 how == mojom::LaunchMode::DEFAULT; |
| 177 if (reuse && !windows_.empty()) { | 177 if (reuse && !windows_.empty()) { |
| 178 windows_.back()->Activate(); | 178 windows_.back()->Activate(); |
| 179 return; | 179 return; |
| 180 } | 180 } |
| 181 | 181 |
| 182 navigation::mojom::ViewFactoryPtr view_factory; | 182 navigation::mojom::ViewFactoryPtr view_factory; |
| 183 connector()->ConnectToInterface("exe:navigation", &view_factory); | 183 connector()->ConnectToInterface("exe:navigation", &view_factory); |
| 184 navigation::mojom::ViewPtr view; | 184 navigation::mojom::ViewPtr view; |
| 185 navigation::mojom::ViewClientPtr view_client; | 185 navigation::mojom::ViewClientPtr view_client; |
| 186 navigation::mojom::ViewClientRequest view_client_request = | 186 navigation::mojom::ViewClientRequest view_client_request = |
| 187 GetProxy(&view_client); | 187 GetProxy(&view_client); |
| 188 view_factory->CreateView(std::move(view_client), GetProxy(&view)); | 188 view_factory->CreateView(std::move(view_client), GetProxy(&view)); |
| 189 UI* ui = new UI(this, std::move(view), std::move(view_client_request)); | 189 UI* ui = new UI(this, std::move(view), std::move(view_client_request)); |
| 190 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( | 190 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( |
| 191 ui, nullptr, gfx::Rect(50, 10, 600, 600)); | 191 ui, nullptr, gfx::Rect(50, 10, 600, 600)); |
| 192 ui->NavigateTo(GURL("http://www.theverge.com/")); | 192 ui->NavigateTo(GURL("http://www.theverge.com/")); |
| 193 window->Show(); | 193 window->Show(); |
| 194 AddWindow(window); | 194 AddWindow(window); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void Webtest::Create(const shell::Identity& remote_identity, | 197 void Webtest::Create(const service_manager::Identity& remote_identity, |
| 198 mojom::LaunchableRequest request) { | 198 mojom::LaunchableRequest request) { |
| 199 bindings_.AddBinding(this, std::move(request)); | 199 bindings_.AddBinding(this, std::move(request)); |
| 200 } | 200 } |
| 201 | 201 |
| 202 } // namespace webtest | 202 } // namespace webtest |
| 203 } // namespace mash | 203 } // namespace mash |
| OLD | NEW |