| 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 "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 if (!GetServicePathFromGuid(guid, &service_path, &error)) { | 295 if (!GetServicePathFromGuid(guid, &service_path, &error)) { |
| 296 failure_callback.Run(error); | 296 failure_callback.Run(error); |
| 297 return; | 297 return; |
| 298 } | 298 } |
| 299 | 299 |
| 300 GetManagedConfigurationHandler()->SetProperties( | 300 GetManagedConfigurationHandler()->SetProperties( |
| 301 service_path, *properties, success_callback, | 301 service_path, *properties, success_callback, |
| 302 base::Bind(&NetworkHandlerFailureCallback, failure_callback)); | 302 base::Bind(&NetworkHandlerFailureCallback, failure_callback)); |
| 303 } | 303 } |
| 304 | 304 |
| 305 void NetworkHandlerCreateCallback( |
| 306 const NetworkingPrivateDelegate::StringCallback& callback, |
| 307 const std::string& service_path, |
| 308 const std::string& guid) { |
| 309 callback.Run(guid); |
| 310 } |
| 311 |
| 305 void NetworkingPrivateChromeOS::CreateNetwork( | 312 void NetworkingPrivateChromeOS::CreateNetwork( |
| 306 bool shared, | 313 bool shared, |
| 307 scoped_ptr<base::DictionaryValue> properties, | 314 scoped_ptr<base::DictionaryValue> properties, |
| 308 const StringCallback& success_callback, | 315 const StringCallback& success_callback, |
| 309 const FailureCallback& failure_callback) { | 316 const FailureCallback& failure_callback) { |
| 310 std::string user_id_hash, error; | 317 std::string user_id_hash, error; |
| 311 // Do not allow configuring a non-shared network from a non-primary user. | 318 // Do not allow configuring a non-shared network from a non-primary user. |
| 312 if (!shared && | 319 if (!shared && |
| 313 !GetPrimaryUserIdHash(browser_context_, &user_id_hash, &error)) { | 320 !GetPrimaryUserIdHash(browser_context_, &user_id_hash, &error)) { |
| 314 failure_callback.Run(error); | 321 failure_callback.Run(error); |
| 315 return; | 322 return; |
| 316 } | 323 } |
| 317 | 324 |
| 318 GetManagedConfigurationHandler()->CreateConfiguration( | 325 GetManagedConfigurationHandler()->CreateConfiguration( |
| 319 user_id_hash, *properties, success_callback, | 326 user_id_hash, *properties, |
| 327 base::Bind(&NetworkHandlerCreateCallback, success_callback), |
| 320 base::Bind(&NetworkHandlerFailureCallback, failure_callback)); | 328 base::Bind(&NetworkHandlerFailureCallback, failure_callback)); |
| 321 } | 329 } |
| 322 | 330 |
| 323 void NetworkingPrivateChromeOS::ForgetNetwork( | 331 void NetworkingPrivateChromeOS::ForgetNetwork( |
| 324 const std::string& guid, | 332 const std::string& guid, |
| 325 const VoidCallback& success_callback, | 333 const VoidCallback& success_callback, |
| 326 const FailureCallback& failure_callback) { | 334 const FailureCallback& failure_callback) { |
| 327 std::string service_path, error; | 335 std::string service_path, error; |
| 328 if (!GetServicePathFromGuid(guid, &service_path, &error)) { | 336 if (!GetServicePathFromGuid(guid, &service_path, &error)) { |
| 329 failure_callback.Run(error); | 337 failure_callback.Run(error); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 // Eventually the caller (e.g. Settings) should handle any failures and | 665 // Eventually the caller (e.g. Settings) should handle any failures and |
| 658 // show its own configuration UI. crbug.com/380937. | 666 // show its own configuration UI. crbug.com/380937. |
| 659 if (ui_delegate()->HandleConnectFailed(guid, error_name)) { | 667 if (ui_delegate()->HandleConnectFailed(guid, error_name)) { |
| 660 success_callback.Run(); | 668 success_callback.Run(); |
| 661 return; | 669 return; |
| 662 } | 670 } |
| 663 failure_callback.Run(error_name); | 671 failure_callback.Run(error_name); |
| 664 } | 672 } |
| 665 | 673 |
| 666 } // namespace extensions | 674 } // namespace extensions |
| OLD | NEW |