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();
35 // NetworkScreenActor implementation:
36 virtual void SetDelegate(NetworkScreenActor::Delegate* screen) OVERRIDE;
37 virtual void PrepareToShow() OVERRIDE;
38 virtual void Show() OVERRIDE;
39 virtual void Hide() OVERRIDE;
40 virtual void ShowError(const base::string16& message) OVERRIDE;
41 virtual void ClearErrors() OVERRIDE;
42 virtual void ShowConnectingStatus(bool connecting,
43 const base::string16& network_id) OVERRIDE;
44 virtual void EnableContinue(bool enabled) OVERRIDE;
46 // BaseScreenHandler implementation:
47 virtual void DeclareLocalizedValues(LocalizedValuesBuilder* builder) OVERRIDE;
48 virtual void GetAdditionalParameters(base::DictionaryValue* dict) OVERRIDE;
49 virtual void Initialize() OVERRIDE;
51 // WebUIMessageHandler implementation:
52 virtual void RegisterMessages() OVERRIDE;
54 // InputMethodManager::Observer implementation:
55 virtual void InputMethodChanged(input_method::InputMethodManager* manager,
56 bool show_message) OVERRIDE;
58 // Reloads localized contents.
59 void ReloadLocalizedContent();
62 // Handles moving off the screen.
65 // Handles change of the language.
66 void HandleOnLanguageChanged(const std::string& locale);
68 // Async callback after ReloadResourceBundle(locale) completed.
69 static void OnLanguageChangedCallback(
70 scoped_ptr<NetworkScreenHandlerOnLanguageChangedCallbackData> context,
71 const std::string& requested_locale,
72 const std::string& loaded_locale,
75 // Handles change of the input method.
76 void HandleOnInputMethodChanged(const std::string& id);
78 // Handles change of the time zone
79 void HandleOnTimezoneChanged(const std::string& timezone);
81 // Callback when the system timezone settings is changed.
82 void OnSystemTimezoneChanged();
84 // Returns available timezones. Caller gets the ownership.
85 static base::ListValue* GetTimezoneList();
87 NetworkScreenActor::Delegate* screen_;
88 CoreOobeActor* core_oobe_actor_;
90 bool is_continue_enabled_;
92 // Keeps whether screen should be shown right after initialization.
95 // Position of the network control.
96 gfx::Point network_control_pos_;
98 scoped_ptr<CrosSettings::ObserverSubscription> timezone_subscription_;
100 // The exact language code selected by user in the menu.
101 std::string selected_language_code_;
103 base::WeakPtrFactory<NetworkScreenHandler> weak_ptr_factory_;
105 DISALLOW_COPY_AND_ASSIGN(NetworkScreenHandler);
108 } // namespace chromeos
110 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_NETWORK_SCREEN_HANDLER_H_