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