| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 #include "content/public/browser/render_view_host.h" | 93 #include "content/public/browser/render_view_host.h" |
| 94 #include "content/public/browser/resource_context.h" | 94 #include "content/public/browser/resource_context.h" |
| 95 #include "content/public/browser/site_instance.h" | 95 #include "content/public/browser/site_instance.h" |
| 96 #include "content/public/browser/web_contents.h" | 96 #include "content/public/browser/web_contents.h" |
| 97 #include "content/public/browser/web_contents_view.h" | 97 #include "content/public/browser/web_contents_view.h" |
| 98 #include "content/public/common/child_process_host.h" | 98 #include "content/public/common/child_process_host.h" |
| 99 #include "content/public/common/compositor_util.h" | 99 #include "content/public/common/compositor_util.h" |
| 100 #include "content/public/common/content_descriptors.h" | 100 #include "content/public/common/content_descriptors.h" |
| 101 #include "grit/generated_resources.h" | 101 #include "grit/generated_resources.h" |
| 102 #include "grit/ui_resources.h" | 102 #include "grit/ui_resources.h" |
| 103 #include "net/base/mime_util.h" |
| 103 #include "net/base/ssl_cert_request_info.h" | 104 #include "net/base/ssl_cert_request_info.h" |
| 104 #include "net/cookies/canonical_cookie.h" | 105 #include "net/cookies/canonical_cookie.h" |
| 105 #include "net/cookies/cookie_options.h" | 106 #include "net/cookies/cookie_options.h" |
| 106 #include "ppapi/host/ppapi_host.h" | 107 #include "ppapi/host/ppapi_host.h" |
| 107 #include "ui/base/l10n/l10n_util.h" | 108 #include "ui/base/l10n/l10n_util.h" |
| 108 #include "ui/base/resource/resource_bundle.h" | 109 #include "ui/base/resource/resource_bundle.h" |
| 109 #include "webkit/glue/webpreferences.h" | 110 #include "webkit/glue/webpreferences.h" |
| 110 #include "webkit/plugins/plugin_switches.h" | 111 #include "webkit/plugins/plugin_switches.h" |
| 111 | 112 |
| 112 #if defined(OS_WIN) | 113 #if defined(OS_WIN) |
| 113 #include "chrome/browser/chrome_browser_main_win.h" | 114 #include "chrome/browser/chrome_browser_main_win.h" |
| 114 #elif defined(OS_MACOSX) | 115 #elif defined(OS_MACOSX) |
| 115 #include "chrome/browser/chrome_browser_main_mac.h" | 116 #include "chrome/browser/chrome_browser_main_mac.h" |
| 116 #include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h" | 117 #include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h" |
| 117 #elif defined(OS_CHROMEOS) | 118 #elif defined(OS_CHROMEOS) |
| 118 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" | 119 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" |
| 119 #include "chrome/browser/chromeos/login/user_manager.h" | 120 #include "chrome/browser/chromeos/login/user_manager.h" |
| 120 #elif defined(OS_LINUX) | 121 #elif defined(OS_LINUX) |
| 121 #include "chrome/browser/chrome_browser_main_linux.h" | 122 #include "chrome/browser/chrome_browser_main_linux.h" |
| 122 #elif defined(OS_ANDROID) | 123 #elif defined(OS_ANDROID) |
| 123 #include "chrome/browser/chrome_browser_main_android.h" | 124 #include "chrome/browser/chrome_browser_main_android.h" |
| 124 #include "chrome/common/descriptors_android.h" | 125 #include "chrome/common/descriptors_android.h" |
| 126 #include "net/android/network_library.h" |
| 125 #elif defined(OS_POSIX) | 127 #elif defined(OS_POSIX) |
| 126 #include "chrome/browser/chrome_browser_main_posix.h" | 128 #include "chrome/browser/chrome_browser_main_posix.h" |
| 127 #endif | 129 #endif |
| 128 | 130 |
| 129 #if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_ANDROID) | 131 #if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_ANDROID) |
| 130 #include "base/linux_util.h" | 132 #include "base/linux_util.h" |
| 131 #include "chrome/browser/crash_handler_host_linux.h" | 133 #include "chrome/browser/crash_handler_host_linux.h" |
| 132 #endif | 134 #endif |
| 133 | 135 |
| 134 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 136 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| (...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1267 // If there is no SSLTabHelper for the given WebContents then we can't | 1269 // If there is no SSLTabHelper for the given WebContents then we can't |
| 1268 // show the user a dialog to select a client certificate. So we simply | 1270 // show the user a dialog to select a client certificate. So we simply |
| 1269 // proceed with no client certificate. | 1271 // proceed with no client certificate. |
| 1270 callback.Run(NULL); | 1272 callback.Run(NULL); |
| 1271 return; | 1273 return; |
| 1272 } | 1274 } |
| 1273 ssl_tab_helper->ShowClientCertificateRequestDialog( | 1275 ssl_tab_helper->ShowClientCertificateRequestDialog( |
| 1274 network_session, cert_request_info, callback); | 1276 network_session, cert_request_info, callback); |
| 1275 } | 1277 } |
| 1276 | 1278 |
| 1277 void ChromeContentBrowserClient::AddNewCertificate( | 1279 void ChromeContentBrowserClient::AddNewCryptoFile( |
| 1278 net::URLRequest* request, | 1280 net::URLRequest* request, |
| 1279 net::X509Certificate* cert, | 1281 net::CryptoFileType file_type, |
| 1282 const void* file_data, |
| 1283 size_t file_size, |
| 1280 int render_process_id, | 1284 int render_process_id, |
| 1281 int render_view_id) { | 1285 int render_view_id) { |
| 1282 // The handler will run the UI and delete itself when it's finished. | 1286 #ifdef OS_ANDROID |
| 1283 new SSLAddCertHandler(request, cert, render_process_id, render_view_id); | 1287 // Special case for Android here for several reasons: |
| 1288 // |
| 1289 // - The SSLAddCertHandler implementation currently only supports |
| 1290 // CRYPTO_FILE_TYPE_X509_USER_CERT, but not other types, like |
| 1291 // CRYPTO_FILE_TYPE_PKCS12 which are required on this platform. |
| 1292 // |
| 1293 // - Besides, SSLAddCertHandler tries to verify the certificate |
| 1294 // by calling net::CertDatabase::CheckUserCert() which is not |
| 1295 // implemented on Android, mainly because there is no API |
| 1296 // provided by the system to do that properly. |
| 1297 // |
| 1298 // - The Android CertInstaller activity will check the crypto files |
| 1299 // and display a toast (small fading dialog) to the user if it is |
| 1300 // not valid, so the UI stuff performed by SSLAddCertHandler would |
| 1301 // be redundant. |
| 1302 if (file_size > 0) { |
| 1303 // This launches a new activity which will run in a different process. |
| 1304 // It handles all user interaction, so no need to do anything in the |
| 1305 // browser UI thread here. |
| 1306 net::android::StoreCryptoFile(file_type, file_data, file_size); |
| 1307 } |
| 1308 #else |
| 1309 // Chromium only supports X509 User certificates on other platforms. |
| 1310 // Note that this method should not be called for other crypto |
| 1311 // file types. See net::GetCryptoFileTypeFromMimeType(). |
| 1312 if (file_type == net::CRYPTO_FILE_TYPE_X509_USER_CERT) { |
| 1313 scoped_refptr<net::X509Certificate> cert; |
| 1314 if (file_data != NULL) { |
| 1315 cert = net::X509Certificate::CreateFromBytes( |
| 1316 reinterpret_cast<const char*>(file_data), file_size); |
| 1317 } |
| 1318 // NOTE: Passing a NULL cert pointer if file_data was NULL is |
| 1319 // intentional here. |
| 1320 |
| 1321 // The handler will run the UI and delete itself when it's finished. |
| 1322 new SSLAddCertHandler(request, cert, render_process_id, render_view_id); |
| 1323 } |
| 1324 #endif |
| 1284 } | 1325 } |
| 1285 | 1326 |
| 1286 content::MediaObserver* ChromeContentBrowserClient::GetMediaObserver() { | 1327 content::MediaObserver* ChromeContentBrowserClient::GetMediaObserver() { |
| 1287 return MediaInternals::GetInstance(); | 1328 return MediaInternals::GetInstance(); |
| 1288 } | 1329 } |
| 1289 | 1330 |
| 1290 void ChromeContentBrowserClient::RequestDesktopNotificationPermission( | 1331 void ChromeContentBrowserClient::RequestDesktopNotificationPermission( |
| 1291 const GURL& source_origin, | 1332 const GURL& source_origin, |
| 1292 int callback_context, | 1333 int callback_context, |
| 1293 int render_process_id, | 1334 int render_process_id, |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1849 partition_id = extension->id(); | 1890 partition_id = extension->id(); |
| 1850 } | 1891 } |
| 1851 | 1892 |
| 1852 // Enforce that IsValidStoragePartitionId() implementation stays in sync. | 1893 // Enforce that IsValidStoragePartitionId() implementation stays in sync. |
| 1853 DCHECK(IsValidStoragePartitionId(browser_context, partition_id)); | 1894 DCHECK(IsValidStoragePartitionId(browser_context, partition_id)); |
| 1854 return partition_id; | 1895 return partition_id; |
| 1855 } | 1896 } |
| 1856 | 1897 |
| 1857 | 1898 |
| 1858 } // namespace chrome | 1899 } // namespace chrome |
| OLD | NEW |