Chromium Code Reviews| Index: chrome/browser/chromeos/login/screens/network_screen.cc |
| diff --git a/chrome/browser/chromeos/login/screens/network_screen.cc b/chrome/browser/chromeos/login/screens/network_screen.cc |
| index e6c7ca6e5481aa091cdc6590ec1caaa9cc021474..c4b0f717d2fa3f54ae7acd8fcd107e06ffaf6e4d 100644 |
| --- a/chrome/browser/chromeos/login/screens/network_screen.cc |
| +++ b/chrome/browser/chromeos/login/screens/network_screen.cc |
| @@ -4,6 +4,7 @@ |
| #include "chrome/browser/chromeos/login/screens/network_screen.h" |
| +#include "base/json/json_writer.h" |
| #include "base/location.h" |
| #include "base/logging.h" |
| #include "base/prefs/pref_service.h" |
| @@ -25,7 +26,9 @@ |
| #include "chrome/grit/chromium_strings.h" |
| #include "chrome/grit/generated_resources.h" |
| #include "chromeos/network/network_handler.h" |
| +#include "chromeos/network/network_state.h" |
| #include "chromeos/network/network_state_handler.h" |
| +#include "chromeos/network/network_util.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "ui/base/l10n/l10n_util.h" |
| @@ -229,6 +232,42 @@ std::string NetworkScreen::GetTimezone() const { |
| return timezone_; |
| } |
| +std::string NetworkScreen::GetConnectedWifiNetwork() { |
| + // Currently We can only transfer unsecured WiFi configuration from Shark to |
| + // Remora. There is no way to get password for a secured Wifi network in Cros |
| + // for security reasons. |
| + const NetworkState* network_state = |
| + NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType( |
| + NetworkTypePattern::WiFi()); |
| + |
| + if (!network_state) |
| + return std::string(); |
| + |
| + scoped_ptr<base::DictionaryValue> current_onc = |
| + network_util::TranslateNetworkStateToONC(network_state); |
| + std::string security; |
| + current_onc->GetString( |
| + onc::network_config::WifiProperty(onc::wifi::kSecurity), &security); |
| + 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.
|
| + 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
|
| + } |
| + |
| + 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
|
| + const std::string ssid(raw_ssid.begin(), raw_ssid.end()); |
| + |
| + 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.
|
| + coped_onc->Set(onc::toplevel_config::kType, |
| + new base::StringValue(onc::network_type::kWiFi)); |
| + coped_onc->Set(onc::network_config::WifiProperty(onc::wifi::kSSID), |
| + new base::StringValue(ssid)); |
| + coped_onc->Set(onc::network_config::WifiProperty(onc::wifi::kSecurity), |
| + new base::StringValue(security)); |
| + |
| + std::string onc_spec; |
| + base::JSONWriter::Write(*coped_onc.get(), &onc_spec); |
| + return onc_spec; |
| +} |
| + |
| void NetworkScreen::CreateNetworkFromOnc(const std::string& onc_spec) { |
| network_state_helper_->CreateNetworkFromOnc(onc_spec); |
| } |