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

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

Issue 2476063002: Service Manager: Rework Service and ServiceContext lifetime (Closed)
Patch Set: . Created 4 years, 1 month 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/screenlock/screenlock.h ('k') | mash/session/session.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/screenlock/screenlock.h" 5 #include "mash/screenlock/screenlock.h"
6 6
7 #include "ash/public/cpp/shell_window_ids.h" 7 #include "ash/public/cpp/shell_window_ids.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "mash/session/public/interfaces/session.mojom.h" 11 #include "mash/session/public/interfaces/session.mojom.h"
12 #include "mojo/public/cpp/bindings/binding.h" 12 #include "mojo/public/cpp/bindings/binding.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/service_context.h"
14 #include "services/ui/public/cpp/property_type_converters.h" 15 #include "services/ui/public/cpp/property_type_converters.h"
15 #include "ui/views/background.h" 16 #include "ui/views/background.h"
16 #include "ui/views/controls/button/md_text_button.h" 17 #include "ui/views/controls/button/md_text_button.h"
17 #include "ui/views/mus/aura_init.h" 18 #include "ui/views/mus/aura_init.h"
18 #include "ui/views/mus/native_widget_mus.h" 19 #include "ui/views/mus/native_widget_mus.h"
19 #include "ui/views/mus/window_manager_connection.h" 20 #include "ui/views/mus/window_manager_connection.h"
20 #include "ui/views/widget/widget_delegate.h" 21 #include "ui/views/widget/widget_delegate.h"
21 22
22 namespace mash { 23 namespace mash {
23 namespace screenlock { 24 namespace screenlock {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 views::MdTextButton* unlock_button_; 68 views::MdTextButton* unlock_button_;
68 69
69 DISALLOW_COPY_AND_ASSIGN(ScreenlockView); 70 DISALLOW_COPY_AND_ASSIGN(ScreenlockView);
70 }; 71 };
71 72
72 } // namespace 73 } // namespace
73 74
74 Screenlock::Screenlock() {} 75 Screenlock::Screenlock() {}
75 Screenlock::~Screenlock() {} 76 Screenlock::~Screenlock() {}
76 77
77 void Screenlock::OnStart(const service_manager::ServiceInfo& info) { 78 void Screenlock::OnStart(service_manager::ServiceContext* context) {
78 tracing_.Initialize(connector(), info.identity.name()); 79 tracing_.Initialize(context->connector(), context->identity().name());
79 80
80 mash::session::mojom::SessionPtr session; 81 mash::session::mojom::SessionPtr session;
81 connector()->ConnectToInterface("service:mash_session", &session); 82 context->connector()->ConnectToInterface("service:mash_session", &session);
82 session->AddScreenlockStateListener( 83 session->AddScreenlockStateListener(
83 bindings_.CreateInterfacePtrAndBind(this)); 84 bindings_.CreateInterfacePtrAndBind(this));
84 85
85 aura_init_ = base::MakeUnique<views::AuraInit>(connector(), info.identity, 86 aura_init_ = base::MakeUnique<views::AuraInit>(
86 "views_mus_resources.pak"); 87 context->connector(), context->identity(), "views_mus_resources.pak");
87 window_manager_connection_ = 88 window_manager_connection_ = views::WindowManagerConnection::Create(
88 views::WindowManagerConnection::Create(connector(), info.identity); 89 context->connector(), context->identity());
89 90
90 views::Widget* widget = new views::Widget; 91 views::Widget* widget = new views::Widget;
91 views::Widget::InitParams params( 92 views::Widget::InitParams params(
92 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 93 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
93 params.delegate = new ScreenlockView(connector()); 94 params.delegate = new ScreenlockView(context->connector());
94 95
95 std::map<std::string, std::vector<uint8_t>> properties; 96 std::map<std::string, std::vector<uint8_t>> properties;
96 properties[ui::mojom::WindowManager::kInitialContainerId_Property] = 97 properties[ui::mojom::WindowManager::kInitialContainerId_Property] =
97 mojo::ConvertTo<std::vector<uint8_t>>( 98 mojo::ConvertTo<std::vector<uint8_t>>(
98 ash::kShellWindowId_LockScreenContainer); 99 ash::kShellWindowId_LockScreenContainer);
99 ui::Window* window = 100 ui::Window* window =
100 views::WindowManagerConnection::Get()->NewTopLevelWindow(properties); 101 views::WindowManagerConnection::Get()->NewTopLevelWindow(properties);
101 params.native_widget = new views::NativeWidgetMus( 102 params.native_widget = new views::NativeWidgetMus(
102 widget, window, ui::mojom::CompositorFrameSinkType::DEFAULT); 103 widget, window, ui::mojom::CompositorFrameSinkType::DEFAULT);
103 widget->Init(params); 104 widget->Init(params);
104 widget->Show(); 105 widget->Show();
105 } 106 }
106 107
108 bool Screenlock::OnConnect(
109 const service_manager::ServiceInfo& remote_info,
110 service_manager::InterfaceRegistry* registry) {
111 return false;
112 }
113
107 void Screenlock::ScreenlockStateChanged(bool screen_locked) { 114 void Screenlock::ScreenlockStateChanged(bool screen_locked) {
108 if (!screen_locked) 115 if (!screen_locked)
109 base::MessageLoop::current()->QuitWhenIdle(); 116 base::MessageLoop::current()->QuitWhenIdle();
110 } 117 }
111 118
112 } // namespace screenlock 119 } // namespace screenlock
113 } // namespace mash 120 } // namespace mash
OLDNEW
« no previous file with comments | « mash/screenlock/screenlock.h ('k') | mash/session/session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698