| 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/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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 CatalogViewer::~CatalogViewer() {} | 158 CatalogViewer::~CatalogViewer() {} |
| 159 | 159 |
| 160 void CatalogViewer::RemoveWindow(views::Widget* window) { | 160 void CatalogViewer::RemoveWindow(views::Widget* window) { |
| 161 auto it = std::find(windows_.begin(), windows_.end(), window); | 161 auto it = std::find(windows_.begin(), windows_.end(), window); |
| 162 DCHECK(it != windows_.end()); | 162 DCHECK(it != windows_.end()); |
| 163 windows_.erase(it); | 163 windows_.erase(it); |
| 164 if (windows_.empty()) | 164 if (windows_.empty()) |
| 165 base::MessageLoop::current()->QuitWhenIdle(); | 165 base::MessageLoop::current()->QuitWhenIdle(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void CatalogViewer::OnStart(const service_manager::Identity& identity) { | 168 void CatalogViewer::OnStart(const service_manager::ServiceInfo& info) { |
| 169 tracing_.Initialize(connector(), identity.name()); | 169 tracing_.Initialize(connector(), info.identity.name()); |
| 170 | 170 |
| 171 aura_init_.reset( | 171 aura_init_.reset( |
| 172 new views::AuraInit(connector(), "views_mus_resources.pak")); | 172 new views::AuraInit(connector(), "views_mus_resources.pak")); |
| 173 window_manager_connection_ = | 173 window_manager_connection_ = |
| 174 views::WindowManagerConnection::Create(connector(), identity); | 174 views::WindowManagerConnection::Create(connector(), info.identity); |
| 175 } | 175 } |
| 176 | 176 |
| 177 bool CatalogViewer::OnConnect(const service_manager::Identity& remote_identity, | 177 bool CatalogViewer::OnConnect(const service_manager::ServiceInfo& remote_info, |
| 178 service_manager::InterfaceRegistry* registry) { | 178 service_manager::InterfaceRegistry* registry) { |
| 179 registry->AddInterface<mojom::Launchable>(this); | 179 registry->AddInterface<mojom::Launchable>(this); |
| 180 return true; | 180 return true; |
| 181 } | 181 } |
| 182 | 182 |
| 183 void CatalogViewer::Launch(uint32_t what, mojom::LaunchMode how) { | 183 void CatalogViewer::Launch(uint32_t what, mojom::LaunchMode how) { |
| 184 bool reuse = how == mojom::LaunchMode::REUSE || | 184 bool reuse = how == mojom::LaunchMode::REUSE || |
| 185 how == mojom::LaunchMode::DEFAULT; | 185 how == mojom::LaunchMode::DEFAULT; |
| 186 if (reuse && !windows_.empty()) { | 186 if (reuse && !windows_.empty()) { |
| 187 windows_.back()->Activate(); | 187 windows_.back()->Activate(); |
| 188 return; | 188 return; |
| 189 } | 189 } |
| 190 catalog::mojom::CatalogPtr catalog; | 190 catalog::mojom::CatalogPtr catalog; |
| 191 connector()->ConnectToInterface("service:catalog", &catalog); | 191 connector()->ConnectToInterface("service:catalog", &catalog); |
| 192 | 192 |
| 193 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( | 193 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( |
| 194 new CatalogViewerContents(this, std::move(catalog)), nullptr, | 194 new CatalogViewerContents(this, std::move(catalog)), nullptr, |
| 195 gfx::Rect(25, 25, 500, 600)); | 195 gfx::Rect(25, 25, 500, 600)); |
| 196 window->Show(); | 196 window->Show(); |
| 197 windows_.push_back(window); | 197 windows_.push_back(window); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void CatalogViewer::Create(const service_manager::Identity& remote_identity, | 200 void CatalogViewer::Create(const service_manager::Identity& remote_identity, |
| 201 mojom::LaunchableRequest request) { | 201 mojom::LaunchableRequest request) { |
| 202 bindings_.AddBinding(this, std::move(request)); | 202 bindings_.AddBinding(this, std::move(request)); |
| 203 } | 203 } |
| 204 | 204 |
| 205 } // namespace catalog_viewer | 205 } // namespace catalog_viewer |
| 206 } // namespace mash | 206 } // namespace mash |
| OLD | NEW |