| 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 #include <utility> |
| 8 | 9 |
| 9 #include "base/macros.h" | 10 #include "base/macros.h" |
| 10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 11 #include "base/values.h" | 12 #include "base/values.h" |
| 12 #include "chrome/browser/chromeos/options/network_config_view.h" | 13 #include "chrome/browser/chromeos/options/network_config_view.h" |
| 13 #include "chrome/browser/extensions/tab_helper.h" | 14 #include "chrome/browser/extensions/tab_helper.h" |
| 14 #include "chrome/browser/ui/webui/settings/md_settings_localized_strings_provide
r.h" | 15 #include "chrome/browser/ui/webui/settings/md_settings_localized_strings_provide
r.h" |
| 15 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 16 #include "chrome/grit/browser_resources.h" | 17 #include "chrome/grit/browser_resources.h" |
| 17 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 const base::DictionaryValue& dictionary) const { | 112 const base::DictionaryValue& dictionary) const { |
| 112 std::unique_ptr<base::DictionaryValue> dictionary_copy( | 113 std::unique_ptr<base::DictionaryValue> dictionary_copy( |
| 113 dictionary.DeepCopy()); | 114 dictionary.DeepCopy()); |
| 114 | 115 |
| 115 // Set the 'ServicePath' property for debugging. | 116 // Set the 'ServicePath' property for debugging. |
| 116 dictionary_copy->SetStringWithoutPathExpansion("ServicePath", service_path); | 117 dictionary_copy->SetStringWithoutPathExpansion("ServicePath", service_path); |
| 117 // Set the device properties for debugging. | 118 // Set the device properties for debugging. |
| 118 SetDeviceProperties(dictionary_copy.get()); | 119 SetDeviceProperties(dictionary_copy.get()); |
| 119 | 120 |
| 120 base::ListValue return_arg_list; | 121 base::ListValue return_arg_list; |
| 121 return_arg_list.Append(dictionary_copy.release()); | 122 return_arg_list.Append(std::move(dictionary_copy)); |
| 122 web_ui()->CallJavascriptFunctionUnsafe("NetworkUI.getShillPropertiesResult", | 123 web_ui()->CallJavascriptFunctionUnsafe("NetworkUI.getShillPropertiesResult", |
| 123 return_arg_list); | 124 return_arg_list); |
| 124 } | 125 } |
| 125 | 126 |
| 126 void ErrorCallback( | 127 void ErrorCallback( |
| 127 const std::string& guid, | 128 const std::string& guid, |
| 128 const std::string& error_name, | 129 const std::string& error_name, |
| 129 std::unique_ptr<base::DictionaryValue> /* error_data */) const { | 130 std::unique_ptr<base::DictionaryValue> /* error_data */) const { |
| 130 NET_LOG(ERROR) << "Shill Error: " << error_name << " guid=" << guid; | 131 NET_LOG(ERROR) << "Shill Error: " << error_name << " guid=" << guid; |
| 131 base::ListValue return_arg_list; | 132 base::ListValue return_arg_list; |
| 132 std::unique_ptr<base::DictionaryValue> dictionary; | 133 std::unique_ptr<base::DictionaryValue> dictionary; |
| 133 dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid); | 134 dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid); |
| 134 dictionary->SetStringWithoutPathExpansion("ShillError", error_name); | 135 dictionary->SetStringWithoutPathExpansion("ShillError", error_name); |
| 135 return_arg_list.Append(dictionary.release()); | 136 return_arg_list.Append(std::move(dictionary)); |
| 136 web_ui()->CallJavascriptFunctionUnsafe("NetworkUI.getShillPropertiesResult", | 137 web_ui()->CallJavascriptFunctionUnsafe("NetworkUI.getShillPropertiesResult", |
| 137 return_arg_list); | 138 return_arg_list); |
| 138 } | 139 } |
| 139 | 140 |
| 140 void AddNetwork(const base::ListValue* args) { | 141 void AddNetwork(const base::ListValue* args) { |
| 141 std::string onc_type; | 142 std::string onc_type; |
| 142 args->GetString(0, &onc_type); | 143 args->GetString(0, &onc_type); |
| 143 std::string shill_type = (onc_type == ::onc::network_type::kVPN) | 144 std::string shill_type = (onc_type == ::onc::network_type::kVPN) |
| 144 ? shill::kTypeVPN | 145 ? shill::kTypeVPN |
| 145 : shill::kTypeWifi; | 146 : shill::kTypeWifi; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 html->SetDefaultResource(IDR_NETWORK_UI_HTML); | 218 html->SetDefaultResource(IDR_NETWORK_UI_HTML); |
| 218 | 219 |
| 219 content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), | 220 content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), |
| 220 html); | 221 html); |
| 221 } | 222 } |
| 222 | 223 |
| 223 NetworkUI::~NetworkUI() { | 224 NetworkUI::~NetworkUI() { |
| 224 } | 225 } |
| 225 | 226 |
| 226 } // namespace chromeos | 227 } // namespace chromeos |
| OLD | NEW |