OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/wifi_sync/wifi_config_delegate_chromeos.h" | 5 #include "components/sync_wifi/wifi_config_delegate_chromeos.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chromeos/network/managed_network_configuration_handler.h" | 12 #include "chromeos/network/managed_network_configuration_handler.h" |
13 #include "components/wifi_sync/wifi_credential.h" | 13 #include "components/sync_wifi/wifi_credential.h" |
14 | 14 |
15 namespace wifi_sync { | 15 namespace sync_wifi { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 void OnCreateConfigurationFailed( | 19 void OnCreateConfigurationFailed( |
20 const WifiCredential& wifi_credential, | 20 const WifiCredential& wifi_credential, |
21 const std::string& config_handler_error_message, | 21 const std::string& config_handler_error_message, |
22 std::unique_ptr<base::DictionaryValue> error_data) { | 22 std::unique_ptr<base::DictionaryValue> error_data) { |
23 LOG(ERROR) << "Create configuration failed"; | 23 LOG(ERROR) << "Create configuration failed"; |
24 // TODO(quiche): check if there is a matching network already. If | 24 // TODO(quiche): check if there is a matching network already. If |
25 // so, try to configure it with |wifi_credential|. | 25 // so, try to configure it with |wifi_credential|. |
26 } | 26 } |
27 | 27 |
28 } // namespace | 28 } // namespace |
29 | 29 |
30 WifiConfigDelegateChromeOs::WifiConfigDelegateChromeOs( | 30 WifiConfigDelegateChromeOs::WifiConfigDelegateChromeOs( |
31 const std::string& user_hash, | 31 const std::string& user_hash, |
32 chromeos::ManagedNetworkConfigurationHandler* managed_net_config_handler) | 32 chromeos::ManagedNetworkConfigurationHandler* managed_net_config_handler) |
33 : user_hash_(user_hash), | 33 : user_hash_(user_hash), |
34 managed_network_configuration_handler_(managed_net_config_handler) { | 34 managed_network_configuration_handler_(managed_net_config_handler) { |
35 DCHECK(!user_hash_.empty()); | 35 DCHECK(!user_hash_.empty()); |
36 DCHECK(managed_network_configuration_handler_); | 36 DCHECK(managed_network_configuration_handler_); |
37 } | 37 } |
38 | 38 |
39 WifiConfigDelegateChromeOs::~WifiConfigDelegateChromeOs() { | 39 WifiConfigDelegateChromeOs::~WifiConfigDelegateChromeOs() {} |
40 } | |
41 | 40 |
42 void WifiConfigDelegateChromeOs::AddToLocalNetworks( | 41 void WifiConfigDelegateChromeOs::AddToLocalNetworks( |
43 const WifiCredential& network_credential) { | 42 const WifiCredential& network_credential) { |
44 std::unique_ptr<base::DictionaryValue> onc_properties( | 43 std::unique_ptr<base::DictionaryValue> onc_properties( |
45 network_credential.ToOncProperties()); | 44 network_credential.ToOncProperties()); |
46 // TODO(quiche): Replace with DCHECK, once ONC supports non-UTF-8 SSIDs. | 45 // TODO(quiche): Replace with DCHECK, once ONC supports non-UTF-8 SSIDs. |
47 // crbug.com/432546 | 46 // crbug.com/432546 |
48 if (!onc_properties) { | 47 if (!onc_properties) { |
49 LOG(ERROR) << "Failed to generate ONC properties for " | 48 LOG(ERROR) << "Failed to generate ONC properties for " |
50 << network_credential.ToString(); | 49 << network_credential.ToString(); |
51 return; | 50 return; |
52 } | 51 } |
53 | 52 |
54 managed_network_configuration_handler_->CreateConfiguration( | 53 managed_network_configuration_handler_->CreateConfiguration( |
55 user_hash_, *onc_properties, | 54 user_hash_, *onc_properties, |
56 chromeos::network_handler::ServiceResultCallback(), | 55 chromeos::network_handler::ServiceResultCallback(), |
57 base::Bind(OnCreateConfigurationFailed, network_credential)); | 56 base::Bind(OnCreateConfigurationFailed, network_credential)); |
58 } | 57 } |
59 | 58 |
60 } // namespace wifi_sync | 59 } // namespace sync_wifi |
OLD | NEW |