| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/networking_private/networking_private_chromeos.
h" | 5 #include "extensions/browser/api/networking_private/networking_private_chromeos.
h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "chromeos/dbus/dbus_thread_manager.h" | 10 #include "chromeos/dbus/dbus_thread_manager.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } // namespace | 159 } // namespace |
| 160 | 160 |
| 161 //////////////////////////////////////////////////////////////////////////////// | 161 //////////////////////////////////////////////////////////////////////////////// |
| 162 | 162 |
| 163 namespace extensions { | 163 namespace extensions { |
| 164 | 164 |
| 165 NetworkingPrivateChromeOS::NetworkingPrivateChromeOS( | 165 NetworkingPrivateChromeOS::NetworkingPrivateChromeOS( |
| 166 content::BrowserContext* browser_context, | 166 content::BrowserContext* browser_context, |
| 167 scoped_ptr<VerifyDelegate> verify_delegate) | 167 scoped_ptr<VerifyDelegate> verify_delegate) |
| 168 : NetworkingPrivateDelegate(verify_delegate.Pass()), | 168 : NetworkingPrivateDelegate(verify_delegate.Pass()), |
| 169 browser_context_(browser_context) { | 169 browser_context_(browser_context), |
| 170 } | 170 weak_ptr_factory_(this) {} |
| 171 | 171 |
| 172 NetworkingPrivateChromeOS::~NetworkingPrivateChromeOS() { | 172 NetworkingPrivateChromeOS::~NetworkingPrivateChromeOS() { |
| 173 } | 173 } |
| 174 | 174 |
| 175 void NetworkingPrivateChromeOS::GetProperties( | 175 void NetworkingPrivateChromeOS::GetProperties( |
| 176 const std::string& guid, | 176 const std::string& guid, |
| 177 const DictionaryCallback& success_callback, | 177 const DictionaryCallback& success_callback, |
| 178 const FailureCallback& failure_callback) { | 178 const FailureCallback& failure_callback) { |
| 179 std::string service_path, error; | 179 std::string service_path, error; |
| 180 if (!GetServicePathFromGuid(guid, &service_path, &error)) { | 180 if (!GetServicePathFromGuid(guid, &service_path, &error)) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 const FailureCallback& failure_callback) { | 303 const FailureCallback& failure_callback) { |
| 304 std::string service_path, error; | 304 std::string service_path, error; |
| 305 if (!GetServicePathFromGuid(guid, &service_path, &error)) { | 305 if (!GetServicePathFromGuid(guid, &service_path, &error)) { |
| 306 failure_callback.Run(error); | 306 failure_callback.Run(error); |
| 307 return; | 307 return; |
| 308 } | 308 } |
| 309 | 309 |
| 310 const bool check_error_state = false; | 310 const bool check_error_state = false; |
| 311 NetworkHandler::Get()->network_connection_handler()->ConnectToNetwork( | 311 NetworkHandler::Get()->network_connection_handler()->ConnectToNetwork( |
| 312 service_path, success_callback, | 312 service_path, success_callback, |
| 313 base::Bind(&NetworkHandlerFailureCallback, failure_callback), | 313 base::Bind(&NetworkingPrivateChromeOS::ConnectFailureCallback, |
| 314 weak_ptr_factory_.GetWeakPtr(), guid, success_callback, |
| 315 failure_callback), |
| 314 check_error_state); | 316 check_error_state); |
| 315 } | 317 } |
| 316 | 318 |
| 319 void NetworkingPrivateChromeOS::ConnectFailureCallback( |
| 320 const std::string& guid, |
| 321 const VoidCallback& success_callback, |
| 322 const FailureCallback& failure_callback, |
| 323 const std::string& error_name, |
| 324 scoped_ptr<base::DictionaryValue> error_data) { |
| 325 // TODO(stevenjb): Temporary workaround to show the configuration UI. |
| 326 // Eventually the caller (e.g. Settings) should handle any failures and |
| 327 // show its own configuration UI. crbug.com/380937. |
| 328 if (ui_delegate()->HandleConnectFailed(guid, error_name)) { |
| 329 success_callback.Run(); |
| 330 return; |
| 331 } |
| 332 failure_callback.Run(error_name); |
| 333 } |
| 334 |
| 317 void NetworkingPrivateChromeOS::StartDisconnect( | 335 void NetworkingPrivateChromeOS::StartDisconnect( |
| 318 const std::string& guid, | 336 const std::string& guid, |
| 319 const VoidCallback& success_callback, | 337 const VoidCallback& success_callback, |
| 320 const FailureCallback& failure_callback) { | 338 const FailureCallback& failure_callback) { |
| 321 std::string service_path, error; | 339 std::string service_path, error; |
| 322 if (!GetServicePathFromGuid(guid, &service_path, &error)) { | 340 if (!GetServicePathFromGuid(guid, &service_path, &error)) { |
| 323 failure_callback.Run(error); | 341 failure_callback.Run(error); |
| 324 return; | 342 return; |
| 325 } | 343 } |
| 326 | 344 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 | 560 |
| 543 return true; | 561 return true; |
| 544 } | 562 } |
| 545 | 563 |
| 546 bool NetworkingPrivateChromeOS::RequestScan() { | 564 bool NetworkingPrivateChromeOS::RequestScan() { |
| 547 GetStateHandler()->RequestScan(); | 565 GetStateHandler()->RequestScan(); |
| 548 return true; | 566 return true; |
| 549 } | 567 } |
| 550 | 568 |
| 551 } // namespace extensions | 569 } // namespace extensions |
| OLD | NEW |