| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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.h" | 78 #include "chrome/browser/sessions/tab_restore_service.h" |
| 79 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 79 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 80 #include "chrome/browser/ssl/security_state_model.h" | |
| 81 #include "chrome/browser/sync/profile_sync_service.h" | 80 #include "chrome/browser/sync/profile_sync_service.h" |
| 82 #include "chrome/browser/sync/profile_sync_service_factory.h" | 81 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 83 #include "chrome/browser/sync/sync_ui_util.h" | 82 #include "chrome/browser/sync/sync_ui_util.h" |
| 84 #include "chrome/browser/tab_contents/retargeting_details.h" | 83 #include "chrome/browser/tab_contents/retargeting_details.h" |
| 85 #include "chrome/browser/tab_contents/tab_util.h" | 84 #include "chrome/browser/tab_contents/tab_util.h" |
| 86 #include "chrome/browser/task_management/web_contents_tags.h" | 85 #include "chrome/browser/task_management/web_contents_tags.h" |
| 87 #include "chrome/browser/themes/theme_service.h" | 86 #include "chrome/browser/themes/theme_service.h" |
| 88 #include "chrome/browser/themes/theme_service_factory.h" | 87 #include "chrome/browser/themes/theme_service_factory.h" |
| 89 #include "chrome/browser/translate/chrome_translate_client.h" | 88 #include "chrome/browser/translate/chrome_translate_client.h" |
| 90 #include "chrome/browser/ui/autofill/chrome_autofill_client.h" | 89 #include "chrome/browser/ui/autofill/chrome_autofill_client.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 BrowserWindow* CreateBrowserWindow(Browser* browser) { | 247 BrowserWindow* CreateBrowserWindow(Browser* browser) { |
| 249 return BrowserWindow::CreateBrowserWindow(browser); | 248 return BrowserWindow::CreateBrowserWindow(browser); |
| 250 } | 249 } |
| 251 | 250 |
| 252 // Is the fast tab unload experiment enabled? | 251 // Is the fast tab unload experiment enabled? |
| 253 bool IsFastTabUnloadEnabled() { | 252 bool IsFastTabUnloadEnabled() { |
| 254 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 253 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 255 switches::kEnableFastUnload); | 254 switches::kEnableFastUnload); |
| 256 } | 255 } |
| 257 | 256 |
| 258 // Note: This is a lossy operation. Not all of the policies that can be | |
| 259 // expressed by a SecurityLevel (a //chrome concept) can be expressed by | |
| 260 // a content::SecurityStyle. | |
| 261 content::SecurityStyle SecurityLevelToSecurityStyle( | |
| 262 SecurityStateModel::SecurityLevel security_level) { | |
| 263 switch (security_level) { | |
| 264 case SecurityStateModel::NONE: | |
| 265 return content::SECURITY_STYLE_UNAUTHENTICATED; | |
| 266 case SecurityStateModel::SECURITY_WARNING: | |
| 267 case SecurityStateModel::SECURITY_POLICY_WARNING: | |
| 268 return content::SECURITY_STYLE_WARNING; | |
| 269 case SecurityStateModel::EV_SECURE: | |
| 270 case SecurityStateModel::SECURE: | |
| 271 return content::SECURITY_STYLE_AUTHENTICATED; | |
| 272 case SecurityStateModel::SECURITY_ERROR: | |
| 273 return content::SECURITY_STYLE_AUTHENTICATION_BROKEN; | |
| 274 } | |
| 275 | |
| 276 NOTREACHED(); | |
| 277 return content::SECURITY_STYLE_UNKNOWN; | |
| 278 } | |
| 279 | |
| 280 } // namespace | 257 } // namespace |
| 281 | 258 |
| 282 //////////////////////////////////////////////////////////////////////////////// | 259 //////////////////////////////////////////////////////////////////////////////// |
| 283 // Browser, CreateParams: | 260 // Browser, CreateParams: |
| 284 | 261 |
| 285 Browser::CreateParams::CreateParams(Profile* profile, | 262 Browser::CreateParams::CreateParams(Profile* profile, |
| 286 chrome::HostDesktopType host_desktop_type) | 263 chrome::HostDesktopType host_desktop_type) |
| 287 : type(TYPE_TABBED), | 264 : type(TYPE_TABBED), |
| 288 profile(profile), | 265 profile(profile), |
| 289 host_desktop_type(host_desktop_type), | 266 host_desktop_type(host_desktop_type), |
| (...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1312 if ((operations_allowed & blink::WebDragOperationLink) && | 1289 if ((operations_allowed & blink::WebDragOperationLink) && |
| 1313 chrome::SettingsWindowManager::GetInstance()->IsSettingsBrowser(this)) { | 1290 chrome::SettingsWindowManager::GetInstance()->IsSettingsBrowser(this)) { |
| 1314 return false; | 1291 return false; |
| 1315 } | 1292 } |
| 1316 return true; | 1293 return true; |
| 1317 } | 1294 } |
| 1318 | 1295 |
| 1319 content::SecurityStyle Browser::GetSecurityStyle( | 1296 content::SecurityStyle Browser::GetSecurityStyle( |
| 1320 WebContents* web_contents, | 1297 WebContents* web_contents, |
| 1321 content::SecurityStyleExplanations* security_style_explanations) { | 1298 content::SecurityStyleExplanations* security_style_explanations) { |
| 1322 SecurityStateModel* model = SecurityStateModel::FromWebContents(web_contents); | 1299 connection_security::SecurityInfo security_info; |
| 1323 DCHECK(model); | 1300 connection_security::GetSecurityInfoForWebContents(web_contents, |
| 1324 const SecurityStateModel::SecurityInfo& security_info = | 1301 &security_info); |
| 1325 model->security_info(); | |
| 1326 | |
| 1327 const content::SecurityStyle security_style = | |
| 1328 SecurityLevelToSecurityStyle(security_info.security_level); | |
| 1329 | 1302 |
| 1330 security_style_explanations->ran_insecure_content_style = | 1303 security_style_explanations->ran_insecure_content_style = |
| 1331 SecurityStateModel::kRanInsecureContentStyle; | 1304 connection_security::kRanInsecureContentStyle; |
| 1332 security_style_explanations->displayed_insecure_content_style = | 1305 security_style_explanations->displayed_insecure_content_style = |
| 1333 SecurityStateModel::kDisplayedInsecureContentStyle; | 1306 connection_security::kDisplayedInsecureContentStyle; |
| 1334 | 1307 |
| 1335 // Check if the page is HTTP; if so, no explanations are needed. Note | 1308 // Check if the page is HTTP; if so, no explanations are needed. Note |
| 1336 // that SECURITY_STYLE_UNAUTHENTICATED does not necessarily mean that | 1309 // that SECURITY_STYLE_UNAUTHENTICATED does not necessarily mean that |
| 1337 // the page is loaded over HTTP, because the security style merely | 1310 // the page is loaded over HTTP, because the security style merely |
| 1338 // represents how the embedder wishes to display the security state of | 1311 // represents how the embedder wishes to display the security state of |
| 1339 // the page, and the embedder can choose to display HTTPS page as HTTP | 1312 // the page, and the embedder can choose to display HTTPS page as HTTP |
| 1340 // if it wants to (for example, displaying deprecated crypto | 1313 // if it wants to (for example, displaying deprecated crypto |
| 1341 // algorithms with the same UI treatment as HTTP pages). | 1314 // algorithms with the same UI treatment as HTTP pages). |
| 1342 security_style_explanations->scheme_is_cryptographic = | 1315 security_style_explanations->scheme_is_cryptographic = |
| 1343 security_info.scheme_is_cryptographic; | 1316 security_info.scheme_is_cryptographic; |
| 1344 if (!security_info.scheme_is_cryptographic) { | 1317 if (!security_info.scheme_is_cryptographic || |
| 1345 return security_style; | 1318 security_info.security_style == content::SECURITY_STYLE_UNKNOWN) { |
| 1319 return security_info.security_style; |
| 1346 } | 1320 } |
| 1347 | 1321 |
| 1348 if (security_info.sha1_deprecation_status == | 1322 if (security_info.sha1_deprecation_status == |
| 1349 SecurityStateModel::DEPRECATED_SHA1_BROKEN) { | 1323 connection_security::DEPRECATED_SHA1_BROKEN) { |
| 1350 security_style_explanations->broken_explanations.push_back( | 1324 security_style_explanations->broken_explanations.push_back( |
| 1351 content::SecurityStyleExplanation( | 1325 content::SecurityStyleExplanation( |
| 1352 l10n_util::GetStringUTF8(IDS_BROKEN_SHA1), | 1326 l10n_util::GetStringUTF8(IDS_BROKEN_SHA1), |
| 1353 l10n_util::GetStringUTF8(IDS_BROKEN_SHA1_DESCRIPTION), | 1327 l10n_util::GetStringUTF8(IDS_BROKEN_SHA1_DESCRIPTION), |
| 1354 security_info.cert_id)); | 1328 security_info.cert_id)); |
| 1355 } else if (security_info.sha1_deprecation_status == | 1329 } else if (security_info.sha1_deprecation_status == |
| 1356 SecurityStateModel::DEPRECATED_SHA1_WARNING) { | 1330 connection_security::DEPRECATED_SHA1_WARNING) { |
| 1357 security_style_explanations->warning_explanations.push_back( | 1331 security_style_explanations->warning_explanations.push_back( |
| 1358 content::SecurityStyleExplanation( | 1332 content::SecurityStyleExplanation( |
| 1359 l10n_util::GetStringUTF8(IDS_WARNING_SHA1), | 1333 l10n_util::GetStringUTF8(IDS_WARNING_SHA1), |
| 1360 l10n_util::GetStringUTF8(IDS_WARNING_SHA1_DESCRIPTION), | 1334 l10n_util::GetStringUTF8(IDS_WARNING_SHA1_DESCRIPTION), |
| 1361 security_info.cert_id)); | 1335 security_info.cert_id)); |
| 1362 } | 1336 } |
| 1363 | 1337 |
| 1364 security_style_explanations->ran_insecure_content = | 1338 security_style_explanations->ran_insecure_content = |
| 1365 security_info.mixed_content_status == | 1339 security_info.mixed_content_status == |
| 1366 SecurityStateModel::RAN_MIXED_CONTENT || | 1340 connection_security::RAN_MIXED_CONTENT || |
| 1367 security_info.mixed_content_status == | 1341 security_info.mixed_content_status == |
| 1368 SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT; | 1342 connection_security::RAN_AND_DISPLAYED_MIXED_CONTENT; |
| 1369 security_style_explanations->displayed_insecure_content = | 1343 security_style_explanations->displayed_insecure_content = |
| 1370 security_info.mixed_content_status == | 1344 security_info.mixed_content_status == |
| 1371 SecurityStateModel::DISPLAYED_MIXED_CONTENT || | 1345 connection_security::DISPLAYED_MIXED_CONTENT || |
| 1372 security_info.mixed_content_status == | 1346 security_info.mixed_content_status == |
| 1373 SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT; | 1347 connection_security::RAN_AND_DISPLAYED_MIXED_CONTENT; |
| 1374 | 1348 |
| 1375 if (net::IsCertStatusError(security_info.cert_status)) { | 1349 if (net::IsCertStatusError(security_info.cert_status)) { |
| 1376 base::string16 error_string = base::UTF8ToUTF16(net::ErrorToString( | 1350 base::string16 error_string = base::UTF8ToUTF16(net::ErrorToString( |
| 1377 net::MapCertStatusToNetError(security_info.cert_status))); | 1351 net::MapCertStatusToNetError(security_info.cert_status))); |
| 1378 | 1352 |
| 1379 content::SecurityStyleExplanation explanation( | 1353 content::SecurityStyleExplanation explanation( |
| 1380 l10n_util::GetStringUTF8(IDS_CERTIFICATE_CHAIN_ERROR), | 1354 l10n_util::GetStringUTF8(IDS_CERTIFICATE_CHAIN_ERROR), |
| 1381 l10n_util::GetStringFUTF8( | 1355 l10n_util::GetStringFUTF8( |
| 1382 IDS_CERTIFICATE_CHAIN_ERROR_DESCRIPTION_FORMAT, error_string), | 1356 IDS_CERTIFICATE_CHAIN_ERROR_DESCRIPTION_FORMAT, error_string), |
| 1383 security_info.cert_id); | 1357 security_info.cert_id); |
| 1384 | 1358 |
| 1385 if (net::IsCertStatusMinorError(security_info.cert_status)) | 1359 if (net::IsCertStatusMinorError(security_info.cert_status)) |
| 1386 security_style_explanations->warning_explanations.push_back(explanation); | 1360 security_style_explanations->warning_explanations.push_back(explanation); |
| 1387 else | 1361 else |
| 1388 security_style_explanations->broken_explanations.push_back(explanation); | 1362 security_style_explanations->broken_explanations.push_back(explanation); |
| 1389 } else { | 1363 } else { |
| 1390 // If the certificate does not have errors and is not using | 1364 // If the certificate does not have errors and is not using |
| 1391 // deprecated SHA1, then add an explanation that the certificate is | 1365 // deprecated SHA1, then add an explanation that the certificate is |
| 1392 // valid. | 1366 // valid. |
| 1393 if (security_info.sha1_deprecation_status == | 1367 if (security_info.sha1_deprecation_status == |
| 1394 SecurityStateModel::NO_DEPRECATED_SHA1) { | 1368 connection_security::NO_DEPRECATED_SHA1) { |
| 1395 security_style_explanations->secure_explanations.push_back( | 1369 security_style_explanations->secure_explanations.push_back( |
| 1396 content::SecurityStyleExplanation( | 1370 content::SecurityStyleExplanation( |
| 1397 l10n_util::GetStringUTF8(IDS_VALID_SERVER_CERTIFICATE), | 1371 l10n_util::GetStringUTF8(IDS_VALID_SERVER_CERTIFICATE), |
| 1398 l10n_util::GetStringUTF8( | 1372 l10n_util::GetStringUTF8( |
| 1399 IDS_VALID_SERVER_CERTIFICATE_DESCRIPTION), | 1373 IDS_VALID_SERVER_CERTIFICATE_DESCRIPTION), |
| 1400 security_info.cert_id)); | 1374 security_info.cert_id)); |
| 1401 } | 1375 } |
| 1402 } | 1376 } |
| 1403 | 1377 |
| 1404 return security_style; | 1378 return security_info.security_style; |
| 1405 } | 1379 } |
| 1406 | 1380 |
| 1407 void Browser::ShowCertificateViewerInDevTools( | 1381 void Browser::ShowCertificateViewerInDevTools( |
| 1408 content::WebContents* web_contents, int cert_id) { | 1382 content::WebContents* web_contents, int cert_id) { |
| 1409 DevToolsWindow* devtools_window = | 1383 DevToolsWindow* devtools_window = |
| 1410 DevToolsWindow::GetInstanceForInspectedWebContents(web_contents); | 1384 DevToolsWindow::GetInstanceForInspectedWebContents(web_contents); |
| 1411 if (devtools_window) | 1385 if (devtools_window) |
| 1412 devtools_window->ShowCertificateViewer(cert_id); | 1386 devtools_window->ShowCertificateViewer(cert_id); |
| 1413 } | 1387 } |
| 1414 | 1388 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1503 // need to update the command state early on load to always present usable | 1477 // need to update the command state early on load to always present usable |
| 1504 // actions in the face of slow-to-commit pages. | 1478 // actions in the face of slow-to-commit pages. |
| 1505 if (changed_flags & (content::INVALIDATE_TYPE_URL | | 1479 if (changed_flags & (content::INVALIDATE_TYPE_URL | |
| 1506 content::INVALIDATE_TYPE_LOAD)) | 1480 content::INVALIDATE_TYPE_LOAD)) |
| 1507 command_controller_->TabStateChanged(); | 1481 command_controller_->TabStateChanged(); |
| 1508 | 1482 |
| 1509 if (hosted_app_controller_) | 1483 if (hosted_app_controller_) |
| 1510 hosted_app_controller_->UpdateLocationBarVisibility(true); | 1484 hosted_app_controller_->UpdateLocationBarVisibility(true); |
| 1511 } | 1485 } |
| 1512 | 1486 |
| 1513 void Browser::VisibleSSLStateChanged(WebContents* source) { | 1487 void Browser::VisibleSSLStateChanged(const WebContents* source) { |
| 1514 // When the current tab's SSL state changes, we need to update the URL | 1488 // When the current tab's SSL state changes, we need to update the URL |
| 1515 // bar to reflect the new state. | 1489 // bar to reflect the new state. |
| 1516 DCHECK(source); | 1490 DCHECK(source); |
| 1517 | |
| 1518 // Notify the model that the security state has changed, so that the | |
| 1519 // URL bar updates with up-to-date data computed by the model. | |
| 1520 SecurityStateModel* model = SecurityStateModel::FromWebContents(source); | |
| 1521 DCHECK(model); | |
| 1522 model->SecurityStateChanged(); | |
| 1523 | |
| 1524 if (tab_strip_model_->GetActiveWebContents() == source) | 1491 if (tab_strip_model_->GetActiveWebContents() == source) |
| 1525 UpdateToolbar(false); | 1492 UpdateToolbar(false); |
| 1526 } | 1493 } |
| 1527 | 1494 |
| 1528 void Browser::AddNewContents(WebContents* source, | 1495 void Browser::AddNewContents(WebContents* source, |
| 1529 WebContents* new_contents, | 1496 WebContents* new_contents, |
| 1530 WindowOpenDisposition disposition, | 1497 WindowOpenDisposition disposition, |
| 1531 const gfx::Rect& initial_rect, | 1498 const gfx::Rect& initial_rect, |
| 1532 bool user_gesture, | 1499 bool user_gesture, |
| 1533 bool* was_blocked) { | 1500 bool* was_blocked) { |
| (...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2691 if (contents && !allow_js_access) { | 2658 if (contents && !allow_js_access) { |
| 2692 contents->web_contents()->GetController().LoadURL( | 2659 contents->web_contents()->GetController().LoadURL( |
| 2693 target_url, | 2660 target_url, |
| 2694 content::Referrer(), | 2661 content::Referrer(), |
| 2695 ui::PAGE_TRANSITION_LINK, | 2662 ui::PAGE_TRANSITION_LINK, |
| 2696 std::string()); // No extra headers. | 2663 std::string()); // No extra headers. |
| 2697 } | 2664 } |
| 2698 | 2665 |
| 2699 return contents != NULL; | 2666 return contents != NULL; |
| 2700 } | 2667 } |
| OLD | NEW |