| 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 ui::TableModelObserver* observer_; | 200 ui::TableModelObserver* observer_; |
| 201 views::Textfield* capability_; | 201 views::Textfield* capability_; |
| 202 | 202 |
| 203 std::vector<Entry> entries_; | 203 std::vector<Entry> entries_; |
| 204 | 204 |
| 205 DISALLOW_COPY_AND_ASSIGN(CatalogViewerContents); | 205 DISALLOW_COPY_AND_ASSIGN(CatalogViewerContents); |
| 206 }; | 206 }; |
| 207 | 207 |
| 208 } // namespace | 208 } // namespace |
| 209 | 209 |
| 210 CatalogViewer::CatalogViewer() {} | 210 CatalogViewer::CatalogViewer() { |
| 211 registry_.AddInterface<mojom::Launchable>(this); |
| 212 } |
| 211 CatalogViewer::~CatalogViewer() {} | 213 CatalogViewer::~CatalogViewer() {} |
| 212 | 214 |
| 213 void CatalogViewer::RemoveWindow(views::Widget* window) { | 215 void CatalogViewer::RemoveWindow(views::Widget* window) { |
| 214 auto it = std::find(windows_.begin(), windows_.end(), window); | 216 auto it = std::find(windows_.begin(), windows_.end(), window); |
| 215 DCHECK(it != windows_.end()); | 217 DCHECK(it != windows_.end()); |
| 216 windows_.erase(it); | 218 windows_.erase(it); |
| 217 if (windows_.empty()) | 219 if (windows_.empty()) |
| 218 base::MessageLoop::current()->QuitWhenIdle(); | 220 base::MessageLoop::current()->QuitWhenIdle(); |
| 219 } | 221 } |
| 220 | 222 |
| 221 void CatalogViewer::OnStart() { | 223 void CatalogViewer::OnStart() { |
| 222 tracing_.Initialize(context()->connector(), context()->identity().name()); | 224 tracing_.Initialize(context()->connector(), context()->identity().name()); |
| 223 | 225 |
| 224 aura_init_ = base::MakeUnique<views::AuraInit>( | 226 aura_init_ = base::MakeUnique<views::AuraInit>( |
| 225 context()->connector(), context()->identity(), "views_mus_resources.pak", | 227 context()->connector(), context()->identity(), "views_mus_resources.pak", |
| 226 std::string(), nullptr, views::AuraInit::Mode::AURA_MUS); | 228 std::string(), nullptr, views::AuraInit::Mode::AURA_MUS); |
| 227 } | 229 } |
| 228 | 230 |
| 229 bool CatalogViewer::OnConnect(const service_manager::ServiceInfo& remote_info, | 231 void CatalogViewer::OnBindInterface( |
| 230 service_manager::InterfaceRegistry* registry) { | 232 const service_manager::ServiceInfo& source_info, |
| 231 registry->AddInterface<mojom::Launchable>(this); | 233 const std::string& interface_name, |
| 232 return true; | 234 mojo::ScopedMessagePipeHandle interface_pipe) { |
| 235 registry_.BindInterface(source_info.identity, interface_name, |
| 236 std::move(interface_pipe)); |
| 233 } | 237 } |
| 234 | 238 |
| 235 void CatalogViewer::Launch(uint32_t what, mojom::LaunchMode how) { | 239 void CatalogViewer::Launch(uint32_t what, mojom::LaunchMode how) { |
| 236 bool reuse = how == mojom::LaunchMode::REUSE || | 240 bool reuse = how == mojom::LaunchMode::REUSE || |
| 237 how == mojom::LaunchMode::DEFAULT; | 241 how == mojom::LaunchMode::DEFAULT; |
| 238 if (reuse && !windows_.empty()) { | 242 if (reuse && !windows_.empty()) { |
| 239 windows_.back()->Activate(); | 243 windows_.back()->Activate(); |
| 240 return; | 244 return; |
| 241 } | 245 } |
| 242 catalog::mojom::CatalogPtr catalog; | 246 catalog::mojom::CatalogPtr catalog; |
| 243 context()->connector()->BindInterface(catalog::mojom::kServiceName, &catalog); | 247 context()->connector()->BindInterface(catalog::mojom::kServiceName, &catalog); |
| 244 | 248 |
| 245 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( | 249 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( |
| 246 new CatalogViewerContents(this, std::move(catalog)), nullptr, | 250 new CatalogViewerContents(this, std::move(catalog)), nullptr, |
| 247 gfx::Rect(25, 25, 500, 600)); | 251 gfx::Rect(25, 25, 500, 600)); |
| 248 window->Show(); | 252 window->Show(); |
| 249 windows_.push_back(window); | 253 windows_.push_back(window); |
| 250 } | 254 } |
| 251 | 255 |
| 252 void CatalogViewer::Create(const service_manager::Identity& remote_identity, | 256 void CatalogViewer::Create(const service_manager::Identity& remote_identity, |
| 253 mojom::LaunchableRequest request) { | 257 mojom::LaunchableRequest request) { |
| 254 bindings_.AddBinding(this, std::move(request)); | 258 bindings_.AddBinding(this, std::move(request)); |
| 255 } | 259 } |
| 256 | 260 |
| 257 } // namespace catalog_viewer | 261 } // namespace catalog_viewer |
| 258 } // namespace mash | 262 } // namespace mash |
| OLD | NEW |