• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_UI_WEBUI_CHROMEOS_LOGIN_TERMS_OF_SERVICE_SCREEN_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_TERMS_OF_SERVICE_SCREEN_HANDLER_H_
7 
8 #include <string>
9 
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "chrome/browser/chromeos/login/screens/terms_of_service_screen_actor.h"
13 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
14 
15 namespace chromeos {
16 
17 // The sole implementation of the TermsOfServiceScreenActor, using WebUI.
18 class TermsOfServiceScreenHandler : public BaseScreenHandler,
19                                     public TermsOfServiceScreenActor {
20  public:
21   TermsOfServiceScreenHandler();
22   virtual ~TermsOfServiceScreenHandler();
23 
24   // content::WebUIMessageHandler:
25   virtual void RegisterMessages() OVERRIDE;
26 
27   // BaseScreenHandler:
28   virtual void DeclareLocalizedValues(LocalizedValuesBuilder* builder) OVERRIDE;
29 
30   // TermsOfServiceScreenActor:
31   virtual void SetDelegate(Delegate* screen) OVERRIDE;
32   virtual void Show() OVERRIDE;
33   virtual void Hide() OVERRIDE;
34   virtual void SetDomain(const std::string& domain) OVERRIDE;
35   virtual void OnLoadError() OVERRIDE;
36   virtual void OnLoadSuccess(const std::string& terms_of_service) OVERRIDE;
37 
38  private:
39   // BaseScreenHandler:
40   virtual void Initialize() OVERRIDE;
41 
42   // Update the domain name shown in the UI.
43   void UpdateDomainInUI();
44 
45   // Update the UI to show an error message or the Terms of Service, depending
46   // on whether the download of the Terms of Service was successful. Does
47   // nothing if the download is still in progress.
48   void UpdateTermsOfServiceInUI();
49 
50   // Called when the user declines the Terms of Service by clicking the "back"
51   // button.
52   void HandleBack();
53 
54   // Called when the user accepts the Terms of Service by clicking the "accept
55   // and continue" button.
56   void HandleAccept();
57 
58   TermsOfServiceScreenHandler::Delegate* screen_;
59 
60   // Whether the screen should be shown right after initialization.
61   bool show_on_init_;
62 
63   // The domain name whose Terms of Service are being shown.
64   std::string domain_;
65 
66   // Set to |true| when the download of the Terms of Service fails.
67   bool load_error_;
68 
69   // Set to the Terms of Service when the download is successful.
70   std::string terms_of_service_;
71 
72   DISALLOW_COPY_AND_ASSIGN(TermsOfServiceScreenHandler);
73 };
74 
75 }  // namespace chromeos
76 
77 #endif  // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_TERMS_OF_SERVICE_SCREEN_HANDLER_H_
78