Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/helper.h" | 5 #include "chrome/browser/chromeos/login/helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/chromeos/login/startup_utils.h" | 11 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 12 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 12 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 13 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" | 13 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
| 14 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 14 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 15 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
| 16 #include "chromeos/chromeos_switches.h" | 16 #include "chromeos/chromeos_switches.h" |
| 17 #include "chromeos/network/managed_network_configuration_handler.h" | 17 #include "chromeos/network/managed_network_configuration_handler.h" |
| 18 #include "chromeos/network/network_connection_handler.h" | |
| 18 #include "chromeos/network/network_handler.h" | 19 #include "chromeos/network/network_handler.h" |
| 19 #include "chromeos/network/network_state.h" | 20 #include "chromeos/network/network_state.h" |
| 20 #include "chromeos/network/network_state_handler.h" | 21 #include "chromeos/network/network_state_handler.h" |
| 21 #include "components/guest_view/browser/guest_view_manager.h" | 22 #include "components/guest_view/browser/guest_view_manager.h" |
| 22 #include "content/public/browser/storage_partition.h" | 23 #include "content/public/browser/storage_partition.h" |
| 23 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 24 #include "extensions/browser/guest_view/web_view/web_view_guest.h" | 25 #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
| 25 #include "third_party/cros_system_api/dbus/service_constants.h" | 26 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 27 #include "ui/gfx/image/image_skia.h" | 28 #include "ui/gfx/image/image_skia.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 | 143 |
| 143 NetworkHandler::Get()->managed_network_configuration_handler()-> | 144 NetworkHandler::Get()->managed_network_configuration_handler()-> |
| 144 CreateConfiguration( | 145 CreateConfiguration( |
| 145 "", *toplevel_onc, | 146 "", *toplevel_onc, |
| 146 base::Bind(&NetworkStateHelper::OnCreateConfiguration, | 147 base::Bind(&NetworkStateHelper::OnCreateConfiguration, |
| 147 base::Unretained(this)), | 148 base::Unretained(this)), |
| 148 base::Bind(&NetworkStateHelper::OnCreateConfigurationFailed, | 149 base::Bind(&NetworkStateHelper::OnCreateConfigurationFailed, |
| 149 base::Unretained(this))); | 150 base::Unretained(this))); |
| 150 } | 151 } |
| 151 | 152 |
| 152 void NetworkStateHelper::OnCreateConfiguration( | |
| 153 const std::string& service_path) const { | |
| 154 // Do Nothing. | |
| 155 } | |
| 156 | |
| 157 void NetworkStateHelper::OnCreateConfigurationFailed( | |
| 158 const std::string& error_name, | |
| 159 scoped_ptr<base::DictionaryValue> error_data) const { | |
| 160 LOG(ERROR) << "Failed to create network configuration: " << error_name; | |
| 161 } | |
| 162 | |
| 163 bool NetworkStateHelper::IsConnected() const { | 153 bool NetworkStateHelper::IsConnected() const { |
| 164 chromeos::NetworkStateHandler* nsh = | 154 chromeos::NetworkStateHandler* nsh = |
| 165 chromeos::NetworkHandler::Get()->network_state_handler(); | 155 chromeos::NetworkHandler::Get()->network_state_handler(); |
| 166 return nsh->ConnectedNetworkByType(chromeos::NetworkTypePattern::Default()) != | 156 return nsh->ConnectedNetworkByType(chromeos::NetworkTypePattern::Default()) != |
| 167 nullptr; | 157 nullptr; |
| 168 } | 158 } |
| 169 | 159 |
| 170 bool NetworkStateHelper::IsConnecting() const { | 160 bool NetworkStateHelper::IsConnecting() const { |
| 171 chromeos::NetworkStateHandler* nsh = | 161 chromeos::NetworkStateHandler* nsh = |
| 172 chromeos::NetworkHandler::Get()->network_state_handler(); | 162 chromeos::NetworkHandler::Get()->network_state_handler(); |
| 173 return nsh->ConnectingNetworkByType( | 163 return nsh->ConnectingNetworkByType( |
| 174 chromeos::NetworkTypePattern::Default()) != nullptr; | 164 chromeos::NetworkTypePattern::Default()) != nullptr; |
| 175 } | 165 } |
| 176 | 166 |
| 167 void NetworkStateHelper::OnCreateConfiguration( | |
| 168 const std::string& service_path) const { | |
| 169 // Connect to the network. | |
| 170 NetworkHandler::Get()->network_connection_handler()->ConnectToNetwork( | |
| 171 service_path, base::Bind(&base::DoNothing), | |
| 172 network_handler::ErrorCallback(), false); | |
| 173 } | |
| 174 | |
| 175 void NetworkStateHelper::OnCreateConfigurationFailed( | |
| 176 const std::string& error_name, | |
| 177 scoped_ptr<base::DictionaryValue> error_data) const { | |
| 178 LOG(ERROR) << "Failed to create network configuration: " << error_name; | |
|
achuithb
2015/11/05 23:26:12
Should we be showing the network error screen here
xdai1
2015/11/06 23:23:02
Done.
| |
| 179 } | |
| 180 | |
| 177 content::StoragePartition* GetSigninPartition() { | 181 content::StoragePartition* GetSigninPartition() { |
| 178 content::WebContents* embedder = GetLoginWebContents(); | 182 content::WebContents* embedder = GetLoginWebContents(); |
| 179 if (!embedder) | 183 if (!embedder) |
| 180 return nullptr; | 184 return nullptr; |
| 181 | 185 |
| 182 // Note the partition name must match the sign-in webview used. For now, | 186 // Note the partition name must match the sign-in webview used. For now, |
| 183 // this is the default unnamed, shared, in-memory partition. | 187 // this is the default unnamed, shared, in-memory partition. |
| 184 return GetPartition(embedder, std::string()); | 188 return GetPartition(embedder, std::string()); |
| 185 } | 189 } |
| 186 | 190 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 199 | 203 |
| 200 return signin_partition->GetURLRequestContext(); | 204 return signin_partition->GetURLRequestContext(); |
| 201 } | 205 } |
| 202 | 206 |
| 203 return ProfileHelper::GetSigninProfile()->GetRequestContext(); | 207 return ProfileHelper::GetSigninProfile()->GetRequestContext(); |
| 204 } | 208 } |
| 205 | 209 |
| 206 } // namespace login | 210 } // namespace login |
| 207 | 211 |
| 208 } // namespace chromeos | 212 } // namespace chromeos |
| OLD | NEW |