diff options
author | nkostylev@google.com <nkostylev@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-15 09:17:13 +0000 |
---|---|---|
committer | nkostylev@google.com <nkostylev@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-15 09:17:13 +0000 |
commit | 1d5a9ced82a3c4a4f62c04afe726bf23304a24b9 (patch) | |
tree | 80fe04a923a928e76a2ac713a9c81ea731bc4209 /chrome | |
parent | 7bef619f7f1cde7d07e5642afd5a780c15e3e6d9 (diff) | |
download | chromium_src-1d5a9ced82a3c4a4f62c04afe726bf23304a24b9.zip chromium_src-1d5a9ced82a3c4a4f62c04afe726bf23304a24b9.tar.gz chromium_src-1d5a9ced82a3c4a4f62c04afe726bf23304a24b9.tar.bz2 |
API to report on registration success/skip.
Not integrated into OOBE yet.
BUG= http://crosbug.com/3653
TEST=none
Review URL: http://codereview.chromium.org/2946008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52468 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
7 files changed, 88 insertions, 4 deletions
diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index 05173b6..18810cf 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -112,6 +112,7 @@ const char kSandboxPath[] = "sandbox"; #if defined(OS_CHROMEOS) const char kNetworkPath[] = "network"; const char kOSCreditsPath[] = "os-credits"; +const char kRegisterProductPath[] = "register"; const char kSysPath[] = "system"; #endif @@ -137,6 +138,7 @@ const char *kAllAboutPaths[] = { #if defined(OS_CHROMEOS) kNetworkPath, kOSCreditsPath, + kRegisterProductPath, kSysPath, #endif }; @@ -595,6 +597,19 @@ std::string AboutSandbox() { } #endif +#if defined(OS_CHROMEOS) +std::string AboutRegisterProduct() { + static const base::StringPiece register_html( + ResourceBundle::GetSharedInstance().GetRawDataResource( + IDR_HOST_REGISTRATION_PAGE_HTML)); + + // TODO(nkostylev): Embed registration form URL from startup manifest. + // http://crosbug.com/4645. + + return register_html.as_string(); +} +#endif + std::string AboutVersion(DictionaryValue* localized_strings) { localized_strings->SetString(L"title", l10n_util::GetString(IDS_ABOUT_VERSION_TITLE)); @@ -890,6 +905,8 @@ void AboutSource::StartDataRequest(const std::string& path_raw, #if defined(OS_CHROMEOS) } else if (path == kSysPath) { response = AboutSys(); + } else if (path == kRegisterProductPath) { + response = AboutRegisterProduct(); #endif } diff --git a/chrome/browser/chromeos/login/registration_screen.cc b/chrome/browser/chromeos/login/registration_screen.cc index c802856..c1e8446 100644 --- a/chrome/browser/chromeos/login/registration_screen.cc +++ b/chrome/browser/chromeos/login/registration_screen.cc @@ -4,20 +4,34 @@ #include "chrome/browser/chromeos/login/registration_screen.h" +#include "base/logging.h" #include "base/string_util.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/child_process_security_policy.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 "chrome/common/url_constants.h" #include "googleurl/src/gurl.h" +#include "net/url_request/url_request_about_job.h" +#include "net/url_request/url_request_filter.h" namespace chromeos { namespace { + // TODO(nkostylev): Create host page in resources. -const char kRegistrationHostPageUrl[] = "about:"; +const char kRegistrationHostPageUrl[] = "about:register"; + +// "Hostname" that is used for redirects from host registration page. +const char kRegistrationHostnameUrl[] = "register"; + +// Host page navigates to these URLs in case of success/skipped registration. +const char kRegistrationSuccessUrl[] = "cros://register/success"; +const char kRegistrationSkippedUrl[] = "cros://register/skipped"; + } // namespace /////////////////////////////////////////////////////////////////////////////// @@ -26,6 +40,13 @@ RegistrationScreen::RegistrationScreen(WizardScreenDelegate* delegate) : ViewScreen<RegistrationView>(delegate) { if (!host_page_url_.get()) set_registration_host_page_url(GURL(kRegistrationHostPageUrl)); + + ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( + chrome::kCrosScheme); + URLRequestFilter::GetInstance()->AddHostnameHandler( + chrome::kCrosScheme, + kRegistrationHostnameUrl, + &RegistrationScreen::Factory); } // static @@ -78,6 +99,20 @@ void RegistrationScreen::OnPageLoadFailed(const std::string& url) { } /////////////////////////////////////////////////////////////////////////////// +// RegistrationScreen, TabContentsDelegate implementation: +void RegistrationScreen::LoadingStateChanged(TabContents* source) { + std::string url = source->GetURL().spec(); + LOG(INFO) << "LoadingState changed url: " << url; + if (url == kRegistrationSuccessUrl) { + source->Stop(); + CloseScreen(ScreenObserver::REGISTRATION_SUCCESS); + } else if (url == kRegistrationSkippedUrl) { + source->Stop(); + CloseScreen(ScreenObserver::REGISTRATION_SKIPPED); + } +} + +/////////////////////////////////////////////////////////////////////////////// // RegistrationScreen, private: void RegistrationScreen::CloseScreen(ScreenObserver::ExitCodes code) { StopTimeoutTimer(); @@ -91,4 +126,11 @@ void RegistrationScreen::CloseScreen(ScreenObserver::ExitCodes code) { delegate()->GetObserver(this)->OnExit(code); } +// static +URLRequestJob* RegistrationScreen::Factory(URLRequest* request, + const std::string& scheme) { + LOG(INFO) << "Handling url: " << request->url().spec().c_str(); + return new URLRequestAboutJob(request); +} + } // namespace chromeos diff --git a/chrome/browser/chromeos/login/registration_screen.h b/chrome/browser/chromeos/login/registration_screen.h index 8148505..2e8ddd1 100644 --- a/chrome/browser/chromeos/login/registration_screen.h +++ b/chrome/browser/chromeos/login/registration_screen.h @@ -16,6 +16,8 @@ class GURL; class Profile; class SiteContents; +class URLRequest; +class URLRequestJob; class WizardScreenDelegate; namespace chromeos { @@ -70,6 +72,10 @@ class RegistrationScreen : public ViewScreen<RegistrationView>, // Sets the url for registration host page. Used in tests. static void set_registration_host_page_url(const GURL& url); + // Handler factory for URLRequestFilter::AddHostnameHandler. + static URLRequestJob* Factory(URLRequest* request, + const std::string& scheme); + private: // ViewScreen implementation: virtual void CreateView(); @@ -77,7 +83,7 @@ class RegistrationScreen : public ViewScreen<RegistrationView>, virtual RegistrationView* AllocateView(); // TabContentsDelegate implementation: - virtual void LoadingStateChanged(TabContents* source) {} + virtual void LoadingStateChanged(TabContents* source); virtual void NavigationStateChanged(const TabContents* source, unsigned changed_flags) {} diff --git a/chrome/browser/chromeos/login/screen_observer.h b/chrome/browser/chromeos/login/screen_observer.h index b2bfd3f..85875f1 100644 --- a/chrome/browser/chromeos/login/screen_observer.h +++ b/chrome/browser/chromeos/login/screen_observer.h @@ -34,6 +34,8 @@ class ScreenObserver { USER_IMAGE_SELECTED, USER_IMAGE_SKIPPED, EULA_ACCEPTED, + REGISTRATION_SUCCESS, + REGISTRATION_SKIPPED, EXIT_CODES_COUNT // not a real code, must be the last }; diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc index 4d35239..eca46c6 100644 --- a/chrome/browser/chromeos/login/wizard_controller.cc +++ b/chrome/browser/chromeos/login/wizard_controller.cc @@ -13,7 +13,7 @@ #include "app/l10n_util.h" #include "base/command_line.h" -#include "base/logging.h" // For NOTREACHED. +#include "base/logging.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/cros/login_library.h" @@ -493,6 +493,16 @@ void WizardController::OnUserImageSkipped() { OnUserImageSelected(); } +void WizardController::OnRegistrationSuccess() { + // TODO(nkostylev): Registration screen should be shown on first sign in. + ShowLoginScreen(); +} + +void WizardController::OnRegistrationSkipped() { + // TODO(nkostylev): Track in a histogram? + OnRegistrationSuccess(); +} + /////////////////////////////////////////////////////////////////////////////// // WizardController, private: @@ -596,6 +606,11 @@ void WizardController::OnExit(ExitCodes exit_code) { case EULA_ACCEPTED: OnEulaAccepted(); break; + case REGISTRATION_SUCCESS: + OnRegistrationSuccess(); + break; + case REGISTRATION_SKIPPED: + OnRegistrationSkipped(); default: NOTREACHED(); } diff --git a/chrome/browser/chromeos/login/wizard_controller.h b/chrome/browser/chromeos/login/wizard_controller.h index 15372b3..d5b69b9 100644 --- a/chrome/browser/chromeos/login/wizard_controller.h +++ b/chrome/browser/chromeos/login/wizard_controller.h @@ -130,6 +130,8 @@ class WizardController : public chromeos::ScreenObserver, void OnUpdateErrorUpdating(); void OnUserImageSelected(); void OnUserImageSkipped(); + void OnRegistrationSuccess(); + void OnRegistrationSkipped(); // Switches from one screen to another. void SetCurrentScreen(WizardScreen* screen); diff --git a/chrome/browser/chromeos/login/wizard_controller_browsertest.cc b/chrome/browser/chromeos/login/wizard_controller_browsertest.cc index 163aa22..6459286 100644 --- a/chrome/browser/chromeos/login/wizard_controller_browsertest.cc +++ b/chrome/browser/chromeos/login/wizard_controller_browsertest.cc @@ -227,5 +227,5 @@ IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest, Accelerators) { EXPECT_EQ(controller()->GetEulaScreen(), controller()->current_screen()); } -COMPILE_ASSERT(chromeos::ScreenObserver::EXIT_CODES_COUNT == 15, +COMPILE_ASSERT(chromeos::ScreenObserver::EXIT_CODES_COUNT == 17, add_tests_for_new_control_flow_you_just_introduced); |