OLD | NEW |
---|---|
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/chrome_content_browser_client.h" | 5 #include "chrome/browser/chrome_content_browser_client.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 #include "content/public/browser/resource_context.h" | 98 #include "content/public/browser/resource_context.h" |
99 #include "content/public/browser/site_instance.h" | 99 #include "content/public/browser/site_instance.h" |
100 #include "content/public/browser/web_contents.h" | 100 #include "content/public/browser/web_contents.h" |
101 #include "content/public/browser/web_contents_view.h" | 101 #include "content/public/browser/web_contents_view.h" |
102 #include "content/public/common/child_process_host.h" | 102 #include "content/public/common/child_process_host.h" |
103 #include "content/public/common/content_descriptors.h" | 103 #include "content/public/common/content_descriptors.h" |
104 #include "extensions/common/constants.h" | 104 #include "extensions/common/constants.h" |
105 #include "grit/generated_resources.h" | 105 #include "grit/generated_resources.h" |
106 #include "grit/ui_resources.h" | 106 #include "grit/ui_resources.h" |
107 #include "net/base/escape.h" | 107 #include "net/base/escape.h" |
108 #include "net/base/mime_util.h" | |
108 #include "net/base/ssl_cert_request_info.h" | 109 #include "net/base/ssl_cert_request_info.h" |
109 #include "net/cookies/canonical_cookie.h" | 110 #include "net/cookies/canonical_cookie.h" |
110 #include "net/cookies/cookie_options.h" | 111 #include "net/cookies/cookie_options.h" |
111 #include "ppapi/host/ppapi_host.h" | 112 #include "ppapi/host/ppapi_host.h" |
112 #include "ui/base/l10n/l10n_util.h" | 113 #include "ui/base/l10n/l10n_util.h" |
113 #include "ui/base/resource/resource_bundle.h" | 114 #include "ui/base/resource/resource_bundle.h" |
114 #include "webkit/glue/webpreferences.h" | 115 #include "webkit/glue/webpreferences.h" |
115 #include "webkit/plugins/plugin_switches.h" | 116 #include "webkit/plugins/plugin_switches.h" |
116 | 117 |
117 #if defined(OS_WIN) | 118 #if defined(OS_WIN) |
118 #include "chrome/browser/chrome_browser_main_win.h" | 119 #include "chrome/browser/chrome_browser_main_win.h" |
119 #elif defined(OS_MACOSX) | 120 #elif defined(OS_MACOSX) |
120 #include "chrome/browser/chrome_browser_main_mac.h" | 121 #include "chrome/browser/chrome_browser_main_mac.h" |
121 #include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h" | 122 #include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h" |
122 #elif defined(OS_CHROMEOS) | 123 #elif defined(OS_CHROMEOS) |
123 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" | 124 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" |
124 #include "chrome/browser/chromeos/login/user_manager.h" | 125 #include "chrome/browser/chromeos/login/user_manager.h" |
125 #elif defined(OS_LINUX) | 126 #elif defined(OS_LINUX) |
126 #include "chrome/browser/chrome_browser_main_linux.h" | 127 #include "chrome/browser/chrome_browser_main_linux.h" |
127 #elif defined(OS_ANDROID) | 128 #elif defined(OS_ANDROID) |
128 #include "chrome/browser/android/crash_dump_manager.h" | 129 #include "chrome/browser/android/crash_dump_manager.h" |
129 #include "chrome/browser/chrome_browser_main_android.h" | 130 #include "chrome/browser/chrome_browser_main_android.h" |
130 #include "chrome/common/descriptors_android.h" | 131 #include "chrome/common/descriptors_android.h" |
132 #include "net/android/network_library.h" | |
131 #elif defined(OS_POSIX) | 133 #elif defined(OS_POSIX) |
132 #include "chrome/browser/chrome_browser_main_posix.h" | 134 #include "chrome/browser/chrome_browser_main_posix.h" |
133 #endif | 135 #endif |
134 | 136 |
135 #if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_ANDROID) | 137 #if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_ANDROID) |
136 #include "base/linux_util.h" | 138 #include "base/linux_util.h" |
137 #include "chrome/browser/crash_handler_host_linux.h" | 139 #include "chrome/browser/crash_handler_host_linux.h" |
138 #endif | 140 #endif |
139 | 141 |
140 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 142 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1304 // If there is no SSLTabHelper for the given WebContents then we can't | 1306 // If there is no SSLTabHelper for the given WebContents then we can't |
1305 // show the user a dialog to select a client certificate. So we simply | 1307 // show the user a dialog to select a client certificate. So we simply |
1306 // proceed with no client certificate. | 1308 // proceed with no client certificate. |
1307 callback.Run(NULL); | 1309 callback.Run(NULL); |
1308 return; | 1310 return; |
1309 } | 1311 } |
1310 ssl_tab_helper->ShowClientCertificateRequestDialog( | 1312 ssl_tab_helper->ShowClientCertificateRequestDialog( |
1311 network_session, cert_request_info, callback); | 1313 network_session, cert_request_info, callback); |
1312 } | 1314 } |
1313 | 1315 |
1314 void ChromeContentBrowserClient::AddNewCertificate( | 1316 #if defined(OS_ANDROID) |
1317 // Special case for Android here for several reasons: | |
1318 // | |
1319 // - The SSLAddCertHandler implementation currently only supports | |
1320 // CERTIFICATE_TYPE_X509_USER_CERT, but not other types, like | |
1321 // CERTIFICATE_TYPE_PKCS12_ARCHIVE which are required on this | |
1322 // platform. | |
1323 // | |
1324 // - Besides, SSLAddCertHandler tries to parse the certificate | |
1325 // by calling net::CertDatabase::CheckUserCert() which is not | |
1326 // implemented on Android, mainly because there is no API | |
1327 // provided by the system to do that properly. | |
1328 // | |
1329 // - The Android CertInstaller activity will check the certificate file | |
1330 // and display a toast (small fading dialog) to the user if it is | |
1331 // not valid, so the UI performed by SSLAddCertHandler would | |
1332 // be redundant. | |
1333 void ChromeContentBrowserClient::AddCertificates( | |
darin (slow to review)
2012/11/15 20:47:05
nit: It seems like it would be good to move all of
| |
1315 net::URLRequest* request, | 1334 net::URLRequest* request, |
1316 net::X509Certificate* cert, | 1335 net::CertificateType cert_type, |
1336 const void* cert_data, | |
1337 size_t cert_size, | |
1338 int /* render_process_id */, | |
1339 int /* render_view_id */) { | |
1340 if (cert_size > 0) { | |
1341 // This launches a new activity which will run in a different process. | |
1342 // It handles all user interaction, so no need to do anything in the | |
1343 // browser UI thread here. | |
1344 net::android::StoreCertificate(cert_type, cert_data, cert_size); | |
1345 } | |
1346 } | |
1347 #else // OS_ANDROID | |
1348 void ChromeContentBrowserClient::AddCertificates( | |
1349 net::URLRequest* request, | |
1350 net::CertificateType cert_type, | |
1351 const void* cert_data, | |
1352 size_t cert_size, | |
1317 int render_process_id, | 1353 int render_process_id, |
1318 int render_view_id) { | 1354 int render_view_id) { |
1319 // The handler will run the UI and delete itself when it's finished. | 1355 // Chromium only supports X.509 User certificates on other platforms. |
1320 new SSLAddCertHandler(request, cert, render_process_id, render_view_id); | 1356 // Note that this method should not be called for other certificate |
1357 // types. See net::GetCertificateTypeFromMimeType(). | |
1358 if (cert_type == net::CERTIFICATE_TYPE_X509_USER_CERT) { | |
1359 scoped_refptr<net::X509Certificate> cert; | |
1360 if (cert_data != NULL) { | |
1361 cert = net::X509Certificate::CreateFromBytes( | |
1362 reinterpret_cast<const char*>(cert_data), cert_size); | |
1363 } | |
1364 // NOTE: Passing a NULL cert pointer if |cert_data| was NULL is | |
1365 // intentional here. | |
1366 | |
1367 // The handler will run the UI and delete itself when it's finished. | |
1368 new SSLAddCertHandler(request, cert, render_process_id, render_view_id); | |
1369 } | |
1321 } | 1370 } |
1371 #endif // OS_ANDROID | |
1322 | 1372 |
1323 content::MediaObserver* ChromeContentBrowserClient::GetMediaObserver() { | 1373 content::MediaObserver* ChromeContentBrowserClient::GetMediaObserver() { |
1324 return MediaInternals::GetInstance(); | 1374 return MediaInternals::GetInstance(); |
1325 } | 1375 } |
1326 | 1376 |
1327 void ChromeContentBrowserClient::RequestDesktopNotificationPermission( | 1377 void ChromeContentBrowserClient::RequestDesktopNotificationPermission( |
1328 const GURL& source_origin, | 1378 const GURL& source_origin, |
1329 int callback_context, | 1379 int callback_context, |
1330 int render_process_id, | 1380 int render_process_id, |
1331 int render_view_id) { | 1381 int render_view_id) { |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1913 io_thread_application_locale_ = locale; | 1963 io_thread_application_locale_ = locale; |
1914 } | 1964 } |
1915 | 1965 |
1916 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread( | 1966 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread( |
1917 const std::string& locale) { | 1967 const std::string& locale) { |
1918 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1968 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
1919 io_thread_application_locale_ = locale; | 1969 io_thread_application_locale_ = locale; |
1920 } | 1970 } |
1921 | 1971 |
1922 } // namespace chrome | 1972 } // namespace chrome |
OLD | NEW |