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

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

Issue 2179023004: Make Service own ServiceContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 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/webtest/webtest.h ('k') | media/mojo/services/mojo_media_application.h » ('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 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::OnStart(shell::Connector* connector, 160 void Webtest::OnStart(const shell::Identity& identity) {
161 const shell::Identity& identity, 161 tracing_.Initialize(connector(), identity.name());
162 uint32_t id) {
163 connector_ = connector;
164 tracing_.Initialize(connector, identity.name());
165 162
166 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak")); 163 aura_init_.reset(
164 new views::AuraInit(connector(), "views_mus_resources.pak"));
167 window_manager_connection_ = 165 window_manager_connection_ =
168 views::WindowManagerConnection::Create(connector, identity); 166 views::WindowManagerConnection::Create(connector(), identity);
169 } 167 }
170 168
171 bool Webtest::OnConnect(shell::Connection* connection) { 169 bool Webtest::OnConnect(shell::Connection* connection) {
172 connection->AddInterface<mojom::Launchable>(this); 170 connection->AddInterface<mojom::Launchable>(this);
173 return true; 171 return true;
174 } 172 }
175 173
176 void Webtest::Launch(uint32_t what, mojom::LaunchMode how) { 174 void Webtest::Launch(uint32_t what, mojom::LaunchMode how) {
177 bool reuse = how == mojom::LaunchMode::REUSE || 175 bool reuse = how == mojom::LaunchMode::REUSE ||
178 how == mojom::LaunchMode::DEFAULT; 176 how == mojom::LaunchMode::DEFAULT;
179 if (reuse && !windows_.empty()) { 177 if (reuse && !windows_.empty()) {
180 windows_.back()->Activate(); 178 windows_.back()->Activate();
181 return; 179 return;
182 } 180 }
183 181
184 navigation::mojom::ViewFactoryPtr view_factory; 182 navigation::mojom::ViewFactoryPtr view_factory;
185 connector_->ConnectToInterface("exe:navigation", &view_factory); 183 connector()->ConnectToInterface("exe:navigation", &view_factory);
186 navigation::mojom::ViewPtr view; 184 navigation::mojom::ViewPtr view;
187 navigation::mojom::ViewClientPtr view_client; 185 navigation::mojom::ViewClientPtr view_client;
188 navigation::mojom::ViewClientRequest view_client_request = 186 navigation::mojom::ViewClientRequest view_client_request =
189 GetProxy(&view_client); 187 GetProxy(&view_client);
190 view_factory->CreateView(std::move(view_client), GetProxy(&view)); 188 view_factory->CreateView(std::move(view_client), GetProxy(&view));
191 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));
192 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( 190 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds(
193 ui, nullptr, gfx::Rect(50, 10, 600, 600)); 191 ui, nullptr, gfx::Rect(50, 10, 600, 600));
194 ui->NavigateTo(GURL("http://www.theverge.com/")); 192 ui->NavigateTo(GURL("http://www.theverge.com/"));
195 window->Show(); 193 window->Show();
196 AddWindow(window); 194 AddWindow(window);
197 } 195 }
198 196
199 void Webtest::Create(const shell::Identity& remote_identity, 197 void Webtest::Create(const shell::Identity& remote_identity,
200 mojom::LaunchableRequest request) { 198 mojom::LaunchableRequest request) {
201 bindings_.AddBinding(this, std::move(request)); 199 bindings_.AddBinding(this, std::move(request));
202 } 200 }
203 201
204 } // namespace webtest 202 } // namespace webtest
205 } // namespace mash 203 } // namespace mash
OLDNEW
« no previous file with comments | « mash/webtest/webtest.h ('k') | media/mojo/services/mojo_media_application.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698