OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/webui_login_display_host.h" | 5 #include "chrome/browser/chromeos/login/webui_login_display_host.h" |
6 | 6 |
| 7 #include "chrome/browser/chromeos/login/oobe_display.h" |
7 #include "chrome/browser/chromeos/login/webui_login_display.h" | 8 #include "chrome/browser/chromeos/login/webui_login_display.h" |
| 9 #include "chrome/browser/chromeos/login/webui_login_view.h" |
| 10 #include "chrome/browser/chromeos/login/touch_login_view.h" |
| 11 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 12 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 13 #include "views/widget/widget.h" |
8 | 14 |
9 namespace chromeos { | 15 namespace chromeos { |
10 | 16 |
| 17 namespace { |
| 18 |
| 19 // URL which corresponds to the login WebUI. |
| 20 const char kLoginURL[] = "chrome://login"; |
| 21 // URL which corresponds to the OOBE WebUI. |
| 22 const char kOobeURL[] = "chrome://oobe"; |
| 23 |
| 24 } // namespace |
| 25 |
11 // WebUILoginDisplayHost ------------------------------------------------------- | 26 // WebUILoginDisplayHost ------------------------------------------------------- |
12 | 27 |
13 WebUILoginDisplayHost::WebUILoginDisplayHost(const gfx::Rect& background_bounds) | 28 WebUILoginDisplayHost::WebUILoginDisplayHost(const gfx::Rect& background_bounds) |
14 : BaseLoginDisplayHost(background_bounds) { | 29 : BaseLoginDisplayHost(background_bounds), |
| 30 login_window_(NULL), |
| 31 login_view_(NULL) { |
15 } | 32 } |
16 | 33 |
17 WebUILoginDisplayHost::~WebUILoginDisplayHost() { | 34 WebUILoginDisplayHost::~WebUILoginDisplayHost() { |
| 35 if (login_window_) |
| 36 login_window_->Close(); |
18 } | 37 } |
19 | 38 |
20 // LoginDisplayHost implementation --------------------------------------------- | 39 // LoginDisplayHost implementation --------------------------------------------- |
21 | 40 |
22 LoginDisplay* WebUILoginDisplayHost::CreateLoginDisplay( | 41 LoginDisplay* WebUILoginDisplayHost::CreateLoginDisplay( |
23 LoginDisplay::Delegate* delegate) const { | 42 LoginDisplay::Delegate* delegate) const { |
24 WebUILoginDisplay* webui_login_display = WebUILoginDisplay::GetInstance(); | 43 WebUILoginDisplay* webui_login_display = WebUILoginDisplay::GetInstance(); |
25 webui_login_display->set_delegate(delegate); | 44 webui_login_display->set_delegate(delegate); |
26 webui_login_display->set_background_bounds(background_bounds()); | 45 webui_login_display->set_background_bounds(background_bounds()); |
27 return webui_login_display; | 46 return webui_login_display; |
(...skipping 14 matching lines...) Expand all Loading... |
42 | 61 |
43 void WebUILoginDisplayHost::SetStatusAreaEnabled(bool enable) { | 62 void WebUILoginDisplayHost::SetStatusAreaEnabled(bool enable) { |
44 } | 63 } |
45 | 64 |
46 void WebUILoginDisplayHost::SetStatusAreaVisible(bool visible) { | 65 void WebUILoginDisplayHost::SetStatusAreaVisible(bool visible) { |
47 } | 66 } |
48 | 67 |
49 void WebUILoginDisplayHost::ShowBackground() { | 68 void WebUILoginDisplayHost::ShowBackground() { |
50 } | 69 } |
51 | 70 |
| 71 void WebUILoginDisplayHost::StartWizard(const std::string& first_screen_name, |
| 72 const GURL& start_url) { |
| 73 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAllowWebUIOobe)) |
| 74 LoadURL(GURL(kOobeURL)); |
| 75 BaseLoginDisplayHost::StartWizard(first_screen_name, start_url); |
| 76 } |
| 77 |
| 78 void WebUILoginDisplayHost::StartSignInScreen() { |
| 79 LoadURL(GURL(kLoginURL)); |
| 80 WebUILoginDisplay::GetInstance()->set_login_window(login_window_); |
| 81 BaseLoginDisplayHost::StartSignInScreen(); |
| 82 } |
| 83 |
| 84 void WebUILoginDisplayHost::LoadURL(const GURL& url) { |
| 85 if (!login_window_) { |
| 86 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
| 87 params.bounds = background_bounds(); |
| 88 |
| 89 login_window_ = new views::Widget; |
| 90 login_window_->Init(params); |
| 91 #if defined(TOUCH_UI) |
| 92 login_view_ = new TouchLoginView(); |
| 93 #else |
| 94 login_view_ = new WebUILoginView(); |
| 95 #endif |
| 96 |
| 97 login_view_->Init(); |
| 98 login_window_->SetContentsView(login_view_); |
| 99 login_view_->UpdateWindowType(); |
| 100 |
| 101 login_window_->Show(); |
| 102 } |
| 103 login_view_->LoadURL(url); |
| 104 } |
| 105 |
| 106 WizardController* WebUILoginDisplayHost::CreateWizardController() { |
| 107 // TODO(altimofeev): ensure that WebUI is ready. |
| 108 OobeDisplay* oobe_display = static_cast<OobeUI*>(login_view_->GetWebUI()); |
| 109 return new WizardController(this, oobe_display); |
| 110 } |
| 111 |
52 } // namespace chromeos | 112 } // namespace chromeos |
53 | |
OLD | NEW |