Home | History | Annotate | Download | only in ui
      1 // Copyright 2014 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "chrome/browser/chromeos/login/ui/lock_window_aura.h"
      6 
      7 #include "ash/shell.h"
      8 #include "ash/shell_window_ids.h"
      9 #include "ash/wm/window_animations.h"
     10 #include "base/command_line.h"
     11 #include "ui/aura/window.h"
     12 #include "ui/aura/window_event_dispatcher.h"
     13 
     14 namespace chromeos {
     15 
     16 LockWindow* LockWindow::Create() {
     17   LockWindowAura* lock_window = new LockWindowAura();
     18   // Cancel existing touch events when screen is locked.
     19   ui::GestureRecognizer::Get()->TransferEventsTo(
     20       lock_window->GetNativeWindow(), NULL);
     21   return lock_window;
     22 }
     23 
     24 ////////////////////////////////////////////////////////////////////////////////
     25 // LockWindow implementation:
     26 void LockWindowAura::Grab() {
     27   // We already have grab from the lock screen container, just call the ready
     28   // callback immediately.
     29   if (observer_)
     30     observer_->OnLockWindowReady();
     31 }
     32 
     33 views::Widget* LockWindowAura::GetWidget() {
     34   return this;
     35 }
     36 
     37 ////////////////////////////////////////////////////////////////////////////////
     38 // views::WidgetDelegate implementation:
     39 views::View* LockWindowAura::GetInitiallyFocusedView() {
     40   return initially_focused_view_;
     41 }
     42 
     43 const views::Widget* LockWindowAura::GetWidget() const {
     44   return this;
     45 }
     46 
     47 ////////////////////////////////////////////////////////////////////////////////
     48 // LockWindowAura private:
     49 LockWindowAura::LockWindowAura() {
     50   Init();
     51 }
     52 
     53 LockWindowAura::~LockWindowAura() {
     54 }
     55 
     56 void LockWindowAura::Init() {
     57   views::Widget::InitParams params(
     58       views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
     59   params.delegate = this;
     60   params.show_state = ui::SHOW_STATE_FULLSCREEN;
     61   params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
     62   // TODO(oshima): move the lock screen harness to ash.
     63   params.parent =
     64       ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(),
     65                                ash::kShellWindowId_LockScreenContainer);
     66   views::Widget::Init(params);
     67   wm::SetWindowVisibilityAnimationTransition(
     68       GetNativeView(), wm::ANIMATE_NONE);
     69 }
     70 
     71 }  // namespace chromeos
     72