diff options
author | nkostylev@google.com <nkostylev@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-12 11:37:25 +0000 |
---|---|---|
committer | nkostylev@google.com <nkostylev@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-12 11:37:25 +0000 |
commit | 6971921a5fc4cfa7190b965a4144f612d27efb0c (patch) | |
tree | c442eaf24dd42f8d9acc1539e6c4f687b493aab6 /chrome/browser/chromeos | |
parent | 5c7d598adfc690fe676c54f62cd733d25ee20fa8 (diff) | |
download | chromium_src-6971921a5fc4cfa7190b965a4144f612d27efb0c.zip chromium_src-6971921a5fc4cfa7190b965a4144f612d27efb0c.tar.gz chromium_src-6971921a5fc4cfa7190b965a4144f612d27efb0c.tar.bz2 |
Initial commit for product registration page.
UI only, not integrated into OOBE yet.
BUG= http://crosbug.com/4645
TEST=--login-screen=register should show wizard screen with about: page.
Review URL: http://codereview.chromium.org/2924010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52075 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos')
5 files changed, 209 insertions, 1 deletions
diff --git a/chrome/browser/chromeos/login/account_creation_view.h b/chrome/browser/chromeos/login/account_creation_view.h index cff9c0c..11aa14d 100644 --- a/chrome/browser/chromeos/login/account_creation_view.h +++ b/chrome/browser/chromeos/login/account_creation_view.h @@ -7,7 +7,6 @@ #include <string> -#include "base/timer.h" #include "chrome/browser/chromeos/login/web_page_view.h" #include "views/view.h" diff --git a/chrome/browser/chromeos/login/registration_screen.cc b/chrome/browser/chromeos/login/registration_screen.cc new file mode 100644 index 0000000..c802856 --- /dev/null +++ b/chrome/browser/chromeos/login/registration_screen.cc @@ -0,0 +1,94 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/chromeos/login/registration_screen.h" + +#include "base/string_util.h" +#include "chrome/browser/browser_process.h" +#include "chrome/browser/chromeos/input_method/input_method_util.h" +#include "chrome/browser/profile_manager.h" +#include "chrome/browser/renderer_host/render_view_host.h" +#include "chrome/browser/renderer_host/site_instance.h" +#include "chrome/browser/tab_contents/tab_contents.h" +#include "googleurl/src/gurl.h" + +namespace chromeos { + +namespace { +// TODO(nkostylev): Create host page in resources. +const char kRegistrationHostPageUrl[] = "about:"; +} // namespace + +/////////////////////////////////////////////////////////////////////////////// +// RegistrationScreen, public: +RegistrationScreen::RegistrationScreen(WizardScreenDelegate* delegate) + : ViewScreen<RegistrationView>(delegate) { + if (!host_page_url_.get()) + set_registration_host_page_url(GURL(kRegistrationHostPageUrl)); +} + +// static +void RegistrationScreen::set_registration_host_page_url(const GURL& url) { + host_page_url_.reset(new GURL(url)); +} + +// static +scoped_ptr<GURL> RegistrationScreen::host_page_url_; + +/////////////////////////////////////////////////////////////////////////////// +// RegistrationScreen, ViewScreen implementation: +void RegistrationScreen::CreateView() { + ViewScreen<RegistrationView>::CreateView(); + view()->SetWebPageDelegate(this); +} + +void RegistrationScreen::Refresh() { + StartTimeoutTimer(); + GURL url(*host_page_url_); + Profile* profile = ProfileManager::GetDefaultProfile(); + view()->InitDOM(profile, + SiteInstance::CreateSiteInstanceForURL(profile, url)); + view()->SetTabContentsDelegate(this); + view()->LoadURL(url); +} + +RegistrationView* RegistrationScreen::AllocateView() { + return new RegistrationView(); +} + +/////////////////////////////////////////////////////////////////////////////// +// RegistrationScreen, WebPageDelegate implementation: +void RegistrationScreen::OnPageLoaded() { + StopTimeoutTimer(); + // Enable input methods (e.g. Chinese, Japanese) so that users could input + // their first and last names. + if (g_browser_process) { + const std::string locale = g_browser_process->GetApplicationLocale(); + input_method::EnableInputMethods( + locale, input_method::kKeyboardLayoutsOnly, ""); + // TODO(yusukes,suzhe): Change the 2nd argument to kAllInputMethods when + // crosbug.com/2670 is fixed. + } + view()->ShowPageContent(); +} + +void RegistrationScreen::OnPageLoadFailed(const std::string& url) { + CloseScreen(ScreenObserver::CONNECTION_FAILED); +} + +/////////////////////////////////////////////////////////////////////////////// +// RegistrationScreen, private: +void RegistrationScreen::CloseScreen(ScreenObserver::ExitCodes code) { + StopTimeoutTimer(); + // Disable input methods since they are not necessary to input username and + // password. + if (g_browser_process) { + const std::string locale = g_browser_process->GetApplicationLocale(); + input_method::EnableInputMethods( + locale, input_method::kKeyboardLayoutsOnly, ""); + } + delegate()->GetObserver(this)->OnExit(code); +} + +} // namespace chromeos diff --git a/chrome/browser/chromeos/login/registration_screen.h b/chrome/browser/chromeos/login/registration_screen.h new file mode 100644 index 0000000..8148505 --- /dev/null +++ b/chrome/browser/chromeos/login/registration_screen.h @@ -0,0 +1,95 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_REGISTRATION_SCREEN_H_ +#define CHROME_BROWSER_CHROMEOS_LOGIN_REGISTRATION_SCREEN_H_ + +#include <string> + +#include "base/scoped_ptr.h" +#include "chrome/browser/chromeos/login/screen_observer.h" +#include "chrome/browser/chromeos/login/view_screen.h" +#include "chrome/browser/chromeos/login/web_page_screen.h" +#include "chrome/browser/chromeos/login/web_page_view.h" + +class GURL; +class Profile; +class SiteContents; +class WizardScreenDelegate; + +namespace chromeos { + +// Class that renders host registration page. +class RegistrationDomView : public WebPageDomView { + public: + RegistrationDomView() {} + + protected: + // Overriden from DOMView: + virtual TabContents* CreateTabContents(Profile* profile, + SiteInstance* instance) { + return new WizardWebPageViewTabContents(profile, + instance, + page_delegate_); + } + + DISALLOW_COPY_AND_ASSIGN(RegistrationDomView); +}; + +// Class that displays screen contents: page and throbber while waiting. +class RegistrationView : public WebPageView { + public: + RegistrationView() : dom_view_(new RegistrationDomView()) {} + + protected: + virtual WebPageDomView* dom_view() { return dom_view_; } + + private: + // View that renders page. + RegistrationDomView* dom_view_; + + DISALLOW_COPY_AND_ASSIGN(RegistrationView); +}; + +// RegistrationScreen represents screen that is shown during OOBE. +// It renders host page served from resources that includes iframe with +// registration page specified in the startup customization manifest. +// Partner registration page notifies host page on registration result. +// Host page notifies that back to RegistrationScreen. +class RegistrationScreen : public ViewScreen<RegistrationView>, + public WebPageScreen, + public WebPageDelegate { + public: + explicit RegistrationScreen(WizardScreenDelegate* delegate); + + // WebPageDelegate implementation: + virtual void OnPageLoaded(); + virtual void OnPageLoadFailed(const std::string& url); + + // Sets the url for registration host page. Used in tests. + static void set_registration_host_page_url(const GURL& url); + + private: + // ViewScreen implementation: + virtual void CreateView(); + virtual void Refresh(); + virtual RegistrationView* AllocateView(); + + // TabContentsDelegate implementation: + virtual void LoadingStateChanged(TabContents* source) {} + virtual void NavigationStateChanged(const TabContents* source, + unsigned changed_flags) {} + + // WebPageScreen implementation: + virtual void CloseScreen(ScreenObserver::ExitCodes code); + + // Url of account creation page. Overriden by tests. + static scoped_ptr<GURL> host_page_url_; + + DISALLOW_COPY_AND_ASSIGN(RegistrationScreen); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_LOGIN_REGISTRATION_SCREEN_H_ diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc index 8902f6a..e5abc13 100644 --- a/chrome/browser/chromeos/login/wizard_controller.cc +++ b/chrome/browser/chromeos/login/wizard_controller.cc @@ -28,6 +28,7 @@ #include "chrome/browser/chromeos/login/login_screen.h" #include "chrome/browser/chromeos/login/login_utils.h" #include "chrome/browser/chromeos/login/network_screen.h" +#include "chrome/browser/chromeos/login/registration_screen.h" #include "chrome/browser/chromeos/login/rounded_rect_painter.h" #include "chrome/browser/chromeos/login/update_screen.h" #include "chrome/browser/chromeos/login/user_image_screen.h" @@ -161,6 +162,7 @@ const char WizardController::kLoginScreenName[] = "login"; const char WizardController::kAccountScreenName[] = "account"; const char WizardController::kUpdateScreenName[] = "update"; const char WizardController::kUserImageScreenName[] = "image"; +const char WizardController::kRegistrationScreenName[] = "register"; // Passing this parameter as a "first screen" initiates full OOBE flow. const char WizardController::kOutOfBoxScreenName[] = "oobe"; @@ -292,6 +294,12 @@ chromeos::UserImageScreen* WizardController::GetUserImageScreen() { return user_image_screen_.get(); } +chromeos::RegistrationScreen* WizardController::GetRegistrationScreen() { + if (!registration_screen_.get()) + registration_screen_.reset(new chromeos::RegistrationScreen(this)); + return registration_screen_.get(); +} + void WizardController::ShowNetworkScreen() { SetStatusAreaVisible(false); SetCurrentScreen(GetNetworkScreen()); @@ -338,6 +346,11 @@ void WizardController::ShowUserImageScreen() { SetCurrentScreen(GetUserImageScreen()); } +void WizardController::ShowRegistrationScreen() { + SetStatusAreaVisible(true); + SetCurrentScreen(GetRegistrationScreen()); +} + void WizardController::SetStatusAreaVisible(bool visible) { // When ExistingUserController passes background ownership // to WizardController it happens after screen is shown. @@ -495,6 +508,8 @@ void WizardController::ShowFirstScreen(const std::string& first_screen_name) { GetUpdateScreen()->StartUpdate(); } else if (first_screen_name == kUserImageScreenName) { ShowUserImageScreen(); + } else if (first_screen_name == kRegistrationScreenName) { + ShowRegistrationScreen(); } else if (first_screen_name != kTestNoScreenName) { if (is_out_of_box_) { ShowNetworkScreen(); diff --git a/chrome/browser/chromeos/login/wizard_controller.h b/chrome/browser/chromeos/login/wizard_controller.h index 5fdf5fb..f276c4e 100644 --- a/chrome/browser/chromeos/login/wizard_controller.h +++ b/chrome/browser/chromeos/login/wizard_controller.h @@ -23,6 +23,7 @@ class AccountScreen; class BackgroundView; class LoginScreen; class NetworkScreen; +class RegistrationScreen; class UserImageScreen; class UpdateScreen; class StartupCustomizationDocument; @@ -75,6 +76,7 @@ class WizardController : public chromeos::ScreenObserver, chromeos::AccountScreen* GetAccountScreen(); chromeos::UpdateScreen* GetUpdateScreen(); chromeos::UserImageScreen* GetUserImageScreen(); + chromeos::RegistrationScreen* GetRegistrationScreen(); // Show specific screen. void ShowNetworkScreen(); @@ -82,6 +84,7 @@ class WizardController : public chromeos::ScreenObserver, void ShowAccountScreen(); void ShowUpdateScreen(); void ShowUserImageScreen(); + void ShowRegistrationScreen(); // Returns a pointer to the current screen or NULL if there's no such // screen. @@ -103,6 +106,7 @@ class WizardController : public chromeos::ScreenObserver, static const char kAccountScreenName[]; static const char kUpdateScreenName[]; static const char kUserImageScreenName[]; + static const char kRegistrationScreenName[]; static const char kOutOfBoxScreenName[]; static const char kTestNoScreenName[]; @@ -160,6 +164,7 @@ class WizardController : public chromeos::ScreenObserver, scoped_ptr<chromeos::AccountScreen> account_screen_; scoped_ptr<chromeos::UpdateScreen> update_screen_; scoped_ptr<chromeos::UserImageScreen> user_image_screen_; + scoped_ptr<chromeos::RegistrationScreen> registration_screen_; // Screen that's currently active. WizardScreen* current_screen_; |