| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/common/session/session_state_delegate.h" | 5 #include "ash/common/session/session_state_delegate.h" |
| 6 #include "ash/common/shell_window_ids.h" | 6 #include "ash/common/shell_window_ids.h" |
| 7 #include "ash/common/wm_shell.h" |
| 7 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 8 #include "ash/shell/example_factory.h" | 9 #include "ash/shell/example_factory.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 10 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
| 11 #include "ui/aura/window_event_dispatcher.h" | 12 #include "ui/aura/window_event_dispatcher.h" |
| 12 #include "ui/gfx/canvas.h" | 13 #include "ui/gfx/canvas.h" |
| 13 #include "ui/gfx/font_list.h" | 14 #include "ui/gfx/font_list.h" |
| 14 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
| 15 #include "ui/gfx/text_utils.h" | 16 #include "ui/gfx/text_utils.h" |
| 16 #include "ui/views/controls/button/label_button.h" | 17 #include "ui/views/controls/button/label_button.h" |
| 17 #include "ui/views/corewm/tooltip_controller.h" | 18 #include "ui/views/corewm/tooltip_controller.h" |
| 18 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
| 19 #include "ui/views/widget/widget_delegate.h" | 20 #include "ui/views/widget/widget_delegate.h" |
| 20 | 21 |
| 21 using ash::Shell; | |
| 22 | |
| 23 namespace ash { | 22 namespace ash { |
| 24 namespace shell { | 23 namespace shell { |
| 25 | 24 |
| 26 class LockView : public views::WidgetDelegateView, | 25 class LockView : public views::WidgetDelegateView, |
| 27 public views::ButtonListener { | 26 public views::ButtonListener { |
| 28 public: | 27 public: |
| 29 LockView() | 28 LockView() |
| 30 : unlock_button_( | 29 : unlock_button_( |
| 31 new views::LabelButton(this, base::ASCIIToUTF16("Unlock"))) { | 30 new views::LabelButton(this, base::ASCIIToUTF16("Unlock"))) { |
| 32 unlock_button_->SetStyle(views::Button::STYLE_BUTTON); | 31 unlock_button_->SetStyle(views::Button::STYLE_BUTTON); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 57 unlock_button_->SetBoundsRect(bounds); | 56 unlock_button_->SetBoundsRect(bounds); |
| 58 } | 57 } |
| 59 void ViewHierarchyChanged( | 58 void ViewHierarchyChanged( |
| 60 const ViewHierarchyChangedDetails& details) override { | 59 const ViewHierarchyChangedDetails& details) override { |
| 61 if (details.is_add && details.child == this) | 60 if (details.is_add && details.child == this) |
| 62 unlock_button_->RequestFocus(); | 61 unlock_button_->RequestFocus(); |
| 63 } | 62 } |
| 64 | 63 |
| 65 // Overridden from views::WidgetDelegateView: | 64 // Overridden from views::WidgetDelegateView: |
| 66 void WindowClosing() override { | 65 void WindowClosing() override { |
| 67 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); | 66 WmShell::Get()->GetSessionStateDelegate()->UnlockScreen(); |
| 68 } | 67 } |
| 69 | 68 |
| 70 // Overridden from views::ButtonListener: | 69 // Overridden from views::ButtonListener: |
| 71 void ButtonPressed(views::Button* sender, const ui::Event& event) override { | 70 void ButtonPressed(views::Button* sender, const ui::Event& event) override { |
| 72 DCHECK(sender == unlock_button_); | 71 DCHECK(sender == unlock_button_); |
| 73 GetWidget()->Close(); | 72 GetWidget()->Close(); |
| 74 } | 73 } |
| 75 | 74 |
| 76 gfx::FontList font_list_; | 75 gfx::FontList font_list_; |
| 77 views::LabelButton* unlock_button_; | 76 views::LabelButton* unlock_button_; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 99 widget->GetNativeView()->SetName("LockView"); | 98 widget->GetNativeView()->SetName("LockView"); |
| 100 widget->GetNativeView()->Focus(); | 99 widget->GetNativeView()->Focus(); |
| 101 | 100 |
| 102 // TODO: it shouldn't be necessary to invoke UpdateTooltip() here. | 101 // TODO: it shouldn't be necessary to invoke UpdateTooltip() here. |
| 103 Shell::GetInstance()->tooltip_controller()->UpdateTooltip( | 102 Shell::GetInstance()->tooltip_controller()->UpdateTooltip( |
| 104 widget->GetNativeView()); | 103 widget->GetNativeView()); |
| 105 } | 104 } |
| 106 | 105 |
| 107 } // namespace shell | 106 } // namespace shell |
| 108 } // namespace ash | 107 } // namespace ash |
| OLD | NEW |