1 // Copyright (c) 2013 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_SCREENS_TERMS_OF_SERVICE_SCREEN_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_TERMS_OF_SERVICE_SCREEN_H_ 7 8 #include "base/basictypes.h" 9 #include "base/compiler_specific.h" 10 #include "base/memory/scoped_ptr.h" 11 #include "base/timer/timer.h" 12 #include "chrome/browser/chromeos/login/screens/terms_of_service_screen_actor.h" 13 #include "chrome/browser/chromeos/login/screens/wizard_screen.h" 14 #include "net/url_request/url_fetcher_delegate.h" 15 16 namespace net { 17 class URLFetcher; 18 } 19 20 namespace chromeos { 21 22 class ScreenObserver; 23 24 // A screen that shows Terms of Service which have been configured through 25 // policy. The screen is shown during login and requires the user to accept the 26 // Terms of Service before proceeding. Currently, Terms of Service are available 27 // for public sessions only. 28 class TermsOfServiceScreen : public WizardScreen, 29 public TermsOfServiceScreenActor::Delegate, 30 public net::URLFetcherDelegate { 31 public: 32 TermsOfServiceScreen(ScreenObserver* screen_observer, 33 TermsOfServiceScreenActor* actor); 34 virtual ~TermsOfServiceScreen(); 35 36 // WizardScreen: 37 virtual void PrepareToShow() OVERRIDE; 38 virtual void Show() OVERRIDE; 39 virtual void Hide() OVERRIDE; 40 virtual std::string GetName() const OVERRIDE; 41 42 // TermsOfServiceScreenActor::Delegate: 43 virtual void OnDecline() OVERRIDE; 44 virtual void OnAccept() OVERRIDE; 45 virtual void OnActorDestroyed(TermsOfServiceScreenActor* actor) OVERRIDE; 46 47 private: 48 // Start downloading the Terms of Service. 49 void StartDownload(); 50 51 // Abort the attempt to download the Terms of Service if it takes too long. 52 void OnDownloadTimeout(); 53 54 // net::URLFetcherDelegate: 55 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 56 57 TermsOfServiceScreenActor* actor_; 58 59 scoped_ptr<net::URLFetcher> terms_of_service_fetcher_; 60 61 // Timer that enforces a custom (shorter) timeout on the attempt to download 62 // the Terms of Service. 63 base::OneShotTimer<TermsOfServiceScreen> download_timer_; 64 65 DISALLOW_COPY_AND_ASSIGN(TermsOfServiceScreen); 66 }; 67 68 } // namespace chromeos 69 70 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_TERMS_OF_SERVICE_SCREEN_H_ 71