Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Side by Side Diff: chrome/browser/ui/webui/net_internals/net_internals_ui.cc

Issue 419013003: Replace c/b/nss_context by a KeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Flattened components/cert_database folders. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/crypto_module_delegate_nss.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/net_internals/net_internals_ui.h" 5 #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 #include "net/proxy/proxy_service.h" 69 #include "net/proxy/proxy_service.h"
70 #include "net/url_request/url_request_context.h" 70 #include "net/url_request/url_request_context.h"
71 #include "net/url_request/url_request_context_getter.h" 71 #include "net/url_request/url_request_context_getter.h"
72 72
73 #if defined(OS_CHROMEOS) 73 #if defined(OS_CHROMEOS)
74 #include "chrome/browser/chromeos/file_manager/filesystem_api_util.h" 74 #include "chrome/browser/chromeos/file_manager/filesystem_api_util.h"
75 #include "chrome/browser/chromeos/net/onc_utils.h" 75 #include "chrome/browser/chromeos/net/onc_utils.h"
76 #include "chrome/browser/chromeos/profiles/profile_helper.h" 76 #include "chrome/browser/chromeos/profiles/profile_helper.h"
77 #include "chrome/browser/chromeos/system/syslogs_provider.h" 77 #include "chrome/browser/chromeos/system/syslogs_provider.h"
78 #include "chrome/browser/chromeos/system_logs/debug_log_writer.h" 78 #include "chrome/browser/chromeos/system_logs/debug_log_writer.h"
79 #include "chrome/browser/net/nss_context.h" 79 #include "chrome/browser/net/cert_database_service_factory.h"
80 #include "chromeos/dbus/dbus_thread_manager.h" 80 #include "chromeos/dbus/dbus_thread_manager.h"
81 #include "chromeos/dbus/debug_daemon_client.h" 81 #include "chromeos/dbus/debug_daemon_client.h"
82 #include "chromeos/network/onc/onc_certificate_importer_impl.h" 82 #include "chromeos/network/onc/onc_certificate_importer_impl.h"
83 #include "chromeos/network/onc/onc_utils.h" 83 #include "chromeos/network/onc/onc_utils.h"
84 #include "components/cert_database/cert_database_service.h"
84 #include "components/user_manager/user.h" 85 #include "components/user_manager/user.h"
85 #endif 86 #endif
86 87
87 #if defined(OS_WIN) 88 #if defined(OS_WIN)
88 #include "chrome/browser/net/service_providers_win.h" 89 #include "chrome/browser/net/service_providers_win.h"
89 #endif 90 #endif
90 91
91 #if defined(ENABLE_EXTENSIONS) 92 #if defined(ENABLE_EXTENSIONS)
92 #include "chrome/browser/extensions/extension_service.h" 93 #include "chrome/browser/extensions/extension_service.h"
93 #include "chrome/browser/ui/webui/extensions/extension_basic_info.h" 94 #include "chrome/browser/ui/webui/extensions/extension_basic_info.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 void OnRefreshSystemLogs(const base::ListValue* list); 232 void OnRefreshSystemLogs(const base::ListValue* list);
232 void OnGetSystemLog(const base::ListValue* list); 233 void OnGetSystemLog(const base::ListValue* list);
233 void OnImportONCFile(const base::ListValue* list); 234 void OnImportONCFile(const base::ListValue* list);
234 void OnStoreDebugLogs(const base::ListValue* list); 235 void OnStoreDebugLogs(const base::ListValue* list);
235 void OnStoreDebugLogsCompleted(const base::FilePath& log_path, 236 void OnStoreDebugLogsCompleted(const base::FilePath& log_path,
236 bool succeeded); 237 bool succeeded);
237 void OnSetNetworkDebugMode(const base::ListValue* list); 238 void OnSetNetworkDebugMode(const base::ListValue* list);
238 void OnSetNetworkDebugModeCompleted(const std::string& subsystem, 239 void OnSetNetworkDebugModeCompleted(const std::string& subsystem,
239 bool succeeded); 240 bool succeeded);
240 241
241 // Callback to |GetNSSCertDatabaseForProfile| used to retrieve the database
242 // to which user's ONC defined certificates should be imported.
243 // It parses and imports |onc_blob|.
244 void ImportONCFileToNSSDB(const std::string& onc_blob,
245 const std::string& passcode,
246 net::NSSCertDatabase* nssdb);
247
248 // Called back by the CertificateImporter when a certificate import finished. 242 // Called back by the CertificateImporter when a certificate import finished.
249 // |previous_error| contains earlier errors during this import. 243 // |previous_error| contains earlier errors during this import.
250 void OnCertificatesImported( 244 void OnCertificatesImported(
251 const std::string& previous_error, 245 const std::string& previous_error,
252 bool success, 246 bool success,
253 const net::CertificateList& onc_trusted_certificates); 247 const net::CertificateList& onc_trusted_certificates);
254 #endif 248 #endif
255 249
256 private: 250 private:
257 class IOThreadImpl; 251 class IOThreadImpl;
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 syslogs_getter_->DeleteSystemLogs(); 1150 syslogs_getter_->DeleteSystemLogs();
1157 syslogs_getter_->LoadSystemLogs(); 1151 syslogs_getter_->LoadSystemLogs();
1158 } 1152 }
1159 1153
1160 void NetInternalsMessageHandler::OnGetSystemLog( 1154 void NetInternalsMessageHandler::OnGetSystemLog(
1161 const base::ListValue* list) { 1155 const base::ListValue* list) {
1162 DCHECK(syslogs_getter_.get()); 1156 DCHECK(syslogs_getter_.get());
1163 syslogs_getter_->RequestSystemLog(list); 1157 syslogs_getter_->RequestSystemLog(list);
1164 } 1158 }
1165 1159
1166 void NetInternalsMessageHandler::ImportONCFileToNSSDB( 1160 void NetInternalsMessageHandler::OnImportONCFile(const base::ListValue* list) {
1167 const std::string& onc_blob, 1161 std::string onc_blob;
1168 const std::string& passcode, 1162 std::string passcode;
1169 net::NSSCertDatabase* nssdb) { 1163 if (list->GetSize() != 2 || !list->GetString(0, &onc_blob) ||
1164 !list->GetString(1, &passcode)) {
1165 NOTREACHED();
1166 }
1167
1170 user_manager::User* user = chromeos::ProfileHelper::Get()->GetUserByProfile( 1168 user_manager::User* user = chromeos::ProfileHelper::Get()->GetUserByProfile(
1171 Profile::FromWebUI(web_ui())); 1169 Profile::FromWebUI(web_ui()));
1172
1173 if (!user) { 1170 if (!user) {
1174 std::string error = "User not found."; 1171 std::string error = "User not found.";
1175 SendJavascriptCommand("receivedONCFileParse", new base::StringValue(error)); 1172 SendJavascriptCommand("receivedONCFileParse", new base::StringValue(error));
1176 return; 1173 return;
1177 } 1174 }
1178 1175
1176 cert_database::CertDatabaseService* cert_service =
1177 cert_database::CertDatabaseServiceFactory::GetForBrowserContext(
1178 web_ui()->GetWebContents()->GetBrowserContext());
1179 if (!cert_service) {
1180 std::string error = "Certificate database not available.";
1181 SendJavascriptCommand("receivedONCFileParse", new base::StringValue(error));
1182 return;
1183 }
1184
1179 std::string error; 1185 std::string error;
1180 onc::ONCSource onc_source = onc::ONC_SOURCE_USER_IMPORT; 1186 onc::ONCSource onc_source = onc::ONC_SOURCE_USER_IMPORT;
1181 base::ListValue network_configs; 1187 base::ListValue network_configs;
1182 base::DictionaryValue global_network_config; 1188 base::DictionaryValue global_network_config;
1183 base::ListValue certificates; 1189 base::ListValue certificates;
1184 if (!chromeos::onc::ParseAndValidateOncForImport(onc_blob, 1190 if (!chromeos::onc::ParseAndValidateOncForImport(onc_blob,
1185 onc_source, 1191 onc_source,
1186 passcode, 1192 passcode,
1187 &network_configs, 1193 &network_configs,
1188 &global_network_config, 1194 &global_network_config,
1189 &certificates)) { 1195 &certificates)) {
1190 error = "Errors occurred during the ONC parsing. "; 1196 error = "Errors occurred during the ONC parsing. ";
1191 } 1197 }
1192 1198
1193 std::string network_error; 1199 std::string network_error;
1194 chromeos::onc::ImportNetworksForUser(user, network_configs, &network_error); 1200 chromeos::onc::ImportNetworksForUser(user, network_configs, &network_error);
1195 if (!network_error.empty()) 1201 if (!network_error.empty())
1196 error += network_error; 1202 error += network_error;
1197 1203
1198 chromeos::onc::CertificateImporterImpl cert_importer( 1204 chromeos::onc::CertificateImporterImpl cert_importer(
1199 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), nssdb); 1205 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
1206 cert_service->GetIOPart());
1200 cert_importer.ImportCertificates( 1207 cert_importer.ImportCertificates(
1201 certificates, 1208 certificates,
1202 onc_source, 1209 onc_source,
1203 base::Bind(&NetInternalsMessageHandler::OnCertificatesImported, 1210 base::Bind(&NetInternalsMessageHandler::OnCertificatesImported,
1204 AsWeakPtr(), 1211 AsWeakPtr(),
1205 error)); 1212 error));
1206 } 1213 }
1207 1214
1208 void NetInternalsMessageHandler::OnCertificatesImported( 1215 void NetInternalsMessageHandler::OnCertificatesImported(
1209 const std::string& previous_error, 1216 const std::string& previous_error,
1210 bool success, 1217 bool success,
1211 const net::CertificateList& /* unused onc_trusted_certificates */) { 1218 const net::CertificateList& /* unused onc_trusted_certificates */) {
1212 std::string error = previous_error; 1219 std::string error = previous_error;
1213 if (!success) 1220 if (!success)
1214 error += "Some certificates couldn't be imported. "; 1221 error += "Some certificates couldn't be imported. ";
1215 1222
1216 SendJavascriptCommand("receivedONCFileParse", new base::StringValue(error)); 1223 SendJavascriptCommand("receivedONCFileParse", new base::StringValue(error));
1217 } 1224 }
1218 1225
1219 void NetInternalsMessageHandler::OnImportONCFile(
1220 const base::ListValue* list) {
1221 std::string onc_blob;
1222 std::string passcode;
1223 if (list->GetSize() != 2 ||
1224 !list->GetString(0, &onc_blob) ||
1225 !list->GetString(1, &passcode)) {
1226 NOTREACHED();
1227 }
1228
1229 GetNSSCertDatabaseForProfile(
1230 Profile::FromWebUI(web_ui()),
1231 base::Bind(&NetInternalsMessageHandler::ImportONCFileToNSSDB, AsWeakPtr(),
1232 onc_blob, passcode));
1233 }
1234
1235 void NetInternalsMessageHandler::OnStoreDebugLogs(const base::ListValue* list) { 1226 void NetInternalsMessageHandler::OnStoreDebugLogs(const base::ListValue* list) {
1236 DCHECK(list); 1227 DCHECK(list);
1237 1228
1238 SendJavascriptCommand("receivedStoreDebugLogs", 1229 SendJavascriptCommand("receivedStoreDebugLogs",
1239 new base::StringValue("Creating log file...")); 1230 new base::StringValue("Creating log file..."));
1240 Profile* profile = Profile::FromWebUI(web_ui()); 1231 Profile* profile = Profile::FromWebUI(web_ui());
1241 const DownloadPrefs* const prefs = DownloadPrefs::FromBrowserContext(profile); 1232 const DownloadPrefs* const prefs = DownloadPrefs::FromBrowserContext(profile);
1242 base::FilePath path = prefs->DownloadPath(); 1233 base::FilePath path = prefs->DownloadPath();
1243 if (file_manager::util::IsUnderNonNativeLocalPath(profile, path)) 1234 if (file_manager::util::IsUnderNonNativeLocalPath(profile, path))
1244 path = prefs->GetDefaultDownloadDirectoryForProfile(); 1235 path = prefs->GetDefaultDownloadDirectoryForProfile();
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 } 1476 }
1486 1477
1487 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) 1478 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui)
1488 : WebUIController(web_ui) { 1479 : WebUIController(web_ui) {
1489 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); 1480 web_ui->AddMessageHandler(new NetInternalsMessageHandler());
1490 1481
1491 // Set up the chrome://net-internals/ source. 1482 // Set up the chrome://net-internals/ source.
1492 Profile* profile = Profile::FromWebUI(web_ui); 1483 Profile* profile = Profile::FromWebUI(web_ui);
1493 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); 1484 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource());
1494 } 1485 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/crypto_module_delegate_nss.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698