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

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

Issue 2509853002: Convert //mash to define service names in mojom (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/public/interfaces/constants.mojom ('k') | mash/session/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 "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/constants.mojom.h"
11 #include "mash/session/public/interfaces/session.mojom.h" 12 #include "mash/session/public/interfaces/session.mojom.h"
12 #include "mojo/public/cpp/bindings/binding.h" 13 #include "mojo/public/cpp/bindings/binding.h"
13 #include "services/service_manager/public/cpp/connector.h" 14 #include "services/service_manager/public/cpp/connector.h"
14 #include "services/service_manager/public/cpp/service_context.h" 15 #include "services/service_manager/public/cpp/service_context.h"
15 #include "services/ui/public/cpp/property_type_converters.h" 16 #include "services/ui/public/cpp/property_type_converters.h"
16 #include "ui/views/background.h" 17 #include "ui/views/background.h"
17 #include "ui/views/controls/button/md_text_button.h" 18 #include "ui/views/controls/button/md_text_button.h"
18 #include "ui/views/mus/aura_init.h" 19 #include "ui/views/mus/aura_init.h"
19 #include "ui/views/mus/native_widget_mus.h" 20 #include "ui/views/mus/native_widget_mus.h"
20 #include "ui/views/mus/window_manager_connection.h" 21 #include "ui/views/mus/window_manager_connection.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 54
54 unlock_button_->SetBounds(bounds.width() - ps.width(), 55 unlock_button_->SetBounds(bounds.width() - ps.width(),
55 bounds.bottom() + 10, 56 bounds.bottom() + 10,
56 ps.width(), ps.height()); 57 ps.width(), ps.height());
57 } 58 }
58 59
59 // Overridden from views::ButtonListener: 60 // Overridden from views::ButtonListener:
60 void ButtonPressed(views::Button* sender, const ui::Event& event) override { 61 void ButtonPressed(views::Button* sender, const ui::Event& event) override {
61 DCHECK_EQ(sender, unlock_button_); 62 DCHECK_EQ(sender, unlock_button_);
62 mash::session::mojom::SessionPtr session; 63 mash::session::mojom::SessionPtr session;
63 connector_->ConnectToInterface("mash_session", &session); 64 connector_->ConnectToInterface(session::mojom::kServiceName, &session);
64 session->UnlockScreen(); 65 session->UnlockScreen();
65 } 66 }
66 67
67 service_manager::Connector* connector_; 68 service_manager::Connector* connector_;
68 views::MdTextButton* unlock_button_; 69 views::MdTextButton* unlock_button_;
69 70
70 DISALLOW_COPY_AND_ASSIGN(ScreenlockView); 71 DISALLOW_COPY_AND_ASSIGN(ScreenlockView);
71 }; 72 };
72 73
73 } // namespace 74 } // namespace
74 75
75 Screenlock::Screenlock() {} 76 Screenlock::Screenlock() {}
76 Screenlock::~Screenlock() {} 77 Screenlock::~Screenlock() {}
77 78
78 void Screenlock::OnStart() { 79 void Screenlock::OnStart() {
79 tracing_.Initialize(context()->connector(), context()->identity().name()); 80 tracing_.Initialize(context()->connector(), context()->identity().name());
80 81
81 mash::session::mojom::SessionPtr session; 82 mash::session::mojom::SessionPtr session;
82 context()->connector()->ConnectToInterface("mash_session", &session); 83 context()->connector()->ConnectToInterface(session::mojom::kServiceName,
84 &session);
83 session->AddScreenlockStateListener( 85 session->AddScreenlockStateListener(
84 bindings_.CreateInterfacePtrAndBind(this)); 86 bindings_.CreateInterfacePtrAndBind(this));
85 87
86 aura_init_ = base::MakeUnique<views::AuraInit>( 88 aura_init_ = base::MakeUnique<views::AuraInit>(
87 context()->connector(), context()->identity(), "views_mus_resources.pak"); 89 context()->connector(), context()->identity(), "views_mus_resources.pak");
88 window_manager_connection_ = views::WindowManagerConnection::Create( 90 window_manager_connection_ = views::WindowManagerConnection::Create(
89 context()->connector(), context()->identity()); 91 context()->connector(), context()->identity());
90 92
91 views::Widget* widget = new views::Widget; 93 views::Widget* widget = new views::Widget;
92 views::Widget::InitParams params( 94 views::Widget::InitParams params(
(...skipping 18 matching lines...) Expand all
111 return false; 113 return false;
112 } 114 }
113 115
114 void Screenlock::ScreenlockStateChanged(bool screen_locked) { 116 void Screenlock::ScreenlockStateChanged(bool screen_locked) {
115 if (!screen_locked) 117 if (!screen_locked)
116 base::MessageLoop::current()->QuitWhenIdle(); 118 base::MessageLoop::current()->QuitWhenIdle();
117 } 119 }
118 120
119 } // namespace screenlock 121 } // namespace screenlock
120 } // namespace mash 122 } // namespace mash
OLDNEW
« no previous file with comments | « mash/screenlock/public/interfaces/constants.mojom ('k') | mash/session/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698