Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: chrome/browser/chromeos/login/screens/network_screen.h

Issue 2649873009: cros: Fold NetworkModel into NetworkScreen (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_NETWORK_SCREEN_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_NETWORK_SCREEN_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_NETWORK_SCREEN_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_NETWORK_SCREEN_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
17 #include "base/timer/timer.h" 17 #include "base/timer/timer.h"
18 #include "chrome/browser/chromeos/login/screens/network_model.h" 18 #include "chrome/browser/chromeos/login/screens/base_screen.h"
19 #include "chrome/browser/chromeos/settings/cros_settings.h" 19 #include "chrome/browser/chromeos/settings/cros_settings.h"
20 #include "chromeos/network/network_state_handler_observer.h" 20 #include "chromeos/network/network_state_handler_observer.h"
21 #include "ui/base/ime/chromeos/input_method_manager.h" 21 #include "ui/base/ime/chromeos/input_method_manager.h"
22 22
23 namespace chromeos { 23 namespace chromeos {
24 24
25 class InputEventsBlocker; 25 class InputEventsBlocker;
26 class NetworkView; 26 class NetworkView;
27 class ScreenManager; 27 class ScreenManager;
28 28
29 namespace locale_util { 29 namespace locale_util {
30 struct LanguageSwitchResult; 30 struct LanguageSwitchResult;
31 } 31 }
32 32
33 namespace login { 33 namespace login {
34 class NetworkStateHelper; 34 class NetworkStateHelper;
35 } 35 }
36 36
37 class NetworkScreen : public NetworkModel, 37 class NetworkScreen : public BaseScreen,
38 public NetworkStateHandlerObserver, 38 public NetworkStateHandlerObserver,
39 public input_method::InputMethodManager::Observer { 39 public input_method::InputMethodManager::Observer {
40 public: 40 public:
41 class Delegate { 41 class Delegate {
42 public: 42 public:
43 virtual ~Delegate() {} 43 virtual ~Delegate() {}
44 44
45 // Called when enable debugging screen is requested. 45 // Called when enable debugging screen is requested.
46 virtual void OnEnableDebuggingScreenRequested() = 0; 46 virtual void OnEnableDebuggingScreenRequested() = 0;
47 }; 47 };
48 48
49 class Observer { 49 class Observer {
50 public: 50 public:
51 virtual ~Observer() {} 51 virtual ~Observer() {}
52 52
53 // Called when language list is reloaded. 53 // Called when language list is reloaded.
54 virtual void OnLanguageListReloaded() = 0; 54 virtual void OnLanguageListReloaded() = 0;
55 }; 55 };
56 56
57 NetworkScreen(BaseScreenDelegate* base_screen_delegate, 57 NetworkScreen(BaseScreenDelegate* base_screen_delegate,
58 Delegate* delegate, 58 Delegate* delegate,
59 NetworkView* view); 59 NetworkView* view);
60 ~NetworkScreen() override; 60 ~NetworkScreen() override;
61 61
62 static NetworkScreen* Get(ScreenManager* manager); 62 static NetworkScreen* Get(ScreenManager* manager);
63 63
64 // NetworkModel implementation: 64 // Called when |view| has been destroyed. If this instance is destroyed before
65 void Show() override; 65 // the |view| it should call view->Unbind().
66 void Hide() override; 66 void OnViewDestroyed(NetworkView* view);
67 void OnViewDestroyed(NetworkView* view) override;
68 void OnUserAction(const std::string& action_id) override;
69 void OnContextKeyUpdated(const ::login::ScreenContext::KeyType& key) override;
70 std::string GetLanguageListLocale() const override;
71 const base::ListValue* GetLanguageList() const override;
72 void UpdateLanguageList() override;
73 67
74 // NetworkStateHandlerObserver implementation: 68 std::string language_list_locale() const { return language_list_locale_; }
achuithb 2017/01/27 01:20:54 const std::string&
jdufault 2017/01/27 23:57:43 Done.
75 void NetworkConnectionStateChanged(const NetworkState* network) override; 69 const base::ListValue* language_list() const { return language_list_.get(); }
76 void DefaultNetworkChanged(const NetworkState* network) override;
77 70
78 // InputMethodManager::Observer implementation: 71 void UpdateLanguageList();
79 void InputMethodChanged(input_method::InputMethodManager* manager,
80 Profile* profile,
81 bool show_message) override;
82 72
83 // Set locale and input method. If |locale| is empty or doesn't change, set 73 // Set locale and input method. If |locale| is empty or doesn't change, set
84 // the |input_method| directly. If |input_method| is empty or ineligible, we 74 // the |input_method| directly. If |input_method| is empty or ineligible, we
85 // don't change the current |input_method|. 75 // don't change the current |input_method|.
86 void SetApplicationLocaleAndInputMethod(const std::string& locale, 76 void SetApplicationLocaleAndInputMethod(const std::string& locale,
87 const std::string& input_method); 77 const std::string& input_method);
88 std::string GetApplicationLocale(); 78 std::string GetApplicationLocale();
89 std::string GetInputMethod() const; 79 std::string GetInputMethod() const;
90 80
91 void SetTimezone(const std::string& timezone_id); 81 void SetTimezone(const std::string& timezone_id);
92 std::string GetTimezone() const; 82 std::string GetTimezone() const;
93 83
94 // Currently We can only get unsecured Wifi network configuration from shark 84 // Currently We can only get unsecured Wifi network configuration from shark
95 // that can be applied to remora. Returns the network ONC configuration. 85 // that can be applied to remora. Returns the network ONC configuration.
96 void GetConnectedWifiNetwork(std::string* out_onc_spec); 86 void GetConnectedWifiNetwork(std::string* out_onc_spec);
97 void CreateAndConnectNetworkFromOnc(const std::string& onc_spec, 87 void CreateAndConnectNetworkFromOnc(const std::string& onc_spec,
98 const base::Closure& success_callback, 88 const base::Closure& success_callback,
99 const base::Closure& failed_callback); 89 const base::Closure& failed_callback);
100 90
101 void AddObserver(Observer* observer); 91 void AddObserver(Observer* observer);
102 void RemoveObserver(Observer* observer); 92 void RemoveObserver(Observer* observer);
103 93
104 private: 94 private:
105 friend class NetworkScreenTest; 95 friend class NetworkScreenTest;
106 FRIEND_TEST_ALL_PREFIXES(NetworkScreenTest, Timeout); 96 FRIEND_TEST_ALL_PREFIXES(NetworkScreenTest, Timeout);
107 FRIEND_TEST_ALL_PREFIXES(NetworkScreenTest, CanConnect); 97 FRIEND_TEST_ALL_PREFIXES(NetworkScreenTest, CanConnect);
108 FRIEND_TEST_ALL_PREFIXES(HandsOffNetworkScreenTest, RequiresNoInput); 98 FRIEND_TEST_ALL_PREFIXES(HandsOffNetworkScreenTest, RequiresNoInput);
109 99
100 // BaseScreen implementation:
101 void Show() override;
102 void Hide() override;
103 void OnUserAction(const std::string& action_id) override;
104 void OnContextKeyUpdated(const ::login::ScreenContext::KeyType& key) override;
105
106 // NetworkStateHandlerObserver implementation:
107 void NetworkConnectionStateChanged(const NetworkState* network) override;
108 void DefaultNetworkChanged(const NetworkState* network) override;
109
110 // InputMethodManager::Observer implementation:
111 void InputMethodChanged(input_method::InputMethodManager* manager,
112 Profile* profile,
113 bool show_message) override;
114
110 void SetApplicationLocale(const std::string& locale); 115 void SetApplicationLocale(const std::string& locale);
111 void SetInputMethod(const std::string& input_method); 116 void SetInputMethod(const std::string& input_method);
112 117
113 // Subscribe to timezone changes. 118 // Subscribe to timezone changes.
114 void InitializeTimezoneObserver(); 119 void InitializeTimezoneObserver();
115 120
116 // Subscribes NetworkScreen to the network change notification, 121 // Subscribes NetworkScreen to the network change notification,
117 // forces refresh of current network state. 122 // forces refresh of current network state.
118 void Refresh(); 123 void Refresh();
119 124
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // Callback for chromeos::ResolveUILanguageList() (from l10n_util). 164 // Callback for chromeos::ResolveUILanguageList() (from l10n_util).
160 void OnLanguageListResolved( 165 void OnLanguageListResolved(
161 std::unique_ptr<base::ListValue> new_language_list, 166 std::unique_ptr<base::ListValue> new_language_list,
162 const std::string& new_language_list_locale, 167 const std::string& new_language_list_locale,
163 const std::string& new_selected_language); 168 const std::string& new_selected_language);
164 169
165 // Callback when the system timezone settings is changed. 170 // Callback when the system timezone settings is changed.
166 void OnSystemTimezoneChanged(); 171 void OnSystemTimezoneChanged();
167 172
168 // True if subscribed to network change notification. 173 // True if subscribed to network change notification.
169 bool is_network_subscribed_; 174 bool is_network_subscribed_ = false;
170 175
171 // ID of the the network that we are waiting for. 176 // ID of the the network that we are waiting for.
172 base::string16 network_id_; 177 base::string16 network_id_;
173 178
174 // True if user pressed continue button so we should proceed with OOBE 179 // True if user pressed continue button so we should proceed with OOBE
175 // as soon as we are connected. 180 // as soon as we are connected.
176 bool continue_pressed_; 181 bool continue_pressed_ = false;
177 182
178 // Timer for connection timeout. 183 // Timer for connection timeout.
179 base::OneShotTimer connection_timer_; 184 base::OneShotTimer connection_timer_;
180 185
181 std::unique_ptr<CrosSettings::ObserverSubscription> timezone_subscription_; 186 std::unique_ptr<CrosSettings::ObserverSubscription> timezone_subscription_;
182 187
183 NetworkView* view_; 188 NetworkView* view_ = nullptr;
184 Delegate* delegate_; 189 Delegate* delegate_ = nullptr;
185 std::unique_ptr<login::NetworkStateHelper> network_state_helper_; 190 std::unique_ptr<login::NetworkStateHelper> network_state_helper_;
186 191
187 std::string input_method_; 192 std::string input_method_;
188 std::string timezone_; 193 std::string timezone_;
189 194
190 // Creation of language list happens on Blocking Pool, so we cache 195 // Creation of language list happens on Blocking Pool, so we cache
191 // resolved data. 196 // resolved data.
192 std::string language_list_locale_; 197 std::string language_list_locale_;
193 std::unique_ptr<base::ListValue> language_list_; 198 std::unique_ptr<base::ListValue> language_list_;
194 199
195 // The exact language code selected by user in the menu. 200 // The exact language code selected by user in the menu.
196 std::string selected_language_code_; 201 std::string selected_language_code_;
197 202
198 base::ObserverList<Observer> observers_; 203 base::ObserverList<Observer> observers_;
199 204
200 base::WeakPtrFactory<NetworkScreen> weak_factory_; 205 base::WeakPtrFactory<NetworkScreen> weak_factory_;
201 206
202 DISALLOW_COPY_AND_ASSIGN(NetworkScreen); 207 DISALLOW_COPY_AND_ASSIGN(NetworkScreen);
203 }; 208 };
204 209
205 } // namespace chromeos 210 } // namespace chromeos
206 211
207 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_NETWORK_SCREEN_H_ 212 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_NETWORK_SCREEN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698