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

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

Issue 1882423004: Move shell service to toplevel shell namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 months 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/main.cc » ('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 "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "components/mus/public/cpp/property_type_converters.h" 9 #include "components/mus/public/cpp/property_type_converters.h"
10 #include "mash/session/public/interfaces/session.mojom.h" 10 #include "mash/session/public/interfaces/session.mojom.h"
11 #include "mash/wm/public/interfaces/container.mojom.h" 11 #include "mash/wm/public/interfaces/container.mojom.h"
12 #include "mojo/public/cpp/bindings/binding.h" 12 #include "mojo/public/cpp/bindings/binding.h"
13 #include "services/shell/public/cpp/connector.h" 13 #include "services/shell/public/cpp/connector.h"
14 #include "ui/views/background.h" 14 #include "ui/views/background.h"
15 #include "ui/views/controls/button/label_button.h" 15 #include "ui/views/controls/button/label_button.h"
16 #include "ui/views/mus/aura_init.h" 16 #include "ui/views/mus/aura_init.h"
17 #include "ui/views/mus/native_widget_mus.h" 17 #include "ui/views/mus/native_widget_mus.h"
18 #include "ui/views/mus/window_manager_connection.h" 18 #include "ui/views/mus/window_manager_connection.h"
19 #include "ui/views/widget/widget_delegate.h" 19 #include "ui/views/widget/widget_delegate.h"
20 20
21 namespace mash { 21 namespace mash {
22 namespace screenlock { 22 namespace screenlock {
23 namespace { 23 namespace {
24 24
25 class ScreenlockView : public views::WidgetDelegateView, 25 class ScreenlockView : public views::WidgetDelegateView,
26 public views::ButtonListener { 26 public views::ButtonListener {
27 public: 27 public:
28 explicit ScreenlockView(mojo::Connector* connector) 28 explicit ScreenlockView(shell::Connector* connector)
29 : connector_(connector), 29 : connector_(connector),
30 unlock_button_( 30 unlock_button_(
31 new views::LabelButton(this, base::ASCIIToUTF16("Unlock"))) { 31 new views::LabelButton(this, base::ASCIIToUTF16("Unlock"))) {
32 set_background(views::Background::CreateSolidBackground(SK_ColorYELLOW)); 32 set_background(views::Background::CreateSolidBackground(SK_ColorYELLOW));
33 unlock_button_->SetStyle(views::Button::STYLE_BUTTON); 33 unlock_button_->SetStyle(views::Button::STYLE_BUTTON);
34 AddChildView(unlock_button_); 34 AddChildView(unlock_button_);
35 } 35 }
36 ~ScreenlockView() override {} 36 ~ScreenlockView() override {}
37 37
38 private: 38 private:
(...skipping 18 matching lines...) Expand all
57 } 57 }
58 58
59 // Overridden from views::ButtonListener: 59 // Overridden from views::ButtonListener:
60 void ButtonPressed(views::Button* sender, const ui::Event& event) override { 60 void ButtonPressed(views::Button* sender, const ui::Event& event) override {
61 DCHECK_EQ(sender, unlock_button_); 61 DCHECK_EQ(sender, unlock_button_);
62 mash::session::mojom::SessionPtr session; 62 mash::session::mojom::SessionPtr session;
63 connector_->ConnectToInterface("mojo:mash_session", &session); 63 connector_->ConnectToInterface("mojo:mash_session", &session);
64 session->UnlockScreen(); 64 session->UnlockScreen();
65 } 65 }
66 66
67 mojo::Connector* connector_; 67 shell::Connector* connector_;
68 views::LabelButton* unlock_button_; 68 views::LabelButton* unlock_button_;
69 69
70 DISALLOW_COPY_AND_ASSIGN(ScreenlockView); 70 DISALLOW_COPY_AND_ASSIGN(ScreenlockView);
71 }; 71 };
72 72
73 } // namespace 73 } // namespace
74 74
75 Screenlock::Screenlock() {} 75 Screenlock::Screenlock() {}
76 Screenlock::~Screenlock() {} 76 Screenlock::~Screenlock() {}
77 77
78 void Screenlock::Initialize(mojo::Connector* connector, 78 void Screenlock::Initialize(shell::Connector* connector,
79 const mojo::Identity& identity, 79 const shell::Identity& identity,
80 uint32_t id) { 80 uint32_t id) {
81 tracing_.Initialize(connector, identity.name()); 81 tracing_.Initialize(connector, identity.name());
82 82
83 mash::session::mojom::SessionPtr session; 83 mash::session::mojom::SessionPtr session;
84 connector->ConnectToInterface("mojo:mash_session", &session); 84 connector->ConnectToInterface("mojo:mash_session", &session);
85 session->AddScreenlockStateListener( 85 session->AddScreenlockStateListener(
86 bindings_.CreateInterfacePtrAndBind(this)); 86 bindings_.CreateInterfacePtrAndBind(this));
87 87
88 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak")); 88 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak"));
89 views::WindowManagerConnection::Create(connector); 89 views::WindowManagerConnection::Create(connector);
(...skipping 15 matching lines...) Expand all
105 widget->Show(); 105 widget->Show();
106 } 106 }
107 107
108 void Screenlock::ScreenlockStateChanged(bool screen_locked) { 108 void Screenlock::ScreenlockStateChanged(bool screen_locked) {
109 if (!screen_locked) 109 if (!screen_locked)
110 base::MessageLoop::current()->QuitWhenIdle(); 110 base::MessageLoop::current()->QuitWhenIdle();
111 } 111 }
112 112
113 } // namespace screenlock 113 } // namespace screenlock
114 } // namespace main 114 } // namespace main
OLDNEW
« no previous file with comments | « mash/screenlock/screenlock.h ('k') | mash/session/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698