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

Side by Side Diff: mash/example/views_examples/views_examples.cc

Issue 2569413003: Converts more services to use aura-mus (Closed)
Patch Set: merge Created 4 years 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/example/views_examples/BUILD.gn ('k') | mash/task_viewer/BUILD.gn » ('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 <memory> 5 #include <memory>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "mash/public/interfaces/launchable.mojom.h" 9 #include "mash/public/interfaces/launchable.mojom.h"
10 #include "mojo/public/cpp/bindings/binding_set.h" 10 #include "mojo/public/cpp/bindings/binding_set.h"
11 #include "services/service_manager/public/c/main.h" 11 #include "services/service_manager/public/c/main.h"
12 #include "services/service_manager/public/cpp/connection.h" 12 #include "services/service_manager/public/cpp/connection.h"
13 #include "services/service_manager/public/cpp/connector.h" 13 #include "services/service_manager/public/cpp/connector.h"
14 #include "services/service_manager/public/cpp/interface_factory.h" 14 #include "services/service_manager/public/cpp/interface_factory.h"
15 #include "services/service_manager/public/cpp/interface_registry.h" 15 #include "services/service_manager/public/cpp/interface_registry.h"
16 #include "services/service_manager/public/cpp/service.h" 16 #include "services/service_manager/public/cpp/service.h"
17 #include "services/service_manager/public/cpp/service_context.h" 17 #include "services/service_manager/public/cpp/service_context.h"
18 #include "services/service_manager/public/cpp/service_runner.h" 18 #include "services/service_manager/public/cpp/service_runner.h"
19 #include "services/tracing/public/cpp/provider.h" 19 #include "services/tracing/public/cpp/provider.h"
20 #include "ui/views/examples/example_base.h" 20 #include "ui/views/examples/example_base.h"
21 #include "ui/views/examples/examples_window.h" 21 #include "ui/views/examples/examples_window.h"
22 #include "ui/views/mus/aura_init.h" 22 #include "ui/views/mus/aura_init.h"
23 #include "ui/views/mus/window_manager_connection.h"
24
25 namespace views {
26 class AuraInit;
27 class WindowManagerConnection;
28 }
29 23
30 class ViewsExamples 24 class ViewsExamples
31 : public service_manager::Service, 25 : public service_manager::Service,
32 public mash::mojom::Launchable, 26 public mash::mojom::Launchable,
33 public service_manager::InterfaceFactory<mash::mojom::Launchable> { 27 public service_manager::InterfaceFactory<mash::mojom::Launchable> {
34 public: 28 public:
35 ViewsExamples() {} 29 ViewsExamples() {}
36 ~ViewsExamples() override {} 30 ~ViewsExamples() override {}
37 31
38 private: 32 private:
39 // service_manager::Service: 33 // service_manager::Service:
40 void OnStart() override { 34 void OnStart() override {
41 tracing_.Initialize(context()->connector(), context()->identity().name()); 35 tracing_.Initialize(context()->connector(), context()->identity().name());
42 aura_init_ = base::MakeUnique<views::AuraInit>( 36 aura_init_ = base::MakeUnique<views::AuraInit>(
43 context()->connector(), context()->identity(), 37 context()->connector(), context()->identity(),
44 "views_mus_resources.pak"); 38 "views_mus_resources.pak", std::string(), nullptr,
45 window_manager_connection_ = views::WindowManagerConnection::Create( 39 views::AuraInit::Mode::AURA_MUS);
46 context()->connector(), context()->identity());
47 } 40 }
48 bool OnConnect(const service_manager::ServiceInfo& remote_info, 41 bool OnConnect(const service_manager::ServiceInfo& remote_info,
49 service_manager::InterfaceRegistry* registry) override { 42 service_manager::InterfaceRegistry* registry) override {
50 registry->AddInterface<mash::mojom::Launchable>(this); 43 registry->AddInterface<mash::mojom::Launchable>(this);
51 return true; 44 return true;
52 } 45 }
53 46
54 // mash::mojom::Launchable: 47 // mash::mojom::Launchable:
55 void Launch(uint32_t what, mash::mojom::LaunchMode how) override { 48 void Launch(uint32_t what, mash::mojom::LaunchMode how) override {
56 views::examples::ShowExamplesWindow(views::examples::QUIT_ON_CLOSE, 49 views::examples::ShowExamplesWindow(views::examples::QUIT_ON_CLOSE,
57 nullptr, nullptr); 50 nullptr, nullptr);
58 } 51 }
59 52
60 // service_manager::InterfaceFactory<mash::mojom::Launchable>: 53 // service_manager::InterfaceFactory<mash::mojom::Launchable>:
61 void Create(const service_manager::Identity& remote_identity, 54 void Create(const service_manager::Identity& remote_identity,
62 mash::mojom::LaunchableRequest request) override { 55 mash::mojom::LaunchableRequest request) override {
63 bindings_.AddBinding(this, std::move(request)); 56 bindings_.AddBinding(this, std::move(request));
64 } 57 }
65 58
66 mojo::BindingSet<mash::mojom::Launchable> bindings_; 59 mojo::BindingSet<mash::mojom::Launchable> bindings_;
67 60
68 tracing::Provider tracing_; 61 tracing::Provider tracing_;
69 std::unique_ptr<views::AuraInit> aura_init_; 62 std::unique_ptr<views::AuraInit> aura_init_;
70 std::unique_ptr<views::WindowManagerConnection> window_manager_connection_;
71 63
72 DISALLOW_COPY_AND_ASSIGN(ViewsExamples); 64 DISALLOW_COPY_AND_ASSIGN(ViewsExamples);
73 }; 65 };
74 66
75 MojoResult ServiceMain(MojoHandle service_request_handle) { 67 MojoResult ServiceMain(MojoHandle service_request_handle) {
76 return service_manager::ServiceRunner(new ViewsExamples) 68 return service_manager::ServiceRunner(new ViewsExamples)
77 .Run(service_request_handle); 69 .Run(service_request_handle);
78 } 70 }
OLDNEW
« no previous file with comments | « mash/example/views_examples/BUILD.gn ('k') | mash/task_viewer/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698