| 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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #endif // defined(OS_WIN) | 10 #endif // defined(OS_WIN) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 #include "chrome/browser/profiles/profile_destroyer.h" | 69 #include "chrome/browser/profiles/profile_destroyer.h" |
| 70 #include "chrome/browser/profiles/profile_metrics.h" | 70 #include "chrome/browser/profiles/profile_metrics.h" |
| 71 #include "chrome/browser/profiles/profiles_state.h" | 71 #include "chrome/browser/profiles/profiles_state.h" |
| 72 #include "chrome/browser/repost_form_warning_controller.h" | 72 #include "chrome/browser/repost_form_warning_controller.h" |
| 73 #include "chrome/browser/search/search.h" | 73 #include "chrome/browser/search/search.h" |
| 74 #include "chrome/browser/sessions/session_restore.h" | 74 #include "chrome/browser/sessions/session_restore.h" |
| 75 #include "chrome/browser/sessions/session_service.h" | 75 #include "chrome/browser/sessions/session_service.h" |
| 76 #include "chrome/browser/sessions/session_service_factory.h" | 76 #include "chrome/browser/sessions/session_service_factory.h" |
| 77 #include "chrome/browser/sessions/session_tab_helper.h" | 77 #include "chrome/browser/sessions/session_tab_helper.h" |
| 78 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 78 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 79 #include "chrome/browser/ssl/security_state_model.h" | 79 #include "chrome/browser/ssl/chrome_security_state_model_delegate.h" |
| 80 #include "chrome/browser/sync/profile_sync_service_factory.h" | 80 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 81 #include "chrome/browser/sync/sync_ui_util.h" | 81 #include "chrome/browser/sync/sync_ui_util.h" |
| 82 #include "chrome/browser/tab_contents/retargeting_details.h" | 82 #include "chrome/browser/tab_contents/retargeting_details.h" |
| 83 #include "chrome/browser/tab_contents/tab_util.h" | 83 #include "chrome/browser/tab_contents/tab_util.h" |
| 84 #include "chrome/browser/task_management/web_contents_tags.h" | 84 #include "chrome/browser/task_management/web_contents_tags.h" |
| 85 #include "chrome/browser/themes/theme_service.h" | 85 #include "chrome/browser/themes/theme_service.h" |
| 86 #include "chrome/browser/themes/theme_service_factory.h" | 86 #include "chrome/browser/themes/theme_service_factory.h" |
| 87 #include "chrome/browser/translate/chrome_translate_client.h" | 87 #include "chrome/browser/translate/chrome_translate_client.h" |
| 88 #include "chrome/browser/ui/autofill/chrome_autofill_client.h" | 88 #include "chrome/browser/ui/autofill/chrome_autofill_client.h" |
| 89 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" | 89 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 #include "chrome/grit/locale_settings.h" | 155 #include "chrome/grit/locale_settings.h" |
| 156 #include "components/app_modal/javascript_dialog_manager.h" | 156 #include "components/app_modal/javascript_dialog_manager.h" |
| 157 #include "components/bookmarks/browser/bookmark_model.h" | 157 #include "components/bookmarks/browser/bookmark_model.h" |
| 158 #include "components/bookmarks/browser/bookmark_utils.h" | 158 #include "components/bookmarks/browser/bookmark_utils.h" |
| 159 #include "components/bookmarks/common/bookmark_pref_names.h" | 159 #include "components/bookmarks/common/bookmark_pref_names.h" |
| 160 #include "components/browser_sync/browser/profile_sync_service.h" | 160 #include "components/browser_sync/browser/profile_sync_service.h" |
| 161 #include "components/content_settings/core/browser/host_content_settings_map.h" | 161 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 162 #include "components/favicon/content/content_favicon_driver.h" | 162 #include "components/favicon/content/content_favicon_driver.h" |
| 163 #include "components/history/core/browser/top_sites.h" | 163 #include "components/history/core/browser/top_sites.h" |
| 164 #include "components/search/search.h" | 164 #include "components/search/search.h" |
| 165 #include "components/security_state/security_state_model.h" |
| 165 #include "components/sessions/core/session_types.h" | 166 #include "components/sessions/core/session_types.h" |
| 166 #include "components/sessions/core/tab_restore_service.h" | 167 #include "components/sessions/core/tab_restore_service.h" |
| 167 #include "components/startup_metric_utils/browser/startup_metric_utils.h" | 168 #include "components/startup_metric_utils/browser/startup_metric_utils.h" |
| 168 #include "components/translate/core/browser/language_state.h" | 169 #include "components/translate/core/browser/language_state.h" |
| 169 #include "components/ui/zoom/zoom_controller.h" | 170 #include "components/ui/zoom/zoom_controller.h" |
| 170 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 171 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 171 #include "content/public/browser/devtools_agent_host.h" | 172 #include "content/public/browser/devtools_agent_host.h" |
| 172 #include "content/public/browser/interstitial_page.h" | 173 #include "content/public/browser/interstitial_page.h" |
| 173 #include "content/public/browser/invalidate_type.h" | 174 #include "content/public/browser/invalidate_type.h" |
| 174 #include "content/public/browser/navigation_controller.h" | 175 #include "content/public/browser/navigation_controller.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 return BrowserWindow::CreateBrowserWindow(browser); | 252 return BrowserWindow::CreateBrowserWindow(browser); |
| 252 } | 253 } |
| 253 | 254 |
| 254 // Is the fast tab unload experiment enabled? | 255 // Is the fast tab unload experiment enabled? |
| 255 bool IsFastTabUnloadEnabled() { | 256 bool IsFastTabUnloadEnabled() { |
| 256 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 257 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 257 switches::kEnableFastUnload); | 258 switches::kEnableFastUnload); |
| 258 } | 259 } |
| 259 | 260 |
| 260 // Note: This is a lossy operation. Not all of the policies that can be | 261 // Note: This is a lossy operation. Not all of the policies that can be |
| 261 // expressed by a SecurityLevel (a //chrome concept) can be expressed by | 262 // expressed by a SecurityLevel can be expressed by a |
| 262 // a content::SecurityStyle. | 263 // content::SecurityStyle. |
| 263 content::SecurityStyle SecurityLevelToSecurityStyle( | 264 content::SecurityStyle SecurityLevelToSecurityStyle( |
| 264 SecurityStateModel::SecurityLevel security_level) { | 265 security_state::SecurityLevel security_level) { |
| 265 switch (security_level) { | 266 switch (security_level) { |
| 266 case SecurityStateModel::NONE: | 267 case security_state::NONE: |
| 267 return content::SECURITY_STYLE_UNAUTHENTICATED; | 268 return content::SECURITY_STYLE_UNAUTHENTICATED; |
| 268 case SecurityStateModel::SECURITY_WARNING: | 269 case security_state::SECURITY_WARNING: |
| 269 case SecurityStateModel::SECURITY_POLICY_WARNING: | 270 case security_state::SECURITY_POLICY_WARNING: |
| 270 return content::SECURITY_STYLE_WARNING; | 271 return content::SECURITY_STYLE_WARNING; |
| 271 case SecurityStateModel::EV_SECURE: | 272 case security_state::EV_SECURE: |
| 272 case SecurityStateModel::SECURE: | 273 case security_state::SECURE: |
| 273 return content::SECURITY_STYLE_AUTHENTICATED; | 274 return content::SECURITY_STYLE_AUTHENTICATED; |
| 274 case SecurityStateModel::SECURITY_ERROR: | 275 case security_state::SECURITY_ERROR: |
| 275 return content::SECURITY_STYLE_AUTHENTICATION_BROKEN; | 276 return content::SECURITY_STYLE_AUTHENTICATION_BROKEN; |
| 276 } | 277 } |
| 277 | 278 |
| 278 NOTREACHED(); | 279 NOTREACHED(); |
| 279 return content::SECURITY_STYLE_UNKNOWN; | 280 return content::SECURITY_STYLE_UNKNOWN; |
| 280 } | 281 } |
| 281 | 282 |
| 282 } // namespace | 283 } // namespace |
| 283 | 284 |
| 284 //////////////////////////////////////////////////////////////////////////////// | 285 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1306 if ((operations_allowed & blink::WebDragOperationLink) && | 1307 if ((operations_allowed & blink::WebDragOperationLink) && |
| 1307 chrome::SettingsWindowManager::GetInstance()->IsSettingsBrowser(this)) { | 1308 chrome::SettingsWindowManager::GetInstance()->IsSettingsBrowser(this)) { |
| 1308 return false; | 1309 return false; |
| 1309 } | 1310 } |
| 1310 return true; | 1311 return true; |
| 1311 } | 1312 } |
| 1312 | 1313 |
| 1313 content::SecurityStyle Browser::GetSecurityStyle( | 1314 content::SecurityStyle Browser::GetSecurityStyle( |
| 1314 WebContents* web_contents, | 1315 WebContents* web_contents, |
| 1315 content::SecurityStyleExplanations* security_style_explanations) { | 1316 content::SecurityStyleExplanations* security_style_explanations) { |
| 1316 SecurityStateModel* model = SecurityStateModel::FromWebContents(web_contents); | 1317 ChromeSecurityStateModelDelegate* model_delegate = |
| 1317 DCHECK(model); | 1318 ChromeSecurityStateModelDelegate::FromWebContents(web_contents); |
| 1318 const SecurityStateModel::SecurityInfo& security_info = | 1319 DCHECK(model_delegate); |
| 1319 model->GetSecurityInfo(); | 1320 const security_state::SecurityInfo& security_info = |
| 1321 model_delegate->GetSecurityInfo(); |
| 1320 | 1322 |
| 1321 const content::SecurityStyle security_style = | 1323 const content::SecurityStyle security_style = |
| 1322 SecurityLevelToSecurityStyle(security_info.security_level); | 1324 SecurityLevelToSecurityStyle(security_info.security_level); |
| 1323 | 1325 |
| 1324 security_style_explanations->ran_insecure_content_style = | 1326 security_style_explanations->ran_insecure_content_style = |
| 1325 SecurityStateModel::kRanInsecureContentStyle; | 1327 SecurityLevelToSecurityStyle( |
| 1328 security_state::SecurityStateModel::kRanInsecureContentLevel); |
| 1326 security_style_explanations->displayed_insecure_content_style = | 1329 security_style_explanations->displayed_insecure_content_style = |
| 1327 SecurityStateModel::kDisplayedInsecureContentStyle; | 1330 SecurityLevelToSecurityStyle( |
| 1331 security_state::SecurityStateModel::kDisplayedInsecureContentLevel); |
| 1328 | 1332 |
| 1329 // Check if the page is HTTP; if so, no explanations are needed. Note | 1333 // Check if the page is HTTP; if so, no explanations are needed. Note |
| 1330 // that SECURITY_STYLE_UNAUTHENTICATED does not necessarily mean that | 1334 // that SECURITY_STYLE_UNAUTHENTICATED does not necessarily mean that |
| 1331 // the page is loaded over HTTP, because the security style merely | 1335 // the page is loaded over HTTP, because the security style merely |
| 1332 // represents how the embedder wishes to display the security state of | 1336 // represents how the embedder wishes to display the security state of |
| 1333 // the page, and the embedder can choose to display HTTPS page as HTTP | 1337 // the page, and the embedder can choose to display HTTPS page as HTTP |
| 1334 // if it wants to (for example, displaying deprecated crypto | 1338 // if it wants to (for example, displaying deprecated crypto |
| 1335 // algorithms with the same UI treatment as HTTP pages). | 1339 // algorithms with the same UI treatment as HTTP pages). |
| 1336 security_style_explanations->scheme_is_cryptographic = | 1340 security_style_explanations->scheme_is_cryptographic = |
| 1337 security_info.scheme_is_cryptographic; | 1341 security_info.scheme_is_cryptographic; |
| 1338 if (!security_info.scheme_is_cryptographic) { | 1342 if (!security_info.scheme_is_cryptographic) { |
| 1339 return security_style; | 1343 return security_style; |
| 1340 } | 1344 } |
| 1341 | 1345 |
| 1342 if (security_info.sha1_deprecation_status == | 1346 if (security_info.sha1_deprecation_status == |
| 1343 SecurityStateModel::DEPRECATED_SHA1_MAJOR) { | 1347 security_state::DEPRECATED_SHA1_MAJOR) { |
| 1344 security_style_explanations->broken_explanations.push_back( | 1348 security_style_explanations->broken_explanations.push_back( |
| 1345 content::SecurityStyleExplanation( | 1349 content::SecurityStyleExplanation( |
| 1346 l10n_util::GetStringUTF8(IDS_MAJOR_SHA1), | 1350 l10n_util::GetStringUTF8(IDS_MAJOR_SHA1), |
| 1347 l10n_util::GetStringUTF8(IDS_MAJOR_SHA1_DESCRIPTION), | 1351 l10n_util::GetStringUTF8(IDS_MAJOR_SHA1_DESCRIPTION), |
| 1348 security_info.cert_id)); | 1352 security_info.cert_id)); |
| 1349 } else if (security_info.sha1_deprecation_status == | 1353 } else if (security_info.sha1_deprecation_status == |
| 1350 SecurityStateModel::DEPRECATED_SHA1_MINOR) { | 1354 security_state::DEPRECATED_SHA1_MINOR) { |
| 1351 security_style_explanations->unauthenticated_explanations.push_back( | 1355 security_style_explanations->unauthenticated_explanations.push_back( |
| 1352 content::SecurityStyleExplanation( | 1356 content::SecurityStyleExplanation( |
| 1353 l10n_util::GetStringUTF8(IDS_MINOR_SHA1), | 1357 l10n_util::GetStringUTF8(IDS_MINOR_SHA1), |
| 1354 l10n_util::GetStringUTF8(IDS_MINOR_SHA1_DESCRIPTION), | 1358 l10n_util::GetStringUTF8(IDS_MINOR_SHA1_DESCRIPTION), |
| 1355 security_info.cert_id)); | 1359 security_info.cert_id)); |
| 1356 } | 1360 } |
| 1357 | 1361 |
| 1358 security_style_explanations->ran_insecure_content = | 1362 security_style_explanations->ran_insecure_content = |
| 1363 security_info.mixed_content_status == security_state::RAN_MIXED_CONTENT || |
| 1359 security_info.mixed_content_status == | 1364 security_info.mixed_content_status == |
| 1360 SecurityStateModel::RAN_MIXED_CONTENT || | 1365 security_state::RAN_AND_DISPLAYED_MIXED_CONTENT; |
| 1361 security_info.mixed_content_status == | |
| 1362 SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT; | |
| 1363 security_style_explanations->displayed_insecure_content = | 1366 security_style_explanations->displayed_insecure_content = |
| 1364 security_info.mixed_content_status == | 1367 security_info.mixed_content_status == |
| 1365 SecurityStateModel::DISPLAYED_MIXED_CONTENT || | 1368 security_state::DISPLAYED_MIXED_CONTENT || |
| 1366 security_info.mixed_content_status == | 1369 security_info.mixed_content_status == |
| 1367 SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT; | 1370 security_state::RAN_AND_DISPLAYED_MIXED_CONTENT; |
| 1368 | 1371 |
| 1369 if (net::IsCertStatusError(security_info.cert_status)) { | 1372 if (net::IsCertStatusError(security_info.cert_status)) { |
| 1370 base::string16 error_string = base::UTF8ToUTF16(net::ErrorToString( | 1373 base::string16 error_string = base::UTF8ToUTF16(net::ErrorToString( |
| 1371 net::MapCertStatusToNetError(security_info.cert_status))); | 1374 net::MapCertStatusToNetError(security_info.cert_status))); |
| 1372 | 1375 |
| 1373 content::SecurityStyleExplanation explanation( | 1376 content::SecurityStyleExplanation explanation( |
| 1374 l10n_util::GetStringUTF8(IDS_CERTIFICATE_CHAIN_ERROR), | 1377 l10n_util::GetStringUTF8(IDS_CERTIFICATE_CHAIN_ERROR), |
| 1375 l10n_util::GetStringFUTF8( | 1378 l10n_util::GetStringFUTF8( |
| 1376 IDS_CERTIFICATE_CHAIN_ERROR_DESCRIPTION_FORMAT, error_string), | 1379 IDS_CERTIFICATE_CHAIN_ERROR_DESCRIPTION_FORMAT, error_string), |
| 1377 security_info.cert_id); | 1380 security_info.cert_id); |
| 1378 | 1381 |
| 1379 if (net::IsCertStatusMinorError(security_info.cert_status)) | 1382 if (net::IsCertStatusMinorError(security_info.cert_status)) |
| 1380 security_style_explanations->unauthenticated_explanations.push_back( | 1383 security_style_explanations->unauthenticated_explanations.push_back( |
| 1381 explanation); | 1384 explanation); |
| 1382 else | 1385 else |
| 1383 security_style_explanations->broken_explanations.push_back(explanation); | 1386 security_style_explanations->broken_explanations.push_back(explanation); |
| 1384 } else { | 1387 } else { |
| 1385 // If the certificate does not have errors and is not using | 1388 // If the certificate does not have errors and is not using |
| 1386 // deprecated SHA1, then add an explanation that the certificate is | 1389 // deprecated SHA1, then add an explanation that the certificate is |
| 1387 // valid. | 1390 // valid. |
| 1388 if (security_info.sha1_deprecation_status == | 1391 if (security_info.sha1_deprecation_status == |
| 1389 SecurityStateModel::NO_DEPRECATED_SHA1) { | 1392 security_state::NO_DEPRECATED_SHA1) { |
| 1390 security_style_explanations->secure_explanations.push_back( | 1393 security_style_explanations->secure_explanations.push_back( |
| 1391 content::SecurityStyleExplanation( | 1394 content::SecurityStyleExplanation( |
| 1392 l10n_util::GetStringUTF8(IDS_VALID_SERVER_CERTIFICATE), | 1395 l10n_util::GetStringUTF8(IDS_VALID_SERVER_CERTIFICATE), |
| 1393 l10n_util::GetStringUTF8( | 1396 l10n_util::GetStringUTF8( |
| 1394 IDS_VALID_SERVER_CERTIFICATE_DESCRIPTION), | 1397 IDS_VALID_SERVER_CERTIFICATE_DESCRIPTION), |
| 1395 security_info.cert_id)); | 1398 security_info.cert_id)); |
| 1396 } | 1399 } |
| 1397 } | 1400 } |
| 1398 | 1401 |
| 1399 if (security_info.is_secure_protocol_and_ciphersuite) { | 1402 if (security_info.is_secure_protocol_and_ciphersuite) { |
| (...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2704 if (contents && !allow_js_access) { | 2707 if (contents && !allow_js_access) { |
| 2705 contents->web_contents()->GetController().LoadURL( | 2708 contents->web_contents()->GetController().LoadURL( |
| 2706 target_url, | 2709 target_url, |
| 2707 content::Referrer(), | 2710 content::Referrer(), |
| 2708 ui::PAGE_TRANSITION_LINK, | 2711 ui::PAGE_TRANSITION_LINK, |
| 2709 std::string()); // No extra headers. | 2712 std::string()); // No extra headers. |
| 2710 } | 2713 } |
| 2711 | 2714 |
| 2712 return contents != NULL; | 2715 return contents != NULL; |
| 2713 } | 2716 } |
| OLD | NEW |