| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/extensions/networking_private_api.h" | 5 #include "chrome/browser/chromeos/extensions/networking_private_api.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/command_line.h" |
| 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/browser_process_platform_part_chromeos.h" |
| 13 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 10 #include "chrome/browser/extensions/extension_function_registry.h" | 14 #include "chrome/browser/extensions/extension_function_registry.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/common/extensions/api/networking_private.h" | 16 #include "chrome/common/extensions/api/networking_private.h" |
| 13 #include "chromeos/dbus/dbus_thread_manager.h" | 17 #include "chromeos/dbus/dbus_thread_manager.h" |
| 14 #include "chromeos/dbus/shill_manager_client.h" | 18 #include "chromeos/dbus/shill_manager_client.h" |
| 15 #include "chromeos/network/managed_network_configuration_handler.h" | 19 #include "chromeos/network/managed_network_configuration_handler.h" |
| 16 #include "chromeos/network/network_state.h" | 20 #include "chromeos/network/network_state.h" |
| 17 #include "chromeos/network/network_state_handler.h" | 21 #include "chromeos/network/network_state_handler.h" |
| 18 #include "chromeos/network/onc/onc_constants.h" | 22 #include "chromeos/network/onc/onc_constants.h" |
| 19 #include "chromeos/network/onc/onc_signature.h" | 23 #include "chromeos/network/onc/onc_signature.h" |
| 20 #include "chromeos/network/onc/onc_translator.h" | 24 #include "chromeos/network/onc/onc_translator.h" |
| 21 | 25 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 98 |
| 95 NetworkingPrivateGetManagedPropertiesFunction:: | 99 NetworkingPrivateGetManagedPropertiesFunction:: |
| 96 ~NetworkingPrivateGetManagedPropertiesFunction() { | 100 ~NetworkingPrivateGetManagedPropertiesFunction() { |
| 97 } | 101 } |
| 98 | 102 |
| 99 bool NetworkingPrivateGetManagedPropertiesFunction::RunImpl() { | 103 bool NetworkingPrivateGetManagedPropertiesFunction::RunImpl() { |
| 100 scoped_ptr<api::GetManagedProperties::Params> params = | 104 scoped_ptr<api::GetManagedProperties::Params> params = |
| 101 api::GetManagedProperties::Params::Create(*args_); | 105 api::GetManagedProperties::Params::Create(*args_); |
| 102 EXTENSION_FUNCTION_VALIDATE(params); | 106 EXTENSION_FUNCTION_VALIDATE(params); |
| 103 | 107 |
| 104 // The profile of the requesting browser. | 108 // User ID hash presence is only enforced when multi-profiles are turned on. |
| 105 Profile* requesting_profile = profile(); | 109 std::string user_id_hash; |
| 106 // TODO(pneubeck): Use ProfileHelper to obtain the userhash, once it provides | 110 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles)) { |
| 107 // that functionality. crbug/238623. | 111 user_id_hash = g_browser_process->platform_part()-> |
| 108 std::string userhash = requesting_profile->GetPath().BaseName().value(); | 112 profile_helper()->GetUserIdHashFromProfile(profile()); |
| 113 } else { |
| 114 user_id_hash = g_browser_process->platform_part()-> |
| 115 profile_helper()->active_user_id_hash(); |
| 116 } |
| 109 | 117 |
| 110 ManagedNetworkConfigurationHandler::Get()->GetManagedProperties( | 118 ManagedNetworkConfigurationHandler::Get()->GetManagedProperties( |
| 111 userhash, | 119 user_id_hash, |
| 112 params->network_guid, // service path | 120 params->network_guid, // service path |
| 113 base::Bind(&NetworkingPrivateGetManagedPropertiesFunction::Success, | 121 base::Bind(&NetworkingPrivateGetManagedPropertiesFunction::Success, |
| 114 this), | 122 this), |
| 115 base::Bind(&NetworkingPrivateGetManagedPropertiesFunction::Failure, | 123 base::Bind(&NetworkingPrivateGetManagedPropertiesFunction::Failure, |
| 116 this)); | 124 this)); |
| 117 return true; | 125 return true; |
| 118 } | 126 } |
| 119 | 127 |
| 120 void NetworkingPrivateGetManagedPropertiesFunction::Success( | 128 void NetworkingPrivateGetManagedPropertiesFunction::Success( |
| 121 const std::string& service_path, | 129 const std::string& service_path, |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 const std::string& result) { | 445 const std::string& result) { |
| 438 results_ = api::VerifyAndEncryptData::Results::Create(result); | 446 results_ = api::VerifyAndEncryptData::Results::Create(result); |
| 439 SendResponse(true); | 447 SendResponse(true); |
| 440 } | 448 } |
| 441 | 449 |
| 442 void NetworkingPrivateVerifyAndEncryptDataFunction::ErrorCallback( | 450 void NetworkingPrivateVerifyAndEncryptDataFunction::ErrorCallback( |
| 443 const std::string& error_name, const std::string& error) { | 451 const std::string& error_name, const std::string& error) { |
| 444 error_ = error_name; | 452 error_ = error_name; |
| 445 SendResponse(false); | 453 SendResponse(false); |
| 446 } | 454 } |
| OLD | NEW |