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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_NETWORK_SCREEN_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_NETWORK_SCREEN_HANDLER_H_
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"
24 struct NetworkScreenHandlerOnLanguageChangedCallbackData;
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 {
32 explicit NetworkScreenHandler(CoreOobeActor* core_oobe_actor);
33 virtual ~NetworkScreenHandler();
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;
53 // BaseScreenHandler implementation:
54 virtual void DeclareLocalizedValues(LocalizedValuesBuilder* builder) override;
55 virtual void GetAdditionalParameters(base::DictionaryValue* dict) override;
56 virtual void Initialize() override;
58 // WebUIMessageHandler implementation:
59 virtual void RegisterMessages() override;
61 // InputMethodManager::Observer implementation:
62 virtual void InputMethodChanged(input_method::InputMethodManager* manager,
63 bool show_message) override;
65 // Reloads localized contents.
66 void ReloadLocalizedContent();
68 // Handles moving off the screen.
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,
78 // Callback when the system timezone settings is changed.
79 void OnSystemTimezoneChanged();
81 // Returns available timezones. Caller gets the ownership.
82 static base::ListValue* GetTimezoneList();
84 NetworkScreenActor::Delegate* screen_;
85 CoreOobeActor* core_oobe_actor_;
87 bool is_continue_enabled_;
89 // Keeps whether screen should be shown right after initialization.
92 // Position of the network control.
93 gfx::Point network_control_pos_;
95 scoped_ptr<CrosSettings::ObserverSubscription> timezone_subscription_;
97 // The exact language code selected by user in the menu.
98 std::string selected_language_code_;
101 std::string input_method_;
102 std::string timezone_;
104 base::WeakPtrFactory<NetworkScreenHandler> weak_ptr_factory_;
106 DISALLOW_COPY_AND_ASSIGN(NetworkScreenHandler);
109 } // namespace chromeos
111 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_NETWORK_SCREEN_HANDLER_H_