Home | History | Annotate | Download | only in login
      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.
      4 
      5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_REGISTRATION_SCREEN_H_
      6 #define CHROME_BROWSER_CHROMEOS_LOGIN_REGISTRATION_SCREEN_H_
      7 #pragma once
      8 
      9 #include <string>
     10 
     11 #include "base/memory/scoped_ptr.h"
     12 #include "chrome/browser/chromeos/login/screen_observer.h"
     13 #include "chrome/browser/chromeos/login/view_screen.h"
     14 #include "chrome/browser/chromeos/login/web_page_screen.h"
     15 #include "chrome/browser/chromeos/login/web_page_view.h"
     16 
     17 namespace net {
     18 class URLRequest;
     19 class URLRequestJob;
     20 }  // namespace net
     21 
     22 class GURL;
     23 class Profile;
     24 class SiteContents;
     25 class WizardScreenDelegate;
     26 
     27 namespace chromeos {
     28 
     29 // Class that renders host registration page.
     30 class RegistrationDomView : public WebPageDomView {
     31  public:
     32   RegistrationDomView() {}
     33 
     34  protected:
     35   // Overriden from DOMView:
     36   virtual TabContents* CreateTabContents(Profile* profile,
     37                                          SiteInstance* instance) {
     38     return new WizardWebPageViewTabContents(profile,
     39                                             instance,
     40                                             page_delegate_);
     41   }
     42 
     43   DISALLOW_COPY_AND_ASSIGN(RegistrationDomView);
     44 };
     45 
     46 // Class that displays screen contents: page and throbber while waiting.
     47 class RegistrationView : public WebPageView {
     48  public:
     49   RegistrationView() : dom_view_(new RegistrationDomView()) {}
     50 
     51  protected:
     52   virtual WebPageDomView* dom_view() { return dom_view_; }
     53 
     54  private:
     55   // View that renders page.
     56   RegistrationDomView* dom_view_;
     57 
     58   DISALLOW_COPY_AND_ASSIGN(RegistrationView);
     59 };
     60 
     61 // RegistrationScreen represents screen that is shown during OOBE.
     62 // It renders host page served from resources that includes iframe with
     63 // registration page specified in the startup customization manifest.
     64 // Partner registration page notifies host page on registration result.
     65 // Host page notifies that back to RegistrationScreen.
     66 class RegistrationScreen : public ViewScreen<RegistrationView>,
     67                            public WebPageScreen,
     68                            public WebPageDelegate {
     69  public:
     70   explicit RegistrationScreen(WizardScreenDelegate* delegate);
     71 
     72   // WebPageDelegate implementation:
     73   virtual void OnPageLoaded();
     74   virtual void OnPageLoadFailed(const std::string& url);
     75 
     76   // Sets the url for registration host page. Used in tests.
     77   static void set_registration_host_page_url(const GURL& url);
     78 
     79   // Handler factory for net::URLRequestFilter::AddHostnameHandler.
     80   static net::URLRequestJob* Factory(net::URLRequest* request,
     81                                      const std::string& scheme);
     82 
     83  private:
     84   // ViewScreen implementation:
     85   virtual void CreateView();
     86   virtual void Refresh();
     87   virtual RegistrationView* AllocateView();
     88 
     89   // TabContentsDelegate implementation:
     90   virtual void LoadingStateChanged(TabContents* source) {}
     91   virtual void NavigationStateChanged(const TabContents* source,
     92                                       unsigned changed_flags) {}
     93   virtual void OpenURLFromTab(TabContents* source,
     94                               const GURL& url,
     95                               const GURL& referrer,
     96                               WindowOpenDisposition disposition,
     97                               PageTransition::Type transition);
     98   virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event);
     99 
    100   // WebPageScreen implementation:
    101   virtual void CloseScreen(ScreenObserver::ExitCodes code);
    102 
    103   // Url of account creation page. Overriden by tests.
    104   static scoped_ptr<GURL> host_page_url_;
    105 
    106   DISALLOW_COPY_AND_ASSIGN(RegistrationScreen);
    107 };
    108 
    109 }  // namespace chromeos
    110 
    111 #endif  // CHROME_BROWSER_CHROMEOS_LOGIN_REGISTRATION_SCREEN_H_
    112