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> |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 #include "content/public/browser/navigation_controller.h" | 182 #include "content/public/browser/navigation_controller.h" |
183 #include "content/public/browser/navigation_entry.h" | 183 #include "content/public/browser/navigation_entry.h" |
184 #include "content/public/browser/notification_details.h" | 184 #include "content/public/browser/notification_details.h" |
185 #include "content/public/browser/notification_service.h" | 185 #include "content/public/browser/notification_service.h" |
186 #include "content/public/browser/plugin_service.h" | 186 #include "content/public/browser/plugin_service.h" |
187 #include "content/public/browser/render_frame_host.h" | 187 #include "content/public/browser/render_frame_host.h" |
188 #include "content/public/browser/render_process_host.h" | 188 #include "content/public/browser/render_process_host.h" |
189 #include "content/public/browser/render_view_host.h" | 189 #include "content/public/browser/render_view_host.h" |
190 #include "content/public/browser/render_widget_host.h" | 190 #include "content/public/browser/render_widget_host.h" |
191 #include "content/public/browser/render_widget_host_view.h" | 191 #include "content/public/browser/render_widget_host_view.h" |
192 #include "content/public/browser/security_style_explanation.h" | |
193 #include "content/public/browser/security_style_explanations.h" | |
194 #include "content/public/browser/site_instance.h" | 192 #include "content/public/browser/site_instance.h" |
195 #include "content/public/browser/user_metrics.h" | 193 #include "content/public/browser/user_metrics.h" |
196 #include "content/public/browser/web_contents.h" | 194 #include "content/public/browser/web_contents.h" |
197 #include "content/public/common/content_constants.h" | 195 #include "content/public/common/content_constants.h" |
198 #include "content/public/common/content_switches.h" | 196 #include "content/public/common/content_switches.h" |
199 #include "content/public/common/page_zoom.h" | 197 #include "content/public/common/page_zoom.h" |
200 #include "content/public/common/renderer_preferences.h" | 198 #include "content/public/common/renderer_preferences.h" |
201 #include "content/public/common/ssl_status.h" | 199 #include "content/public/common/ssl_status.h" |
202 #include "content/public/common/webplugininfo.h" | 200 #include "content/public/common/webplugininfo.h" |
203 #include "extensions/browser/extension_prefs.h" | 201 #include "extensions/browser/extension_prefs.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 BrowserWindow* CreateBrowserWindow(Browser* browser) { | 260 BrowserWindow* CreateBrowserWindow(Browser* browser) { |
263 return BrowserWindow::CreateBrowserWindow(browser); | 261 return BrowserWindow::CreateBrowserWindow(browser); |
264 } | 262 } |
265 | 263 |
266 // Is the fast tab unload experiment enabled? | 264 // Is the fast tab unload experiment enabled? |
267 bool IsFastTabUnloadEnabled() { | 265 bool IsFastTabUnloadEnabled() { |
268 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 266 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
269 switches::kEnableFastUnload); | 267 switches::kEnableFastUnload); |
270 } | 268 } |
271 | 269 |
272 // Note: This is a lossy operation. Not all of the policies that can be | |
273 // expressed by a SecurityLevel (a //chrome concept) can be expressed by | |
274 // a content::SecurityStyle. | |
275 content::SecurityStyle SecurityLevelToSecurityStyle( | |
276 SecurityStateModel::SecurityLevel security_level) { | |
277 switch (security_level) { | |
278 case SecurityStateModel::NONE: | |
279 return content::SECURITY_STYLE_UNAUTHENTICATED; | |
280 case SecurityStateModel::SECURITY_WARNING: | |
281 case SecurityStateModel::SECURITY_POLICY_WARNING: | |
282 return content::SECURITY_STYLE_WARNING; | |
283 case SecurityStateModel::EV_SECURE: | |
284 case SecurityStateModel::SECURE: | |
285 return content::SECURITY_STYLE_AUTHENTICATED; | |
286 case SecurityStateModel::SECURITY_ERROR: | |
287 return content::SECURITY_STYLE_AUTHENTICATION_BROKEN; | |
288 } | |
289 | |
290 NOTREACHED(); | |
291 return content::SECURITY_STYLE_UNKNOWN; | |
292 } | |
293 | |
294 } // namespace | 270 } // namespace |
295 | 271 |
296 //////////////////////////////////////////////////////////////////////////////// | 272 //////////////////////////////////////////////////////////////////////////////// |
297 // Browser, CreateParams: | 273 // Browser, CreateParams: |
298 | 274 |
299 Browser::CreateParams::CreateParams(Profile* profile) | 275 Browser::CreateParams::CreateParams(Profile* profile) |
300 : type(TYPE_TABBED), | 276 : type(TYPE_TABBED), |
301 profile(profile), | 277 profile(profile), |
302 trusted_source(false), | 278 trusted_source(false), |
303 initial_show_state(ui::SHOW_STATE_DEFAULT), | 279 initial_show_state(ui::SHOW_STATE_DEFAULT), |
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 } | 1289 } |
1314 return true; | 1290 return true; |
1315 } | 1291 } |
1316 | 1292 |
1317 content::SecurityStyle Browser::GetSecurityStyle( | 1293 content::SecurityStyle Browser::GetSecurityStyle( |
1318 WebContents* web_contents, | 1294 WebContents* web_contents, |
1319 content::SecurityStyleExplanations* security_style_explanations) { | 1295 content::SecurityStyleExplanations* security_style_explanations) { |
1320 ChromeSecurityStateModelClient* model_client = | 1296 ChromeSecurityStateModelClient* model_client = |
1321 ChromeSecurityStateModelClient::FromWebContents(web_contents); | 1297 ChromeSecurityStateModelClient::FromWebContents(web_contents); |
1322 DCHECK(model_client); | 1298 DCHECK(model_client); |
1323 const SecurityStateModel::SecurityInfo& security_info = | 1299 return model_client->GetSecurityStyle(model_client->GetSecurityInfo(), |
1324 model_client->GetSecurityInfo(); | 1300 security_style_explanations); |
1325 | |
1326 const content::SecurityStyle security_style = | |
1327 SecurityLevelToSecurityStyle(security_info.security_level); | |
1328 | |
1329 security_style_explanations->ran_insecure_content_style = | |
1330 SecurityLevelToSecurityStyle( | |
1331 SecurityStateModel::kRanInsecureContentLevel); | |
1332 security_style_explanations->displayed_insecure_content_style = | |
1333 SecurityLevelToSecurityStyle( | |
1334 SecurityStateModel::kDisplayedInsecureContentLevel); | |
1335 | |
1336 // Check if the page is HTTP; if so, no explanations are needed. Note | |
1337 // that SECURITY_STYLE_UNAUTHENTICATED does not necessarily mean that | |
1338 // the page is loaded over HTTP, because the security style merely | |
1339 // represents how the embedder wishes to display the security state of | |
1340 // the page, and the embedder can choose to display HTTPS page as HTTP | |
1341 // if it wants to (for example, displaying deprecated crypto | |
1342 // algorithms with the same UI treatment as HTTP pages). | |
1343 security_style_explanations->scheme_is_cryptographic = | |
1344 security_info.scheme_is_cryptographic; | |
1345 if (!security_info.scheme_is_cryptographic) { | |
1346 return security_style; | |
1347 } | |
1348 | |
1349 if (security_info.sha1_deprecation_status == | |
1350 SecurityStateModel::DEPRECATED_SHA1_MAJOR) { | |
1351 security_style_explanations->broken_explanations.push_back( | |
1352 content::SecurityStyleExplanation( | |
1353 l10n_util::GetStringUTF8(IDS_MAJOR_SHA1), | |
1354 l10n_util::GetStringUTF8(IDS_MAJOR_SHA1_DESCRIPTION), | |
1355 security_info.cert_id)); | |
1356 } else if (security_info.sha1_deprecation_status == | |
1357 SecurityStateModel::DEPRECATED_SHA1_MINOR) { | |
1358 security_style_explanations->unauthenticated_explanations.push_back( | |
1359 content::SecurityStyleExplanation( | |
1360 l10n_util::GetStringUTF8(IDS_MINOR_SHA1), | |
1361 l10n_util::GetStringUTF8(IDS_MINOR_SHA1_DESCRIPTION), | |
1362 security_info.cert_id)); | |
1363 } | |
1364 | |
1365 security_style_explanations->ran_insecure_content = | |
1366 security_info.mixed_content_status == | |
1367 SecurityStateModel::RAN_MIXED_CONTENT || | |
1368 security_info.mixed_content_status == | |
1369 SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT; | |
1370 security_style_explanations->displayed_insecure_content = | |
1371 security_info.mixed_content_status == | |
1372 SecurityStateModel::DISPLAYED_MIXED_CONTENT || | |
1373 security_info.mixed_content_status == | |
1374 SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT; | |
1375 | |
1376 if (net::IsCertStatusError(security_info.cert_status)) { | |
1377 base::string16 error_string = base::UTF8ToUTF16(net::ErrorToString( | |
1378 net::MapCertStatusToNetError(security_info.cert_status))); | |
1379 | |
1380 content::SecurityStyleExplanation explanation( | |
1381 l10n_util::GetStringUTF8(IDS_CERTIFICATE_CHAIN_ERROR), | |
1382 l10n_util::GetStringFUTF8( | |
1383 IDS_CERTIFICATE_CHAIN_ERROR_DESCRIPTION_FORMAT, error_string), | |
1384 security_info.cert_id); | |
1385 | |
1386 if (net::IsCertStatusMinorError(security_info.cert_status)) | |
1387 security_style_explanations->unauthenticated_explanations.push_back( | |
1388 explanation); | |
1389 else | |
1390 security_style_explanations->broken_explanations.push_back(explanation); | |
1391 } else { | |
1392 // If the certificate does not have errors and is not using | |
1393 // deprecated SHA1, then add an explanation that the certificate is | |
1394 // valid. | |
1395 if (security_info.sha1_deprecation_status == | |
1396 SecurityStateModel::NO_DEPRECATED_SHA1) { | |
1397 security_style_explanations->secure_explanations.push_back( | |
1398 content::SecurityStyleExplanation( | |
1399 l10n_util::GetStringUTF8(IDS_VALID_SERVER_CERTIFICATE), | |
1400 l10n_util::GetStringUTF8( | |
1401 IDS_VALID_SERVER_CERTIFICATE_DESCRIPTION), | |
1402 security_info.cert_id)); | |
1403 } | |
1404 } | |
1405 | |
1406 if (security_info.is_secure_protocol_and_ciphersuite) { | |
1407 security_style_explanations->secure_explanations.push_back( | |
1408 content::SecurityStyleExplanation( | |
1409 l10n_util::GetStringUTF8(IDS_SECURE_PROTOCOL_AND_CIPHERSUITE), | |
1410 l10n_util::GetStringUTF8( | |
1411 IDS_SECURE_PROTOCOL_AND_CIPHERSUITE_DESCRIPTION))); | |
1412 } | |
1413 | |
1414 return security_style; | |
1415 } | 1301 } |
1416 | 1302 |
1417 void Browser::ShowCertificateViewerInDevTools( | 1303 void Browser::ShowCertificateViewerInDevTools( |
1418 content::WebContents* web_contents, int cert_id) { | 1304 content::WebContents* web_contents, int cert_id) { |
1419 DevToolsWindow* devtools_window = | 1305 DevToolsWindow* devtools_window = |
1420 DevToolsWindow::GetInstanceForInspectedWebContents(web_contents); | 1306 DevToolsWindow::GetInstanceForInspectedWebContents(web_contents); |
1421 if (devtools_window) | 1307 if (devtools_window) |
1422 devtools_window->ShowCertificateViewer(cert_id); | 1308 devtools_window->ShowCertificateViewer(cert_id); |
1423 } | 1309 } |
1424 | 1310 |
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2723 if (contents && !allow_js_access) { | 2609 if (contents && !allow_js_access) { |
2724 contents->web_contents()->GetController().LoadURL( | 2610 contents->web_contents()->GetController().LoadURL( |
2725 target_url, | 2611 target_url, |
2726 content::Referrer(), | 2612 content::Referrer(), |
2727 ui::PAGE_TRANSITION_LINK, | 2613 ui::PAGE_TRANSITION_LINK, |
2728 std::string()); // No extra headers. | 2614 std::string()); // No extra headers. |
2729 } | 2615 } |
2730 | 2616 |
2731 return contents != NULL; | 2617 return contents != NULL; |
2732 } | 2618 } |
OLD | NEW |