5e0d95fb24d80a367cd308f2f7f41928faf2eb3e
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / chromeos / login / network_screen_handler.h
1 // Copyright (c) 2012 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_NETWORK_SCREEN_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_NETWORK_SCREEN_HANDLER_H_
7
8 #include <string>
9
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/chromeos/login/screens/network_screen_actor.h"
13 #include "chrome/browser/chromeos/settings/cros_settings.h"
14 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
15 #include "chromeos/ime/component_extension_ime_manager.h"
16 #include "chromeos/ime/input_method_manager.h"
17 #include "ui/gfx/point.h"
18
19 namespace chromeos {
20
21 class CoreOobeActor;
22 class IdleDetector;
23
24 struct NetworkScreenHandlerOnLanguageChangedCallbackData;
25
26 // WebUI implementation of NetworkScreenActor. It is used to interact with
27 // the welcome screen (part of the page) of the OOBE.
28 class NetworkScreenHandler : public NetworkScreenActor,
29                              public BaseScreenHandler,
30                              public input_method::InputMethodManager::Observer {
31  public:
32   explicit NetworkScreenHandler(CoreOobeActor* core_oobe_actor);
33   virtual ~NetworkScreenHandler();
34
35  private:
36   // NetworkScreenActor implementation:
37   virtual void SetDelegate(NetworkScreenActor::Delegate* screen) override;
38   virtual void PrepareToShow() override;
39   virtual void Show() override;
40   virtual void Hide() override;
41   virtual void ShowError(const base::string16& message) override;
42   virtual void ClearErrors() override;
43   virtual void ShowConnectingStatus(bool connecting,
44                                     const base::string16& network_id) override;
45   virtual void EnableContinue(bool enabled) override;
46   virtual std::string GetApplicationLocale() const override;
47   virtual std::string GetInputMethod() const override;
48   virtual std::string GetTimezone() const override;
49   virtual void SetApplicationLocale(const std::string& locale) override;
50   virtual void SetInputMethod(const std::string& input_method) override;
51   virtual void SetTimezone(const std::string& timezone) override;
52
53   // BaseScreenHandler implementation:
54   virtual void DeclareLocalizedValues(LocalizedValuesBuilder* builder) override;
55   virtual void GetAdditionalParameters(base::DictionaryValue* dict) override;
56   virtual void Initialize() override;
57
58   // WebUIMessageHandler implementation:
59   virtual void RegisterMessages() override;
60
61   // InputMethodManager::Observer implementation:
62   virtual void InputMethodChanged(input_method::InputMethodManager* manager,
63                                   bool show_message) override;
64
65   // Reloads localized contents.
66   void ReloadLocalizedContent();
67
68   // Handles moving off the screen.
69   void HandleOnExit();
70
71   // Async callback after ReloadResourceBundle(locale) completed.
72   static void OnLanguageChangedCallback(
73       scoped_ptr<NetworkScreenHandlerOnLanguageChangedCallbackData> context,
74       const std::string& requested_locale,
75       const std::string& loaded_locale,
76       const bool success);
77
78   // Callback when the system timezone settings is changed.
79   void OnSystemTimezoneChanged();
80
81   // Returns available timezones. Caller gets the ownership.
82   static base::ListValue* GetTimezoneList();
83
84   NetworkScreenActor::Delegate* screen_;
85   CoreOobeActor* core_oobe_actor_;
86
87   bool is_continue_enabled_;
88
89   // Keeps whether screen should be shown right after initialization.
90   bool show_on_init_;
91
92   // Position of the network control.
93   gfx::Point network_control_pos_;
94
95   scoped_ptr<CrosSettings::ObserverSubscription> timezone_subscription_;
96
97   // The exact language code selected by user in the menu.
98   std::string selected_language_code_;
99
100   std::string locale_;
101   std::string input_method_;
102   std::string timezone_;
103
104   base::WeakPtrFactory<NetworkScreenHandler> weak_ptr_factory_;
105
106   DISALLOW_COPY_AND_ASSIGN(NetworkScreenHandler);
107 };
108
109 }  // namespace chromeos
110
111 #endif  // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_NETWORK_SCREEN_HANDLER_H_