| 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 "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/shell/public/interfaces/shell.mojom.h" | 10 #include "mash/shell/public/interfaces/shell.mojom.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 unlock_button_->SetBounds(bounds.width() - ps.width(), | 54 unlock_button_->SetBounds(bounds.width() - ps.width(), |
| 55 bounds.bottom() + 10, | 55 bounds.bottom() + 10, |
| 56 ps.width(), ps.height()); | 56 ps.width(), ps.height()); |
| 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::shell::mojom::ShellPtr shell; | 62 mash::shell::mojom::ShellPtr shell; |
| 63 shell_->ConnectToService("mojo:mash_shell", &shell); | 63 shell_->ConnectToInterface("mojo:mash_shell", &shell); |
| 64 shell->UnlockScreen(); | 64 shell->UnlockScreen(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 mojo::Shell* shell_; | 67 mojo::Shell* shell_; |
| 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() : shell_(nullptr) {} | 75 Screenlock::Screenlock() : shell_(nullptr) {} |
| 76 Screenlock::~Screenlock() {} | 76 Screenlock::~Screenlock() {} |
| 77 | 77 |
| 78 void Screenlock::Initialize(mojo::Shell* shell, const std::string& url, | 78 void Screenlock::Initialize(mojo::Shell* shell, const std::string& url, |
| 79 uint32_t id) { | 79 uint32_t id) { |
| 80 shell_ = shell; | 80 shell_ = shell; |
| 81 tracing_.Initialize(shell, url); | 81 tracing_.Initialize(shell, url); |
| 82 | 82 |
| 83 mash::shell::mojom::ShellPtr mash_shell; | 83 mash::shell::mojom::ShellPtr mash_shell; |
| 84 shell_->ConnectToService("mojo:mash_shell", &mash_shell); | 84 shell_->ConnectToInterface("mojo:mash_shell", &mash_shell); |
| 85 mash_shell->AddScreenlockStateListener( | 85 mash_shell->AddScreenlockStateListener( |
| 86 bindings_.CreateInterfacePtrAndBind(this)); | 86 bindings_.CreateInterfacePtrAndBind(this)); |
| 87 | 87 |
| 88 aura_init_.reset(new views::AuraInit(shell, "views_mus_resources.pak")); | 88 aura_init_.reset(new views::AuraInit(shell, "views_mus_resources.pak")); |
| 89 views::WindowManagerConnection::Create(shell); | 89 views::WindowManagerConnection::Create(shell); |
| 90 | 90 |
| 91 views::Widget* widget = new views::Widget; | 91 views::Widget* widget = new views::Widget; |
| 92 views::Widget::InitParams params( | 92 views::Widget::InitParams params( |
| 93 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 93 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 94 params.delegate = new ScreenlockView(shell); | 94 params.delegate = new ScreenlockView(shell); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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 shell_->Quit(); | 110 shell_->Quit(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 } // namespace screenlock | 113 } // namespace screenlock |
| 114 } // namespace main | 114 } // namespace main |
| OLD | NEW |