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

Side by Side Diff: mash/catalog_viewer/catalog_viewer.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
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/catalog_viewer/catalog_viewer.h" 5 #include "mash/catalog_viewer/catalog_viewer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 CatalogViewer::~CatalogViewer() {} 159 CatalogViewer::~CatalogViewer() {}
160 160
161 void CatalogViewer::RemoveWindow(views::Widget* window) { 161 void CatalogViewer::RemoveWindow(views::Widget* window) {
162 auto it = std::find(windows_.begin(), windows_.end(), window); 162 auto it = std::find(windows_.begin(), windows_.end(), window);
163 DCHECK(it != windows_.end()); 163 DCHECK(it != windows_.end());
164 windows_.erase(it); 164 windows_.erase(it);
165 if (windows_.empty()) 165 if (windows_.empty())
166 base::MessageLoop::current()->QuitWhenIdle(); 166 base::MessageLoop::current()->QuitWhenIdle();
167 } 167 }
168 168
169 void CatalogViewer::OnStart(shell::Connector* connector, 169 void CatalogViewer::OnStart(const shell::Identity& identity) {
170 const shell::Identity& identity, 170 tracing_.Initialize(connector(), identity.name());
171 uint32_t id) {
172 connector_ = connector;
173 tracing_.Initialize(connector, identity.name());
174 171
175 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak")); 172 aura_init_.reset(
173 new views::AuraInit(connector(), "views_mus_resources.pak"));
176 window_manager_connection_ = 174 window_manager_connection_ =
177 views::WindowManagerConnection::Create(connector, identity); 175 views::WindowManagerConnection::Create(connector(), identity);
178 } 176 }
179 177
180 bool CatalogViewer::OnConnect(shell::Connection* connection) { 178 bool CatalogViewer::OnConnect(shell::Connection* connection) {
181 connection->AddInterface<mojom::Launchable>(this); 179 connection->AddInterface<mojom::Launchable>(this);
182 return true; 180 return true;
183 } 181 }
184 182
185 void CatalogViewer::Launch(uint32_t what, mojom::LaunchMode how) { 183 void CatalogViewer::Launch(uint32_t what, mojom::LaunchMode how) {
186 bool reuse = how == mojom::LaunchMode::REUSE || 184 bool reuse = how == mojom::LaunchMode::REUSE ||
187 how == mojom::LaunchMode::DEFAULT; 185 how == mojom::LaunchMode::DEFAULT;
188 if (reuse && !windows_.empty()) { 186 if (reuse && !windows_.empty()) {
189 windows_.back()->Activate(); 187 windows_.back()->Activate();
190 return; 188 return;
191 } 189 }
192 catalog::mojom::CatalogPtr catalog; 190 catalog::mojom::CatalogPtr catalog;
193 connector_->ConnectToInterface("mojo:catalog", &catalog); 191 connector()->ConnectToInterface("mojo:catalog", &catalog);
194 192
195 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( 193 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds(
196 new CatalogViewerContents(this, std::move(catalog)), nullptr, 194 new CatalogViewerContents(this, std::move(catalog)), nullptr,
197 gfx::Rect(25, 25, 500, 600)); 195 gfx::Rect(25, 25, 500, 600));
198 window->Show(); 196 window->Show();
199 windows_.push_back(window); 197 windows_.push_back(window);
200 } 198 }
201 199
202 void CatalogViewer::Create(const shell::Identity& remote_identity, 200 void CatalogViewer::Create(const shell::Identity& remote_identity,
203 mojom::LaunchableRequest request) { 201 mojom::LaunchableRequest request) {
204 bindings_.AddBinding(this, std::move(request)); 202 bindings_.AddBinding(this, std::move(request));
205 } 203 }
206 204
207 } // namespace catalog_viewer 205 } // namespace catalog_viewer
208 } // namespace mash 206 } // namespace mash
OLDNEW
« no previous file with comments | « mash/catalog_viewer/catalog_viewer.h ('k') | mash/example/views_examples/views_examples_application_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698