Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / chromeos / login / terms_of_service_screen_handler.h
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 class CoreOobeActor;
18
19 // The sole implementation of the TermsOfServiceScreenActor, using WebUI.
20 class TermsOfServiceScreenHandler : public BaseScreenHandler,
21                                     public TermsOfServiceScreenActor {
22  public:
23   explicit TermsOfServiceScreenHandler(CoreOobeActor* core_oobe_actor);
24   virtual ~TermsOfServiceScreenHandler();
25
26   // content::WebUIMessageHandler:
27   virtual void RegisterMessages() override;
28
29   // BaseScreenHandler:
30   virtual void DeclareLocalizedValues(LocalizedValuesBuilder* builder) override;
31
32   // TermsOfServiceScreenActor:
33   virtual void SetDelegate(Delegate* screen) override;
34   virtual void Show() override;
35   virtual void Hide() override;
36   virtual void SetDomain(const std::string& domain) override;
37   virtual void OnLoadError() override;
38   virtual void OnLoadSuccess(const std::string& terms_of_service) override;
39
40  private:
41   // BaseScreenHandler:
42   virtual void Initialize() override;
43
44   // Callback invoked after the UI locale has been changed.
45   void OnLanguageChangedCallback(const std::string& requested_locale,
46                                  const std::string& loaded_locale,
47                                  const bool success);
48
49   // Switch to the user's preferred input method and show the screen. This
50   // method is called after it has been ensured that the current UI locale
51   // matches the UI locale chosen by the user.
52   void DoShow();
53
54   // Update the domain name shown in the UI.
55   void UpdateDomainInUI();
56
57   // Update the UI to show an error message or the Terms of Service, depending
58   // on whether the download of the Terms of Service was successful. Does
59   // nothing if the download is still in progress.
60   void UpdateTermsOfServiceInUI();
61
62   // Called when the user declines the Terms of Service by clicking the "back"
63   // button.
64   void HandleBack();
65
66   // Called when the user accepts the Terms of Service by clicking the "accept
67   // and continue" button.
68   void HandleAccept();
69
70   TermsOfServiceScreenHandler::Delegate* screen_;
71
72   CoreOobeActor* core_oobe_actor_;
73
74   // Whether the screen should be shown right after initialization.
75   bool show_on_init_;
76
77   // The domain name whose Terms of Service are being shown.
78   std::string domain_;
79
80   // Set to |true| when the download of the Terms of Service fails.
81   bool load_error_;
82
83   // Set to the Terms of Service when the download is successful.
84   std::string terms_of_service_;
85
86   DISALLOW_COPY_AND_ASSIGN(TermsOfServiceScreenHandler);
87 };
88
89 }  // namespace chromeos
90
91 #endif  // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_TERMS_OF_SERVICE_SCREEN_HANDLER_H_