Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 1539043002: Pull SecurityStateModel out into a component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: android fix Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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/chrome_security_state_model_client.h" 79 #include "chrome/browser/ssl/chrome_security_state_model_client.h"
80 #include "chrome/browser/ssl/security_state_model.h"
81 #include "chrome/browser/sync/profile_sync_service_factory.h" 80 #include "chrome/browser/sync/profile_sync_service_factory.h"
82 #include "chrome/browser/sync/sync_ui_util.h" 81 #include "chrome/browser/sync/sync_ui_util.h"
83 #include "chrome/browser/tab_contents/retargeting_details.h" 82 #include "chrome/browser/tab_contents/retargeting_details.h"
84 #include "chrome/browser/tab_contents/tab_util.h" 83 #include "chrome/browser/tab_contents/tab_util.h"
85 #include "chrome/browser/task_management/web_contents_tags.h" 84 #include "chrome/browser/task_management/web_contents_tags.h"
86 #include "chrome/browser/themes/theme_service.h" 85 #include "chrome/browser/themes/theme_service.h"
87 #include "chrome/browser/themes/theme_service_factory.h" 86 #include "chrome/browser/themes/theme_service_factory.h"
88 #include "chrome/browser/translate/chrome_translate_client.h" 87 #include "chrome/browser/translate/chrome_translate_client.h"
89 #include "chrome/browser/ui/autofill/chrome_autofill_client.h" 88 #include "chrome/browser/ui/autofill/chrome_autofill_client.h"
90 #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
156 #include "chrome/grit/locale_settings.h" 155 #include "chrome/grit/locale_settings.h"
157 #include "components/app_modal/javascript_dialog_manager.h" 156 #include "components/app_modal/javascript_dialog_manager.h"
158 #include "components/bookmarks/browser/bookmark_model.h" 157 #include "components/bookmarks/browser/bookmark_model.h"
159 #include "components/bookmarks/browser/bookmark_utils.h" 158 #include "components/bookmarks/browser/bookmark_utils.h"
160 #include "components/bookmarks/common/bookmark_pref_names.h" 159 #include "components/bookmarks/common/bookmark_pref_names.h"
161 #include "components/browser_sync/browser/profile_sync_service.h" 160 #include "components/browser_sync/browser/profile_sync_service.h"
162 #include "components/content_settings/core/browser/host_content_settings_map.h" 161 #include "components/content_settings/core/browser/host_content_settings_map.h"
163 #include "components/favicon/content/content_favicon_driver.h" 162 #include "components/favicon/content/content_favicon_driver.h"
164 #include "components/history/core/browser/top_sites.h" 163 #include "components/history/core/browser/top_sites.h"
165 #include "components/search/search.h" 164 #include "components/search/search.h"
165 #include "components/security_state/security_state_model.h"
166 #include "components/sessions/core/session_types.h" 166 #include "components/sessions/core/session_types.h"
167 #include "components/sessions/core/tab_restore_service.h" 167 #include "components/sessions/core/tab_restore_service.h"
168 #include "components/startup_metric_utils/browser/startup_metric_utils.h" 168 #include "components/startup_metric_utils/browser/startup_metric_utils.h"
169 #include "components/translate/core/browser/language_state.h" 169 #include "components/translate/core/browser/language_state.h"
170 #include "components/ui/zoom/zoom_controller.h" 170 #include "components/ui/zoom/zoom_controller.h"
171 #include "components/web_modal/web_contents_modal_dialog_manager.h" 171 #include "components/web_modal/web_contents_modal_dialog_manager.h"
172 #include "content/public/browser/devtools_agent_host.h" 172 #include "content/public/browser/devtools_agent_host.h"
173 #include "content/public/browser/interstitial_page.h" 173 #include "content/public/browser/interstitial_page.h"
174 #include "content/public/browser/invalidate_type.h" 174 #include "content/public/browser/invalidate_type.h"
175 #include "content/public/browser/navigation_controller.h" 175 #include "content/public/browser/navigation_controller.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // Is the fast tab unload experiment enabled? 255 // Is the fast tab unload experiment enabled?
256 bool IsFastTabUnloadEnabled() { 256 bool IsFastTabUnloadEnabled() {
257 return base::CommandLine::ForCurrentProcess()->HasSwitch( 257 return base::CommandLine::ForCurrentProcess()->HasSwitch(
258 switches::kEnableFastUnload); 258 switches::kEnableFastUnload);
259 } 259 }
260 260
261 // 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
262 // expressed by a SecurityLevel (a //chrome concept) can be expressed by 262 // expressed by a SecurityLevel (a //chrome concept) can be expressed by
263 // a content::SecurityStyle. 263 // a content::SecurityStyle.
264 content::SecurityStyle SecurityLevelToSecurityStyle( 264 content::SecurityStyle SecurityLevelToSecurityStyle(
265 SecurityStateModel::SecurityLevel security_level) { 265 security_state::SecurityStateModel::SecurityLevel security_level) {
266 switch (security_level) { 266 switch (security_level) {
267 case SecurityStateModel::NONE: 267 case security_state::SecurityStateModel::NONE:
268 return content::SECURITY_STYLE_UNAUTHENTICATED; 268 return content::SECURITY_STYLE_UNAUTHENTICATED;
269 case SecurityStateModel::SECURITY_WARNING: 269 case security_state::SecurityStateModel::SECURITY_WARNING:
270 case SecurityStateModel::SECURITY_POLICY_WARNING: 270 case security_state::SecurityStateModel::SECURITY_POLICY_WARNING:
271 return content::SECURITY_STYLE_WARNING; 271 return content::SECURITY_STYLE_WARNING;
272 case SecurityStateModel::EV_SECURE: 272 case security_state::SecurityStateModel::EV_SECURE:
273 case SecurityStateModel::SECURE: 273 case security_state::SecurityStateModel::SECURE:
274 return content::SECURITY_STYLE_AUTHENTICATED; 274 return content::SECURITY_STYLE_AUTHENTICATED;
275 case SecurityStateModel::SECURITY_ERROR: 275 case security_state::SecurityStateModel::SECURITY_ERROR:
276 return content::SECURITY_STYLE_AUTHENTICATION_BROKEN; 276 return content::SECURITY_STYLE_AUTHENTICATION_BROKEN;
277 } 277 }
278 278
279 NOTREACHED(); 279 NOTREACHED();
280 return content::SECURITY_STYLE_UNKNOWN; 280 return content::SECURITY_STYLE_UNKNOWN;
281 } 281 }
282 282
283 } // namespace 283 } // namespace
284 284
285 //////////////////////////////////////////////////////////////////////////////// 285 ////////////////////////////////////////////////////////////////////////////////
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 } 1311 }
1312 return true; 1312 return true;
1313 } 1313 }
1314 1314
1315 content::SecurityStyle Browser::GetSecurityStyle( 1315 content::SecurityStyle Browser::GetSecurityStyle(
1316 WebContents* web_contents, 1316 WebContents* web_contents,
1317 content::SecurityStyleExplanations* security_style_explanations) { 1317 content::SecurityStyleExplanations* security_style_explanations) {
1318 ChromeSecurityStateModelClient* model_client = 1318 ChromeSecurityStateModelClient* model_client =
1319 ChromeSecurityStateModelClient::FromWebContents(web_contents); 1319 ChromeSecurityStateModelClient::FromWebContents(web_contents);
1320 DCHECK(model_client); 1320 DCHECK(model_client);
1321 const SecurityStateModel::SecurityInfo& security_info = 1321 const security_state::SecurityStateModel::SecurityInfo& security_info =
1322 model_client->GetSecurityInfo(); 1322 model_client->GetSecurityInfo();
1323 1323
1324 const content::SecurityStyle security_style = 1324 const content::SecurityStyle security_style =
1325 SecurityLevelToSecurityStyle(security_info.security_level); 1325 SecurityLevelToSecurityStyle(security_info.security_level);
1326 1326
1327 security_style_explanations->ran_insecure_content_style = 1327 security_style_explanations->ran_insecure_content_style =
1328 SecurityLevelToSecurityStyle( 1328 SecurityLevelToSecurityStyle(
1329 SecurityStateModel::kRanInsecureContentLevel); 1329 security_state::SecurityStateModel::kRanInsecureContentLevel);
1330 security_style_explanations->displayed_insecure_content_style = 1330 security_style_explanations->displayed_insecure_content_style =
1331 SecurityLevelToSecurityStyle( 1331 SecurityLevelToSecurityStyle(
1332 SecurityStateModel::kDisplayedInsecureContentLevel); 1332 security_state::SecurityStateModel::kDisplayedInsecureContentLevel);
1333 1333
1334 // Check if the page is HTTP; if so, no explanations are needed. Note 1334 // Check if the page is HTTP; if so, no explanations are needed. Note
1335 // that SECURITY_STYLE_UNAUTHENTICATED does not necessarily mean that 1335 // that SECURITY_STYLE_UNAUTHENTICATED does not necessarily mean that
1336 // the page is loaded over HTTP, because the security style merely 1336 // the page is loaded over HTTP, because the security style merely
1337 // represents how the embedder wishes to display the security state of 1337 // represents how the embedder wishes to display the security state of
1338 // the page, and the embedder can choose to display HTTPS page as HTTP 1338 // the page, and the embedder can choose to display HTTPS page as HTTP
1339 // if it wants to (for example, displaying deprecated crypto 1339 // if it wants to (for example, displaying deprecated crypto
1340 // algorithms with the same UI treatment as HTTP pages). 1340 // algorithms with the same UI treatment as HTTP pages).
1341 security_style_explanations->scheme_is_cryptographic = 1341 security_style_explanations->scheme_is_cryptographic =
1342 security_info.scheme_is_cryptographic; 1342 security_info.scheme_is_cryptographic;
1343 if (!security_info.scheme_is_cryptographic) { 1343 if (!security_info.scheme_is_cryptographic) {
1344 return security_style; 1344 return security_style;
1345 } 1345 }
1346 1346
1347 if (security_info.sha1_deprecation_status == 1347 if (security_info.sha1_deprecation_status ==
1348 SecurityStateModel::DEPRECATED_SHA1_MAJOR) { 1348 security_state::SecurityStateModel::DEPRECATED_SHA1_MAJOR) {
1349 security_style_explanations->broken_explanations.push_back( 1349 security_style_explanations->broken_explanations.push_back(
1350 content::SecurityStyleExplanation( 1350 content::SecurityStyleExplanation(
1351 l10n_util::GetStringUTF8(IDS_MAJOR_SHA1), 1351 l10n_util::GetStringUTF8(IDS_MAJOR_SHA1),
1352 l10n_util::GetStringUTF8(IDS_MAJOR_SHA1_DESCRIPTION), 1352 l10n_util::GetStringUTF8(IDS_MAJOR_SHA1_DESCRIPTION),
1353 security_info.cert_id)); 1353 security_info.cert_id));
1354 } else if (security_info.sha1_deprecation_status == 1354 } else if (security_info.sha1_deprecation_status ==
1355 SecurityStateModel::DEPRECATED_SHA1_MINOR) { 1355 security_state::SecurityStateModel::DEPRECATED_SHA1_MINOR) {
1356 security_style_explanations->unauthenticated_explanations.push_back( 1356 security_style_explanations->unauthenticated_explanations.push_back(
1357 content::SecurityStyleExplanation( 1357 content::SecurityStyleExplanation(
1358 l10n_util::GetStringUTF8(IDS_MINOR_SHA1), 1358 l10n_util::GetStringUTF8(IDS_MINOR_SHA1),
1359 l10n_util::GetStringUTF8(IDS_MINOR_SHA1_DESCRIPTION), 1359 l10n_util::GetStringUTF8(IDS_MINOR_SHA1_DESCRIPTION),
1360 security_info.cert_id)); 1360 security_info.cert_id));
1361 } 1361 }
1362 1362
1363 security_style_explanations->ran_insecure_content = 1363 security_style_explanations->ran_insecure_content =
1364 security_info.mixed_content_status == 1364 security_info.mixed_content_status ==
1365 SecurityStateModel::RAN_MIXED_CONTENT || 1365 security_state::SecurityStateModel::RAN_MIXED_CONTENT ||
1366 security_info.mixed_content_status == 1366 security_info.mixed_content_status ==
1367 SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT; 1367 security_state::SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT;
1368 security_style_explanations->displayed_insecure_content = 1368 security_style_explanations->displayed_insecure_content =
1369 security_info.mixed_content_status == 1369 security_info.mixed_content_status ==
1370 SecurityStateModel::DISPLAYED_MIXED_CONTENT || 1370 security_state::SecurityStateModel::DISPLAYED_MIXED_CONTENT ||
1371 security_info.mixed_content_status == 1371 security_info.mixed_content_status ==
1372 SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT; 1372 security_state::SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT;
1373 1373
1374 if (net::IsCertStatusError(security_info.cert_status)) { 1374 if (net::IsCertStatusError(security_info.cert_status)) {
1375 base::string16 error_string = base::UTF8ToUTF16(net::ErrorToString( 1375 base::string16 error_string = base::UTF8ToUTF16(net::ErrorToString(
1376 net::MapCertStatusToNetError(security_info.cert_status))); 1376 net::MapCertStatusToNetError(security_info.cert_status)));
1377 1377
1378 content::SecurityStyleExplanation explanation( 1378 content::SecurityStyleExplanation explanation(
1379 l10n_util::GetStringUTF8(IDS_CERTIFICATE_CHAIN_ERROR), 1379 l10n_util::GetStringUTF8(IDS_CERTIFICATE_CHAIN_ERROR),
1380 l10n_util::GetStringFUTF8( 1380 l10n_util::GetStringFUTF8(
1381 IDS_CERTIFICATE_CHAIN_ERROR_DESCRIPTION_FORMAT, error_string), 1381 IDS_CERTIFICATE_CHAIN_ERROR_DESCRIPTION_FORMAT, error_string),
1382 security_info.cert_id); 1382 security_info.cert_id);
1383 1383
1384 if (net::IsCertStatusMinorError(security_info.cert_status)) 1384 if (net::IsCertStatusMinorError(security_info.cert_status))
1385 security_style_explanations->unauthenticated_explanations.push_back( 1385 security_style_explanations->unauthenticated_explanations.push_back(
1386 explanation); 1386 explanation);
1387 else 1387 else
1388 security_style_explanations->broken_explanations.push_back(explanation); 1388 security_style_explanations->broken_explanations.push_back(explanation);
1389 } else { 1389 } else {
1390 // If the certificate does not have errors and is not using 1390 // If the certificate does not have errors and is not using
1391 // deprecated SHA1, then add an explanation that the certificate is 1391 // deprecated SHA1, then add an explanation that the certificate is
1392 // valid. 1392 // valid.
1393 if (security_info.sha1_deprecation_status == 1393 if (security_info.sha1_deprecation_status ==
1394 SecurityStateModel::NO_DEPRECATED_SHA1) { 1394 security_state::SecurityStateModel::NO_DEPRECATED_SHA1) {
1395 security_style_explanations->secure_explanations.push_back( 1395 security_style_explanations->secure_explanations.push_back(
1396 content::SecurityStyleExplanation( 1396 content::SecurityStyleExplanation(
1397 l10n_util::GetStringUTF8(IDS_VALID_SERVER_CERTIFICATE), 1397 l10n_util::GetStringUTF8(IDS_VALID_SERVER_CERTIFICATE),
1398 l10n_util::GetStringUTF8( 1398 l10n_util::GetStringUTF8(
1399 IDS_VALID_SERVER_CERTIFICATE_DESCRIPTION), 1399 IDS_VALID_SERVER_CERTIFICATE_DESCRIPTION),
1400 security_info.cert_id)); 1400 security_info.cert_id));
1401 } 1401 }
1402 } 1402 }
1403 1403
1404 if (security_info.is_secure_protocol_and_ciphersuite) { 1404 if (security_info.is_secure_protocol_and_ciphersuite) {
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after
2709 if (contents && !allow_js_access) { 2709 if (contents && !allow_js_access) {
2710 contents->web_contents()->GetController().LoadURL( 2710 contents->web_contents()->GetController().LoadURL(
2711 target_url, 2711 target_url,
2712 content::Referrer(), 2712 content::Referrer(),
2713 ui::PAGE_TRANSITION_LINK, 2713 ui::PAGE_TRANSITION_LINK,
2714 std::string()); // No extra headers. 2714 std::string()); // No extra headers.
2715 } 2715 }
2716 2716
2717 return contents != NULL; 2717 return contents != NULL;
2718 } 2718 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698