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

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

Issue 1428353002: Network Setup from Shark to Remora. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 #include "chrome/browser/chromeos/login/screens/network_screen.h" 5 #include "chrome/browser/chromeos/login/screens/network_screen.h"
6 6
7 #include "base/json/json_writer.h"
7 #include "base/location.h" 8 #include "base/location.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
9 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
10 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/chromeos/base/locale_util.h" 14 #include "chrome/browser/chromeos/base/locale_util.h"
14 #include "chrome/browser/chromeos/customization/customization_document.h" 15 #include "chrome/browser/chromeos/customization/customization_document.h"
15 #include "chrome/browser/chromeos/login/help_app_launcher.h" 16 #include "chrome/browser/chromeos/login/help_app_launcher.h"
16 #include "chrome/browser/chromeos/login/helper.h" 17 #include "chrome/browser/chromeos/login/helper.h"
17 #include "chrome/browser/chromeos/login/screen_manager.h" 18 #include "chrome/browser/chromeos/login/screen_manager.h"
18 #include "chrome/browser/chromeos/login/screens/base_screen_delegate.h" 19 #include "chrome/browser/chromeos/login/screens/base_screen_delegate.h"
19 #include "chrome/browser/chromeos/login/screens/network_view.h" 20 #include "chrome/browser/chromeos/login/screens/network_view.h"
20 #include "chrome/browser/chromeos/login/ui/input_events_blocker.h" 21 #include "chrome/browser/chromeos/login/ui/input_events_blocker.h"
21 #include "chrome/browser/chromeos/login/wizard_controller.h" 22 #include "chrome/browser/chromeos/login/wizard_controller.h"
22 #include "chrome/browser/profiles/profile_manager.h" 23 #include "chrome/browser/profiles/profile_manager.h"
23 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" 24 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h"
24 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
25 #include "chrome/grit/chromium_strings.h" 26 #include "chrome/grit/chromium_strings.h"
26 #include "chrome/grit/generated_resources.h" 27 #include "chrome/grit/generated_resources.h"
27 #include "chromeos/network/network_handler.h" 28 #include "chromeos/network/network_handler.h"
29 #include "chromeos/network/network_state.h"
28 #include "chromeos/network/network_state_handler.h" 30 #include "chromeos/network/network_state_handler.h"
31 #include "chromeos/network/network_util.h"
29 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
30 #include "ui/base/l10n/l10n_util.h" 33 #include "ui/base/l10n/l10n_util.h"
31 34
32 namespace { 35 namespace {
33 36
34 // Time in seconds for connection timeout. 37 // Time in seconds for connection timeout.
35 const int kConnectionTimeoutSec = 40; 38 const int kConnectionTimeoutSec = 40;
36 39
37 } // namespace 40 } // namespace
38 41
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 if (current_timezone_id == timezone_id) 225 if (current_timezone_id == timezone_id)
223 return; 226 return;
224 timezone_ = timezone_id; 227 timezone_ = timezone_id;
225 CrosSettings::Get()->SetString(kSystemTimezone, timezone_id); 228 CrosSettings::Get()->SetString(kSystemTimezone, timezone_id);
226 } 229 }
227 230
228 std::string NetworkScreen::GetTimezone() const { 231 std::string NetworkScreen::GetTimezone() const {
229 return timezone_; 232 return timezone_;
230 } 233 }
231 234
235 std::string NetworkScreen::GetConnectedWifiNetwork() {
236 // Currently We can only transfer unsecured WiFi configuration from Shark to
237 // Remora. There is no way to get password for a secured Wifi network in Cros
238 // for security reasons.
239 const NetworkState* network_state =
240 NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType(
241 NetworkTypePattern::WiFi());
242
243 if (!network_state)
244 return std::string();
245
246 scoped_ptr<base::DictionaryValue> current_onc =
247 network_util::TranslateNetworkStateToONC(network_state);
248 std::string security;
249 current_onc->GetString(
250 onc::network_config::WifiProperty(onc::wifi::kSecurity), &security);
251 if (security.compare(onc::wifi::kSecurityNone) != 0) {
achuithb 2015/11/05 23:26:12 don't need {} Why not if (security != onc::wifi:
stevenjb 2015/11/05 23:48:25 +1
xdai1 2015/11/06 23:23:02 Done.
252 return std::string();
stevenjb 2015/11/05 23:48:25 Eventually, we could support WEP/WPA/PSK networks
xdai1 2015/11/06 23:23:02 The Hotrod shark/remora (a.k.a, controller/host) p
253 }
254
255 const std::vector<uint8_t> raw_ssid = network_state->raw_ssid();
achuithb 2015/11/05 23:26:12 Why not GetHexSsid? https://code.google.com/p/chro
stevenjb 2015/11/05 23:48:25 +1
xdai1 2015/11/06 23:23:02 Done. But it seems more complicated than just usin
stevenjb 2015/11/06 23:32:12 Sorry, the suggestion was to use network_state->Ge
256 const std::string ssid(raw_ssid.begin(), raw_ssid.end());
257
258 scoped_ptr<base::DictionaryValue> coped_onc(new base::DictionaryValue());
stevenjb 2015/11/05 23:48:25 s/coped/copied/
xdai1 2015/11/06 23:23:02 Done.
259 coped_onc->Set(onc::toplevel_config::kType,
260 new base::StringValue(onc::network_type::kWiFi));
261 coped_onc->Set(onc::network_config::WifiProperty(onc::wifi::kSSID),
262 new base::StringValue(ssid));
263 coped_onc->Set(onc::network_config::WifiProperty(onc::wifi::kSecurity),
264 new base::StringValue(security));
265
266 std::string onc_spec;
267 base::JSONWriter::Write(*coped_onc.get(), &onc_spec);
268 return onc_spec;
269 }
270
232 void NetworkScreen::CreateNetworkFromOnc(const std::string& onc_spec) { 271 void NetworkScreen::CreateNetworkFromOnc(const std::string& onc_spec) {
233 network_state_helper_->CreateNetworkFromOnc(onc_spec); 272 network_state_helper_->CreateNetworkFromOnc(onc_spec);
234 } 273 }
235 274
236 void NetworkScreen::AddObserver(Observer* observer) { 275 void NetworkScreen::AddObserver(Observer* observer) {
237 if (observer) 276 if (observer)
238 observers_.AddObserver(observer); 277 observers_.AddObserver(observer);
239 } 278 }
240 279
241 void NetworkScreen::RemoveObserver(Observer* observer) { 280 void NetworkScreen::RemoveObserver(Observer* observer) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 FOR_EACH_OBSERVER(Observer, observers_, OnLanguageListReloaded()); 431 FOR_EACH_OBSERVER(Observer, observers_, OnLanguageListReloaded());
393 } 432 }
394 433
395 void NetworkScreen::OnSystemTimezoneChanged() { 434 void NetworkScreen::OnSystemTimezoneChanged() {
396 std::string current_timezone_id; 435 std::string current_timezone_id;
397 CrosSettings::Get()->GetString(kSystemTimezone, &current_timezone_id); 436 CrosSettings::Get()->GetString(kSystemTimezone, &current_timezone_id);
398 GetContextEditor().SetString(kContextKeyTimezone, current_timezone_id); 437 GetContextEditor().SetString(kContextKeyTimezone, current_timezone_id);
399 } 438 }
400 439
401 } // namespace chromeos 440 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698