Re-enable these tests as they are no longer failing.
[chromium-blink-merge.git] / ash / shell / lock_view.cc
blob245bcee59ef77e36fc8de7644d211fb48e3c3b78
1 // Copyright (c) 2011 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.
5 #include "ash/shell.h"
6 #include "ash/shell_window_ids.h"
7 #include "ash/shell/example_factory.h"
8 #include "base/utf_string_conversions.h"
9 #include "ui/aura/root_window.h"
10 #include "ui/aura/window.h"
11 #include "ui/gfx/canvas.h"
12 #include "ui/gfx/font.h"
13 #include "ui/views/widget/widget.h"
14 #include "ui/views/widget/widget_delegate.h"
16 using ash::Shell;
18 namespace ash {
19 namespace shell {
21 class LockView : public views::WidgetDelegateView {
22 public:
23 LockView() {}
24 virtual ~LockView() {}
26 // Overridden from View:
27 virtual gfx::Size GetPreferredSize() OVERRIDE {
28 return gfx::Size(500, 400);
31 private:
32 // Overridden from View:
33 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
34 canvas->FillRect(SK_ColorYELLOW, GetLocalBounds());
35 string16 text = ASCIIToUTF16("LOCKED!");
36 int string_width = font_.GetStringWidth(text);
37 canvas->DrawStringInt(text, font_, SK_ColorRED, (width() - string_width)/ 2,
38 (height() - font_.GetHeight()) / 2,
39 string_width, font_.GetHeight());
41 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE {
42 return true;
44 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE {
45 GetWidget()->Close();
48 gfx::Font font_;
50 DISALLOW_COPY_AND_ASSIGN(LockView);
53 void CreateLockScreen() {
54 LockView* lock_view = new LockView;
55 views::Widget* widget = new views::Widget;
56 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
57 gfx::Size ps = lock_view->GetPreferredSize();
59 gfx::Size root_window_size = aura::RootWindow::GetInstance()->GetHostSize();
60 params.bounds = gfx::Rect((root_window_size.width() - ps.width()) / 2,
61 (root_window_size.height() - ps.height()) / 2,
62 ps.width(), ps.height());
63 params.delegate = lock_view;
64 widget->Init(params);
65 Shell::GetInstance()->GetContainer(
66 ash::internal::kShellWindowId_LockScreenContainer)->
67 AddChild(widget->GetNativeView());
68 widget->SetContentsView(lock_view);
69 widget->Show();
70 widget->GetNativeView()->SetName("LockView");
73 } // namespace shell
74 } // namespace ash