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

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

Issue 2649873009: cros: Fold NetworkModel into NetworkScreen (Closed)
Patch Set: Address comments Created 3 years, 10 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 const std::string& language_list_locale() const {
75 void NetworkConnectionStateChanged(const NetworkState* network) override; 69 return language_list_locale_;
76 void DefaultNetworkChanged(const NetworkState* network) override; 70 }
71 const base::ListValue* language_list() const { return language_list_.get(); }
77 72
78 // InputMethodManager::Observer implementation: 73 void UpdateLanguageList();
79 void InputMethodChanged(input_method::InputMethodManager* manager,
80 Profile* profile,
81 bool show_message) override;
82 74
83 // Set locale and input method. If |locale| is empty or doesn't change, set 75 // 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 76 // the |input_method| directly. If |input_method| is empty or ineligible, we
85 // don't change the current |input_method|. 77 // don't change the current |input_method|.
86 void SetApplicationLocaleAndInputMethod(const std::string& locale, 78 void SetApplicationLocaleAndInputMethod(const std::string& locale,
87 const std::string& input_method); 79 const std::string& input_method);
88 std::string GetApplicationLocale(); 80 std::string GetApplicationLocale();
89 std::string GetInputMethod() const; 81 std::string GetInputMethod() const;
90 82
91 void SetTimezone(const std::string& timezone_id); 83 void SetTimezone(const std::string& timezone_id);
92 std::string GetTimezone() const; 84 std::string GetTimezone() const;
93 85
94 // Currently We can only get unsecured Wifi network configuration from shark 86 // Currently We can only get unsecured Wifi network configuration from shark
95 // that can be applied to remora. Returns the network ONC configuration. 87 // that can be applied to remora. Returns the network ONC configuration.
96 void GetConnectedWifiNetwork(std::string* out_onc_spec); 88 void GetConnectedWifiNetwork(std::string* out_onc_spec);
97 void CreateAndConnectNetworkFromOnc(const std::string& onc_spec, 89 void CreateAndConnectNetworkFromOnc(const std::string& onc_spec,
98 const base::Closure& success_callback, 90 const base::Closure& success_callback,
99 const base::Closure& failed_callback); 91 const base::Closure& failed_callback);
100 92
101 void AddObserver(Observer* observer); 93 void AddObserver(Observer* observer);
102 void RemoveObserver(Observer* observer); 94 void RemoveObserver(Observer* observer);
103 95
104 private: 96 private:
105 friend class NetworkScreenTest; 97 friend class NetworkScreenTest;
106 FRIEND_TEST_ALL_PREFIXES(NetworkScreenTest, Timeout); 98 FRIEND_TEST_ALL_PREFIXES(NetworkScreenTest, Timeout);
107 FRIEND_TEST_ALL_PREFIXES(NetworkScreenTest, CanConnect); 99 FRIEND_TEST_ALL_PREFIXES(NetworkScreenTest, CanConnect);
108 FRIEND_TEST_ALL_PREFIXES(HandsOffNetworkScreenTest, RequiresNoInput); 100 FRIEND_TEST_ALL_PREFIXES(HandsOffNetworkScreenTest, RequiresNoInput);
109 101
102 // BaseScreen implementation:
103 void Show() override;
104 void Hide() override;
105 void OnUserAction(const std::string& action_id) override;
106 void OnContextKeyUpdated(const ::login::ScreenContext::KeyType& key) override;
107
108 // NetworkStateHandlerObserver implementation:
109 void NetworkConnectionStateChanged(const NetworkState* network) override;
110 void DefaultNetworkChanged(const NetworkState* network) override;
111
112 // InputMethodManager::Observer implementation:
113 void InputMethodChanged(input_method::InputMethodManager* manager,
114 Profile* profile,
115 bool show_message) override;
116
110 void SetApplicationLocale(const std::string& locale); 117 void SetApplicationLocale(const std::string& locale);
111 void SetInputMethod(const std::string& input_method); 118 void SetInputMethod(const std::string& input_method);
112 119
113 // Subscribe to timezone changes. 120 // Subscribe to timezone changes.
114 void InitializeTimezoneObserver(); 121 void InitializeTimezoneObserver();
115 122
116 // Subscribes NetworkScreen to the network change notification, 123 // Subscribes NetworkScreen to the network change notification,
117 // forces refresh of current network state. 124 // forces refresh of current network state.
118 void Refresh(); 125 void Refresh();
119 126
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // Callback for chromeos::ResolveUILanguageList() (from l10n_util). 166 // Callback for chromeos::ResolveUILanguageList() (from l10n_util).
160 void OnLanguageListResolved( 167 void OnLanguageListResolved(
161 std::unique_ptr<base::ListValue> new_language_list, 168 std::unique_ptr<base::ListValue> new_language_list,
162 const std::string& new_language_list_locale, 169 const std::string& new_language_list_locale,
163 const std::string& new_selected_language); 170 const std::string& new_selected_language);
164 171
165 // Callback when the system timezone settings is changed. 172 // Callback when the system timezone settings is changed.
166 void OnSystemTimezoneChanged(); 173 void OnSystemTimezoneChanged();
167 174
168 // True if subscribed to network change notification. 175 // True if subscribed to network change notification.
169 bool is_network_subscribed_; 176 bool is_network_subscribed_ = false;
170 177
171 // ID of the the network that we are waiting for. 178 // ID of the the network that we are waiting for.
172 base::string16 network_id_; 179 base::string16 network_id_;
173 180
174 // True if user pressed continue button so we should proceed with OOBE 181 // True if user pressed continue button so we should proceed with OOBE
175 // as soon as we are connected. 182 // as soon as we are connected.
176 bool continue_pressed_; 183 bool continue_pressed_ = false;
177 184
178 // Timer for connection timeout. 185 // Timer for connection timeout.
179 base::OneShotTimer connection_timer_; 186 base::OneShotTimer connection_timer_;
180 187
181 std::unique_ptr<CrosSettings::ObserverSubscription> timezone_subscription_; 188 std::unique_ptr<CrosSettings::ObserverSubscription> timezone_subscription_;
182 189
183 NetworkView* view_; 190 NetworkView* view_ = nullptr;
184 Delegate* delegate_; 191 Delegate* delegate_ = nullptr;
185 std::unique_ptr<login::NetworkStateHelper> network_state_helper_; 192 std::unique_ptr<login::NetworkStateHelper> network_state_helper_;
186 193
187 std::string input_method_; 194 std::string input_method_;
188 std::string timezone_; 195 std::string timezone_;
189 196
190 // Creation of language list happens on Blocking Pool, so we cache 197 // Creation of language list happens on Blocking Pool, so we cache
191 // resolved data. 198 // resolved data.
192 std::string language_list_locale_; 199 std::string language_list_locale_;
193 std::unique_ptr<base::ListValue> language_list_; 200 std::unique_ptr<base::ListValue> language_list_;
194 201
195 // The exact language code selected by user in the menu. 202 // The exact language code selected by user in the menu.
196 std::string selected_language_code_; 203 std::string selected_language_code_;
197 204
198 base::ObserverList<Observer> observers_; 205 base::ObserverList<Observer> observers_;
199 206
200 base::WeakPtrFactory<NetworkScreen> weak_factory_; 207 base::WeakPtrFactory<NetworkScreen> weak_factory_;
201 208
202 DISALLOW_COPY_AND_ASSIGN(NetworkScreen); 209 DISALLOW_COPY_AND_ASSIGN(NetworkScreen);
203 }; 210 };
204 211
205 } // namespace chromeos 212 } // namespace chromeos
206 213
207 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_NETWORK_SCREEN_H_ 214 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_NETWORK_SCREEN_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/screens/network_model.cc ('k') | chrome/browser/chromeos/login/screens/network_screen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698