Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | |
| 12 | 13 |
| 13 #include "base/base_paths.h" | 14 #include "base/base_paths.h" |
| 14 #include "base/bind.h" | 15 #include "base/bind.h" |
| 15 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 16 #include "base/location.h" | 17 #include "base/location.h" |
| 17 #include "base/logging.h" | 18 #include "base/logging.h" |
| 18 #include "base/macros.h" | 19 #include "base/macros.h" |
| 19 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
| 20 #include "base/process/process_info.h" | 21 #include "base/process/process_info.h" |
| 21 #include "base/profiler/scoped_tracker.h" | 22 #include "base/profiler/scoped_tracker.h" |
| 22 #include "base/single_thread_task_runner.h" | 23 #include "base/single_thread_task_runner.h" |
| 24 #include "base/strings/string16.h" | |
| 23 #include "base/strings/string_number_conversions.h" | 25 #include "base/strings/string_number_conversions.h" |
| 24 #include "base/strings/string_util.h" | 26 #include "base/strings/string_util.h" |
| 25 #include "base/strings/stringprintf.h" | 27 #include "base/strings/stringprintf.h" |
| 26 #include "base/strings/utf_string_conversions.h" | 28 #include "base/strings/utf_string_conversions.h" |
| 27 #include "base/thread_task_runner_handle.h" | 29 #include "base/thread_task_runner_handle.h" |
| 28 #include "base/threading/thread.h" | 30 #include "base/threading/thread.h" |
| 29 #include "base/threading/thread_restrictions.h" | 31 #include "base/threading/thread_restrictions.h" |
| 30 #include "base/time/time.h" | 32 #include "base/time/time.h" |
| 31 #include "build/build_config.h" | 33 #include "build/build_config.h" |
| 32 #include "chrome/app/chrome_command_ids.h" | 34 #include "chrome/app/chrome_command_ids.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 #include "content/public/common/webplugininfo.h" | 204 #include "content/public/common/webplugininfo.h" |
| 203 #include "extensions/browser/extension_prefs.h" | 205 #include "extensions/browser/extension_prefs.h" |
| 204 #include "extensions/browser/extension_registry.h" | 206 #include "extensions/browser/extension_registry.h" |
| 205 #include "extensions/browser/extension_system.h" | 207 #include "extensions/browser/extension_system.h" |
| 206 #include "extensions/common/constants.h" | 208 #include "extensions/common/constants.h" |
| 207 #include "extensions/common/extension.h" | 209 #include "extensions/common/extension.h" |
| 208 #include "extensions/common/manifest_handlers/background_info.h" | 210 #include "extensions/common/manifest_handlers/background_info.h" |
| 209 #include "net/base/filename_util.h" | 211 #include "net/base/filename_util.h" |
| 210 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 212 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 211 #include "net/cookies/cookie_monster.h" | 213 #include "net/cookies/cookie_monster.h" |
| 214 #include "net/ssl/ssl_cipher_suite_names.h" | |
| 215 #include "net/ssl/ssl_connection_status_flags.h" | |
| 212 #include "net/url_request/url_request_context.h" | 216 #include "net/url_request/url_request_context.h" |
| 213 #include "third_party/WebKit/public/web/WebWindowFeatures.h" | 217 #include "third_party/WebKit/public/web/WebWindowFeatures.h" |
| 214 #include "ui/base/l10n/l10n_util.h" | 218 #include "ui/base/l10n/l10n_util.h" |
| 215 #include "ui/base/window_open_disposition.h" | 219 #include "ui/base/window_open_disposition.h" |
| 216 #include "ui/gfx/geometry/point.h" | 220 #include "ui/gfx/geometry/point.h" |
| 217 #include "ui/shell_dialogs/selected_file_info.h" | 221 #include "ui/shell_dialogs/selected_file_info.h" |
| 218 | 222 |
| 219 #if defined(OS_WIN) | 223 #if defined(OS_WIN) |
| 220 #include <windows.h> | 224 #include <windows.h> |
| 221 #include <shellapi.h> | 225 #include <shellapi.h> |
| (...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1306 blink::WebDragOperationsMask operations_allowed) { | 1310 blink::WebDragOperationsMask operations_allowed) { |
| 1307 // Disallow drag-and-drop navigation for Settings windows which do not support | 1311 // Disallow drag-and-drop navigation for Settings windows which do not support |
| 1308 // external navigation. | 1312 // external navigation. |
| 1309 if ((operations_allowed & blink::WebDragOperationLink) && | 1313 if ((operations_allowed & blink::WebDragOperationLink) && |
| 1310 chrome::SettingsWindowManager::GetInstance()->IsSettingsBrowser(this)) { | 1314 chrome::SettingsWindowManager::GetInstance()->IsSettingsBrowser(this)) { |
| 1311 return false; | 1315 return false; |
| 1312 } | 1316 } |
| 1313 return true; | 1317 return true; |
| 1314 } | 1318 } |
| 1315 | 1319 |
| 1316 content::SecurityStyle Browser::GetSecurityStyle( | 1320 content::SecurityStyle Browser::GetSecurityStyle( |
|
estark
2016/04/18 11:46:44
This function is getting pretty huge. We should pr
| |
| 1317 WebContents* web_contents, | 1321 WebContents* web_contents, |
| 1318 content::SecurityStyleExplanations* security_style_explanations) { | 1322 content::SecurityStyleExplanations* security_style_explanations) { |
| 1319 ChromeSecurityStateModelClient* model_client = | 1323 ChromeSecurityStateModelClient* model_client = |
| 1320 ChromeSecurityStateModelClient::FromWebContents(web_contents); | 1324 ChromeSecurityStateModelClient::FromWebContents(web_contents); |
| 1321 DCHECK(model_client); | 1325 DCHECK(model_client); |
| 1322 const SecurityStateModel::SecurityInfo& security_info = | 1326 const SecurityStateModel::SecurityInfo& security_info = |
| 1323 model_client->GetSecurityInfo(); | 1327 model_client->GetSecurityInfo(); |
| 1324 | 1328 |
| 1325 const content::SecurityStyle security_style = | 1329 const content::SecurityStyle security_style = |
| 1326 SecurityLevelToSecurityStyle(security_info.security_level); | 1330 SecurityLevelToSecurityStyle(security_info.security_level); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1395 SecurityStateModel::NO_DEPRECATED_SHA1) { | 1399 SecurityStateModel::NO_DEPRECATED_SHA1) { |
| 1396 security_style_explanations->secure_explanations.push_back( | 1400 security_style_explanations->secure_explanations.push_back( |
| 1397 content::SecurityStyleExplanation( | 1401 content::SecurityStyleExplanation( |
| 1398 l10n_util::GetStringUTF8(IDS_VALID_SERVER_CERTIFICATE), | 1402 l10n_util::GetStringUTF8(IDS_VALID_SERVER_CERTIFICATE), |
| 1399 l10n_util::GetStringUTF8( | 1403 l10n_util::GetStringUTF8( |
| 1400 IDS_VALID_SERVER_CERTIFICATE_DESCRIPTION), | 1404 IDS_VALID_SERVER_CERTIFICATE_DESCRIPTION), |
| 1401 security_info.cert_id)); | 1405 security_info.cert_id)); |
| 1402 } | 1406 } |
| 1403 } | 1407 } |
| 1404 | 1408 |
| 1405 if (security_info.is_secure_protocol_and_ciphersuite) { | 1409 int ssl_version = |
| 1410 net::SSLConnectionStatusToVersion(security_info.connection_status); | |
| 1411 const char* protocol; | |
| 1412 net::SSLVersionToString(&protocol, ssl_version); | |
| 1413 | |
| 1414 const char* key_exchange; | |
| 1415 const char* cipher; | |
| 1416 const char* mac; | |
| 1417 bool is_aead; | |
| 1418 uint16_t cipher_suite = | |
| 1419 net::SSLConnectionStatusToCipherSuite(security_info.connection_status); | |
| 1420 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead, | |
| 1421 cipher_suite); | |
| 1422 | |
| 1423 base::string16 protocol_name = base::ASCIIToUTF16(protocol); | |
| 1424 base::string16 key_exchange_name = base::ASCIIToUTF16(key_exchange); | |
| 1425 const base::string16 cipher_suite_name = | |
|
estark
2016/04/18 11:46:44
Why do these all need to be string16s?
lgarron
2016/04/25 23:56:53
GetStringFUTF8() as well as GetStringFUTF16() take
| |
| 1426 (mac == NULL) ? base::ASCIIToUTF16(cipher) | |
| 1427 : l10n_util::GetStringFUTF16(IDS_CIPHERSUITE_WITH_MAC, | |
| 1428 base::ASCIIToUTF16(cipher), | |
| 1429 base::ASCIIToUTF16(mac)); | |
| 1430 | |
| 1431 if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) { | |
| 1406 security_style_explanations->secure_explanations.push_back( | 1432 security_style_explanations->secure_explanations.push_back( |
| 1407 content::SecurityStyleExplanation( | 1433 content::SecurityStyleExplanation( |
| 1408 l10n_util::GetStringUTF8(IDS_SECURE_PROTOCOL_AND_CIPHERSUITE), | 1434 l10n_util::GetStringUTF8(IDS_SECURE_PROTOCOL_AND_CIPHERSUITE), |
| 1409 l10n_util::GetStringUTF8( | 1435 l10n_util::GetStringFUTF8( |
| 1410 IDS_SECURE_PROTOCOL_AND_CIPHERSUITE_DESCRIPTION))); | 1436 IDS_SECURE_PROTOCOL_AND_CIPHERSUITE_DESCRIPTION, protocol_name, |
| 1437 key_exchange_name, cipher_suite_name))); | |
| 1438 } else if (security_info.cert_id != 0) { | |
|
estark
2016/04/18 11:46:44
Can you please explain this check in a comment? It
lgarron
2016/04/25 23:56:53
The reason is net errors. If we don't include this
| |
| 1439 std::vector<base::string16> summary_replacements; | |
| 1440 std::vector<base::string16> description_replacements; | |
| 1441 | |
|
estark
2016/04/18 11:46:44
Hmmmm, reading this constructing-the-string code h
lgarron
2016/04/25 23:56:53
I've simplified things considerably, taking your s
| |
| 1442 if (security_info.obsolete_ssl_status & net::OBSOLETE_SSL_MASK_PROTOCOL) { | |
| 1443 description_replacements.push_back( | |
| 1444 l10n_util::GetStringUTF16(IDS_SSL_AN_OBSOLETE)); | |
| 1445 summary_replacements.push_back( | |
| 1446 l10n_util::GetStringUTF16(IDS_SSL_PROTOCOL)); | |
| 1447 } else { | |
| 1448 description_replacements.push_back( | |
| 1449 l10n_util::GetStringUTF16(IDS_SSL_A_MODERN)); | |
| 1450 } | |
| 1451 description_replacements.push_back(protocol_name); | |
| 1452 | |
| 1453 if (security_info.obsolete_ssl_status & | |
| 1454 net::OBSOLETE_SSL_MASK_KEY_EXCHANGE) { | |
| 1455 description_replacements.push_back( | |
| 1456 l10n_util::GetStringUTF16(IDS_SSL_AN_OBSOLETE)); | |
| 1457 summary_replacements.push_back( | |
| 1458 l10n_util::GetStringUTF16(IDS_SSL_KEY_EXCHANGE)); | |
| 1459 } else { | |
| 1460 description_replacements.push_back( | |
| 1461 l10n_util::GetStringUTF16(IDS_SSL_A_MODERN)); | |
| 1462 } | |
| 1463 description_replacements.push_back(key_exchange_name); | |
| 1464 | |
| 1465 if (security_info.obsolete_ssl_status & net::OBSOLETE_SSL_MASK_CIPHER) { | |
| 1466 description_replacements.push_back( | |
| 1467 l10n_util::GetStringUTF16(IDS_SSL_AN_OBSOLETE)); | |
| 1468 summary_replacements.push_back( | |
| 1469 l10n_util::GetStringUTF16(IDS_SSL_CIPHER_SUITE)); | |
| 1470 } else { | |
| 1471 description_replacements.push_back( | |
| 1472 l10n_util::GetStringUTF16(IDS_SSL_A_MODERN)); | |
| 1473 } | |
| 1474 description_replacements.push_back(cipher_suite_name); | |
| 1475 | |
| 1476 int summary_message_id; | |
| 1477 switch (summary_replacements.size()) { | |
| 1478 case 1: | |
| 1479 summary_message_id = IDS_SINGLE_OBSOLETE_TLS_SETTING; | |
| 1480 break; | |
| 1481 case 2: | |
| 1482 summary_message_id = IDS_TWO_OBSOLETE_TLS_SETTINGS; | |
| 1483 break; | |
| 1484 case 3: | |
| 1485 summary_message_id = IDS_THREE_OBSOLETE_TLS_SETTINGS; | |
| 1486 break; | |
| 1487 default: | |
| 1488 summary_message_id = 0; | |
| 1489 NOTREACHED(); | |
| 1490 } | |
| 1491 | |
| 1492 security_style_explanations->info_explanations.push_back( | |
| 1493 content::SecurityStyleExplanation( | |
| 1494 base::UTF16ToUTF8(l10n_util::GetStringFUTF16( | |
| 1495 summary_message_id, summary_replacements, nullptr)), | |
| 1496 base::UTF16ToUTF8(l10n_util::GetStringFUTF16( | |
| 1497 IDS_OBSOLETE_SSL_DESCRIPTION, description_replacements, | |
| 1498 nullptr)))); | |
| 1411 } | 1499 } |
| 1412 | 1500 |
| 1413 return security_style; | 1501 return security_style; |
| 1414 } | 1502 } |
| 1415 | 1503 |
| 1416 void Browser::ShowCertificateViewerInDevTools( | 1504 void Browser::ShowCertificateViewerInDevTools( |
| 1417 content::WebContents* web_contents, int cert_id) { | 1505 content::WebContents* web_contents, int cert_id) { |
| 1418 DevToolsWindow* devtools_window = | 1506 DevToolsWindow* devtools_window = |
| 1419 DevToolsWindow::GetInstanceForInspectedWebContents(web_contents); | 1507 DevToolsWindow::GetInstanceForInspectedWebContents(web_contents); |
| 1420 if (devtools_window) | 1508 if (devtools_window) |
| (...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2744 if (contents && !allow_js_access) { | 2832 if (contents && !allow_js_access) { |
| 2745 contents->web_contents()->GetController().LoadURL( | 2833 contents->web_contents()->GetController().LoadURL( |
| 2746 target_url, | 2834 target_url, |
| 2747 content::Referrer(), | 2835 content::Referrer(), |
| 2748 ui::PAGE_TRANSITION_LINK, | 2836 ui::PAGE_TRANSITION_LINK, |
| 2749 std::string()); // No extra headers. | 2837 std::string()); // No extra headers. |
| 2750 } | 2838 } |
| 2751 | 2839 |
| 2752 return contents != NULL; | 2840 return contents != NULL; |
| 2753 } | 2841 } |
| OLD | NEW |