OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/chromeos/login/wizard_controller.h" | 5 #include "chrome/browser/chromeos/login/wizard_controller.h" |
6 | 6 |
7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
8 #include <signal.h> | 8 #include <signal.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "app/resource_bundle.h" | 14 #include "app/resource_bundle.h" |
15 #include "app/l10n_util.h" | 15 #include "app/l10n_util.h" |
16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
17 #include "base/logging.h" // For NOTREACHED. | 17 #include "base/logging.h" // For NOTREACHED. |
18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/chromeos/cros/cros_library.h" | 19 #include "chrome/browser/chromeos/cros/cros_library.h" |
20 #include "chrome/browser/chromeos/cros/login_library.h" | 20 #include "chrome/browser/chromeos/cros/login_library.h" |
21 #include "chrome/browser/chromeos/login/account_screen.h" | 21 #include "chrome/browser/chromeos/login/account_screen.h" |
22 #include "chrome/browser/chromeos/login/background_view.h" | 22 #include "chrome/browser/chromeos/login/background_view.h" |
23 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 23 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
24 #include "chrome/browser/chromeos/login/network_screen.h" | 24 #include "chrome/browser/chromeos/login/network_screen.h" |
25 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" | 25 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" |
26 #include "chrome/browser/chromeos/login/user_manager.h" | 26 #include "chrome/browser/chromeos/login/user_manager.h" |
27 #include "chrome/browser/chromeos/wm_ipc.h" | 27 #include "chrome/browser/chromeos/wm_ipc.h" |
28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 29 #include "views/accelerator.h" |
29 #include "views/painter.h" | 30 #include "views/painter.h" |
30 #include "views/screen.h" | 31 #include "views/screen.h" |
31 #include "views/view.h" | 32 #include "views/view.h" |
32 #include "views/widget/widget_gtk.h" | 33 #include "views/widget/widget_gtk.h" |
33 | 34 |
34 namespace { | 35 namespace { |
35 | 36 |
36 const int kWizardScreenWidth = 700; | 37 const int kWizardScreenWidth = 700; |
37 const int kWizardScreenHeight = 416; | 38 const int kWizardScreenHeight = 416; |
38 | 39 |
39 // RootView of the Widget WizardController creates. Contains the contents of the | 40 // RootView of the Widget WizardController creates. Contains the contents of the |
40 // WizardController. | 41 // WizardController. |
41 class ContentView : public views::View { | 42 class ContentView : public views::View { |
42 public: | 43 public: |
43 ContentView(bool paint_background, int window_x, int window_y, int screen_w, | 44 ContentView(bool paint_background, int window_x, int window_y, int screen_w, |
44 int screen_h) | 45 int screen_h) |
45 : window_x_(window_x), | 46 : window_x_(window_x), |
46 window_y_(window_y), | 47 window_y_(window_y), |
47 screen_w_(screen_w), | 48 screen_w_(screen_w), |
48 screen_h_(screen_h) { | 49 screen_h_(screen_h), |
| 50 accel_login_screen_(views::Accelerator(base::VKEY_L, |
| 51 false, true, true)) { |
49 if (paint_background) { | 52 if (paint_background) { |
50 painter_.reset(chromeos::CreateWizardPainter( | 53 painter_.reset(chromeos::CreateWizardPainter( |
51 &chromeos::BorderDefinition::kWizardBorder)); | 54 &chromeos::BorderDefinition::kWizardBorder)); |
52 } | 55 } |
| 56 |
| 57 AddAccelerator(accel_login_screen_); |
| 58 } |
| 59 |
| 60 bool AcceleratorPressed(const views::Accelerator& accel) { |
| 61 if (accel == accel_login_screen_) { |
| 62 WizardController *controller = WizardController::default_controller(); |
| 63 if (controller) |
| 64 controller->ShowFirstScreen(WizardController::kLoginScreenName); |
| 65 return true; |
| 66 } |
| 67 |
| 68 return false; |
53 } | 69 } |
54 | 70 |
55 void PaintBackground(gfx::Canvas* canvas) { | 71 void PaintBackground(gfx::Canvas* canvas) { |
56 if (painter_.get()) { | 72 if (painter_.get()) { |
57 // TODO(sky): nuke this once new login manager is in place. This needs to | 73 // TODO(sky): nuke this once new login manager is in place. This needs to |
58 // exist because with no window manager transparency isn't really | 74 // exist because with no window manager transparency isn't really |
59 // supported. | 75 // supported. |
60 canvas->TranslateInt(-window_x_, -window_y_); | 76 canvas->TranslateInt(-window_x_, -window_y_); |
61 painter_->Paint(screen_w_, screen_h_, canvas); | 77 painter_->Paint(screen_w_, screen_h_, canvas); |
62 } | 78 } |
63 } | 79 } |
64 | 80 |
65 virtual void Layout() { | 81 virtual void Layout() { |
66 for (int i = 0; i < GetChildViewCount(); ++i) { | 82 for (int i = 0; i < GetChildViewCount(); ++i) { |
67 views::View* cur = GetChildViewAt(i); | 83 views::View* cur = GetChildViewAt(i); |
68 if (cur->IsVisible()) | 84 if (cur->IsVisible()) |
69 cur->SetBounds(0, 0, width(), height()); | 85 cur->SetBounds(0, 0, width(), height()); |
70 } | 86 } |
71 } | 87 } |
72 | 88 |
73 private: | 89 private: |
74 scoped_ptr<views::Painter> painter_; | 90 scoped_ptr<views::Painter> painter_; |
75 | 91 |
76 const int window_x_; | 92 const int window_x_; |
77 const int window_y_; | 93 const int window_y_; |
78 const int screen_w_; | 94 const int screen_w_; |
79 const int screen_h_; | 95 const int screen_h_; |
80 | 96 |
| 97 views::Accelerator accel_login_screen_; |
| 98 |
81 DISALLOW_COPY_AND_ASSIGN(ContentView); | 99 DISALLOW_COPY_AND_ASSIGN(ContentView); |
82 }; | 100 }; |
83 | 101 |
84 | 102 |
85 // Returns bounds of the screen to use for login wizard. | 103 // Returns bounds of the screen to use for login wizard. |
86 // The rect is centered within the default monitor and sized accordingly if | 104 // The rect is centered within the default monitor and sized accordingly if |
87 // |size| is not empty. Otherwise the whole monitor is occupied. | 105 // |size| is not empty. Otherwise the whole monitor is occupied. |
88 gfx::Rect CalculateScreenBounds(const gfx::Size& size) { | 106 gfx::Rect CalculateScreenBounds(const gfx::Size& size) { |
89 gfx::Rect bounds(views::Screen::GetMonitorWorkAreaNearestWindow(NULL)); | 107 gfx::Rect bounds(views::Screen::GetMonitorWorkAreaNearestWindow(NULL)); |
90 if (!size.IsEmpty()) { | 108 if (!size.IsEmpty()) { |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 | 437 |
420 WizardController* controller = new WizardController(); | 438 WizardController* controller = new WizardController(); |
421 controller->ShowBackground(screen_bounds); | 439 controller->ShowBackground(screen_bounds); |
422 controller->Init(first_screen_name, screen_bounds, true); | 440 controller->Init(first_screen_name, screen_bounds, true); |
423 controller->Show(); | 441 controller->Show(); |
424 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) | 442 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) |
425 chromeos::CrosLibrary::Get()->GetLoginLibrary()->EmitLoginPromptReady(); | 443 chromeos::CrosLibrary::Get()->GetLoginLibrary()->EmitLoginPromptReady(); |
426 } | 444 } |
427 | 445 |
428 } // namespace browser | 446 } // namespace browser |
OLD | NEW |