OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/ui/webui/chromeos/network_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/network_ui.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 } | 41 } |
42 | 42 |
43 void SetDeviceProperties(base::DictionaryValue* dictionary) { | 43 void SetDeviceProperties(base::DictionaryValue* dictionary) { |
44 std::string device; | 44 std::string device; |
45 dictionary->GetStringWithoutPathExpansion(shill::kDeviceProperty, &device); | 45 dictionary->GetStringWithoutPathExpansion(shill::kDeviceProperty, &device); |
46 const DeviceState* device_state = | 46 const DeviceState* device_state = |
47 NetworkHandler::Get()->network_state_handler()->GetDeviceState(device); | 47 NetworkHandler::Get()->network_state_handler()->GetDeviceState(device); |
48 if (!device_state) | 48 if (!device_state) |
49 return; | 49 return; |
50 | 50 |
51 scoped_ptr<base::DictionaryValue> device_dictionary( | 51 std::unique_ptr<base::DictionaryValue> device_dictionary( |
52 device_state->properties().DeepCopy()); | 52 device_state->properties().DeepCopy()); |
53 | 53 |
54 if (!device_state->ip_configs().empty()) { | 54 if (!device_state->ip_configs().empty()) { |
55 // Convert IPConfig dictionary to a ListValue. | 55 // Convert IPConfig dictionary to a ListValue. |
56 scoped_ptr<base::ListValue> ip_configs(new base::ListValue); | 56 std::unique_ptr<base::ListValue> ip_configs(new base::ListValue); |
57 for (base::DictionaryValue::Iterator iter(device_state->ip_configs()); | 57 for (base::DictionaryValue::Iterator iter(device_state->ip_configs()); |
58 !iter.IsAtEnd(); iter.Advance()) { | 58 !iter.IsAtEnd(); iter.Advance()) { |
59 ip_configs->Append(iter.value().DeepCopy()); | 59 ip_configs->Append(iter.value().DeepCopy()); |
60 } | 60 } |
61 device_dictionary->SetWithoutPathExpansion(shill::kIPConfigsProperty, | 61 device_dictionary->SetWithoutPathExpansion(shill::kIPConfigsProperty, |
62 ip_configs.release()); | 62 ip_configs.release()); |
63 } | 63 } |
64 if (!device_dictionary->empty()) | 64 if (!device_dictionary->empty()) |
65 dictionary->Set(shill::kDeviceProperty, device_dictionary.release()); | 65 dictionary->Set(shill::kDeviceProperty, device_dictionary.release()); |
66 } | 66 } |
(...skipping 28 matching lines...) Expand all Loading... |
95 service_path, | 95 service_path, |
96 base::Bind(&NetworkConfigMessageHandler::GetShillPropertiesSuccess, | 96 base::Bind(&NetworkConfigMessageHandler::GetShillPropertiesSuccess, |
97 weak_ptr_factory_.GetWeakPtr()), | 97 weak_ptr_factory_.GetWeakPtr()), |
98 base::Bind(&NetworkConfigMessageHandler::ErrorCallback, | 98 base::Bind(&NetworkConfigMessageHandler::ErrorCallback, |
99 weak_ptr_factory_.GetWeakPtr(), guid)); | 99 weak_ptr_factory_.GetWeakPtr(), guid)); |
100 } | 100 } |
101 | 101 |
102 void GetShillPropertiesSuccess( | 102 void GetShillPropertiesSuccess( |
103 const std::string& service_path, | 103 const std::string& service_path, |
104 const base::DictionaryValue& dictionary) const { | 104 const base::DictionaryValue& dictionary) const { |
105 scoped_ptr<base::DictionaryValue> dictionary_copy(dictionary.DeepCopy()); | 105 std::unique_ptr<base::DictionaryValue> dictionary_copy( |
| 106 dictionary.DeepCopy()); |
106 | 107 |
107 // Set the 'ServicePath' property for debugging. | 108 // Set the 'ServicePath' property for debugging. |
108 dictionary_copy->SetStringWithoutPathExpansion("ServicePath", service_path); | 109 dictionary_copy->SetStringWithoutPathExpansion("ServicePath", service_path); |
109 // Set the device properties for debugging. | 110 // Set the device properties for debugging. |
110 SetDeviceProperties(dictionary_copy.get()); | 111 SetDeviceProperties(dictionary_copy.get()); |
111 | 112 |
112 base::ListValue return_arg_list; | 113 base::ListValue return_arg_list; |
113 return_arg_list.Append(dictionary_copy.release()); | 114 return_arg_list.Append(dictionary_copy.release()); |
114 web_ui()->CallJavascriptFunction("NetworkUI.getShillPropertiesResult", | 115 web_ui()->CallJavascriptFunction("NetworkUI.getShillPropertiesResult", |
115 return_arg_list); | 116 return_arg_list); |
116 } | 117 } |
117 | 118 |
118 void ErrorCallback( | 119 void ErrorCallback( |
119 const std::string& guid, | 120 const std::string& guid, |
120 const std::string& error_name, | 121 const std::string& error_name, |
121 scoped_ptr<base::DictionaryValue> /* error_data */) const { | 122 std::unique_ptr<base::DictionaryValue> /* error_data */) const { |
122 NET_LOG(ERROR) << "Shill Error: " << error_name << " guid=" << guid; | 123 NET_LOG(ERROR) << "Shill Error: " << error_name << " guid=" << guid; |
123 base::ListValue return_arg_list; | 124 base::ListValue return_arg_list; |
124 scoped_ptr<base::DictionaryValue> dictionary; | 125 std::unique_ptr<base::DictionaryValue> dictionary; |
125 dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid); | 126 dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid); |
126 dictionary->SetStringWithoutPathExpansion("ShillError", error_name); | 127 dictionary->SetStringWithoutPathExpansion("ShillError", error_name); |
127 return_arg_list.Append(dictionary.release()); | 128 return_arg_list.Append(dictionary.release()); |
128 web_ui()->CallJavascriptFunction("NetworkUI.getShillPropertiesResult", | 129 web_ui()->CallJavascriptFunction("NetworkUI.getShillPropertiesResult", |
129 return_arg_list); | 130 return_arg_list); |
130 } | 131 } |
131 | 132 |
132 base::WeakPtrFactory<NetworkConfigMessageHandler> weak_ptr_factory_; | 133 base::WeakPtrFactory<NetworkConfigMessageHandler> weak_ptr_factory_; |
133 | 134 |
134 DISALLOW_COPY_AND_ASSIGN(NetworkConfigMessageHandler); | 135 DISALLOW_COPY_AND_ASSIGN(NetworkConfigMessageHandler); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 html->SetDefaultResource(IDR_NETWORK_UI_HTML); | 189 html->SetDefaultResource(IDR_NETWORK_UI_HTML); |
189 | 190 |
190 content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), | 191 content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), |
191 html); | 192 html); |
192 } | 193 } |
193 | 194 |
194 NetworkUI::~NetworkUI() { | 195 NetworkUI::~NetworkUI() { |
195 } | 196 } |
196 | 197 |
197 } // namespace chromeos | 198 } // namespace chromeos |
OLD | NEW |