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/screenlock/screenlock.h" | 5 #include "mash/screenlock/screenlock.h" |
6 | 6 |
7 #include "ash/public/interfaces/container.mojom.h" | 7 #include "ash/public/interfaces/container.mojom.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "mash/session/public/interfaces/session.mojom.h" | 10 #include "mash/session/public/interfaces/session.mojom.h" |
11 #include "mojo/public/cpp/bindings/binding.h" | 11 #include "mojo/public/cpp/bindings/binding.h" |
12 #include "services/shell/public/cpp/connector.h" | 12 #include "services/shell/public/cpp/connector.h" |
13 #include "services/ui/public/cpp/property_type_converters.h" | 13 #include "services/ui/public/cpp/property_type_converters.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/md_text_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(shell::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 views::MdTextButton::Create(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); | |
34 AddChildView(unlock_button_); | 33 AddChildView(unlock_button_); |
35 } | 34 } |
36 ~ScreenlockView() override {} | 35 ~ScreenlockView() override {} |
37 | 36 |
38 private: | 37 private: |
39 // Overridden from views::WidgetDelegate: | 38 // Overridden from views::WidgetDelegate: |
40 views::View* GetContentsView() override { return this; } | 39 views::View* GetContentsView() override { return this; } |
41 base::string16 GetWindowTitle() const override { | 40 base::string16 GetWindowTitle() const override { |
42 // TODO(beng): use resources. | 41 // TODO(beng): use resources. |
43 return base::ASCIIToUTF16("Screenlock"); | 42 return base::ASCIIToUTF16("Screenlock"); |
(...skipping 14 matching lines...) Expand all Loading... |
58 | 57 |
59 // Overridden from views::ButtonListener: | 58 // Overridden from views::ButtonListener: |
60 void ButtonPressed(views::Button* sender, const ui::Event& event) override { | 59 void ButtonPressed(views::Button* sender, const ui::Event& event) override { |
61 DCHECK_EQ(sender, unlock_button_); | 60 DCHECK_EQ(sender, unlock_button_); |
62 mash::session::mojom::SessionPtr session; | 61 mash::session::mojom::SessionPtr session; |
63 connector_->ConnectToInterface("mojo:mash_session", &session); | 62 connector_->ConnectToInterface("mojo:mash_session", &session); |
64 session->UnlockScreen(); | 63 session->UnlockScreen(); |
65 } | 64 } |
66 | 65 |
67 shell::Connector* connector_; | 66 shell::Connector* connector_; |
68 views::LabelButton* unlock_button_; | 67 views::MdTextButton* unlock_button_; |
69 | 68 |
70 DISALLOW_COPY_AND_ASSIGN(ScreenlockView); | 69 DISALLOW_COPY_AND_ASSIGN(ScreenlockView); |
71 }; | 70 }; |
72 | 71 |
73 } // namespace | 72 } // namespace |
74 | 73 |
75 Screenlock::Screenlock() {} | 74 Screenlock::Screenlock() {} |
76 Screenlock::~Screenlock() {} | 75 Screenlock::~Screenlock() {} |
77 | 76 |
78 void Screenlock::OnStart(const shell::Identity& identity) { | 77 void Screenlock::OnStart(const shell::Identity& identity) { |
(...skipping 26 matching lines...) Expand all Loading... |
105 widget->Show(); | 104 widget->Show(); |
106 } | 105 } |
107 | 106 |
108 void Screenlock::ScreenlockStateChanged(bool screen_locked) { | 107 void Screenlock::ScreenlockStateChanged(bool screen_locked) { |
109 if (!screen_locked) | 108 if (!screen_locked) |
110 base::MessageLoop::current()->QuitWhenIdle(); | 109 base::MessageLoop::current()->QuitWhenIdle(); |
111 } | 110 } |
112 | 111 |
113 } // namespace screenlock | 112 } // namespace screenlock |
114 } // namespace mash | 113 } // namespace mash |
OLD | NEW |