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

Unified Diff: chrome/browser/chrome_content_browser_client.cc

Issue 1905033002: PlzNavigate: Move navigation-level mixed content checks to the browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@console-security-message
Patch Set: Overall code cleanup to request reviewers to PTAL. Created 4 years, 5 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chrome_content_browser_client.cc
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index f8af92a04931b0c22929199aa1e70f96b6998325..7cf3be226b49c01fa4c8844ff2b9fce240e641ad 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -41,6 +41,8 @@
#include "chrome/browser/chrome_quota_permission_context.h"
#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
+#include "chrome/browser/content_settings/mixed_content_settings.h"
+#include "chrome/browser/content_settings/tab_specific_content_settings.h"
#include "chrome/browser/content_settings/tab_specific_content_settings.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/devtools/chrome_devtools_manager_delegate.h"
@@ -48,6 +50,7 @@
#include "chrome/browser/engagement/site_engagement_eviction_policy.h"
#include "chrome/browser/font_family_cache.h"
#include "chrome/browser/geolocation/chrome_access_token_store.h"
+#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h"
#include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
@@ -105,6 +108,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/secure_origin_whitelist.h"
+#include "chrome/common/ssl_insecure_content.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/installer/util/google_update_settings.h"
@@ -3029,6 +3033,55 @@ void ChromeContentBrowserClient::OverridePageVisibilityState(
}
}
+bool ChromeContentBrowserClient::ShouldAllowDisplayingInsecureContent(
+ bool allowed_per_settings,
+ const GURL& resource_url,
+ content::WebContents* web_contents) {
+ // Note: this implementation is a mirror of
+ // ContentSettingsObserver::allowDisplayingInsecureContent
+ ReportInsecureContent(SslInsecureContentType::DISPLAY);
+ FilteredReportInsecureContentDisplayed(resource_url);
+
+ MixedContentSettings* mixed_content_settings =
+ MixedContentSettings::FromWebContents(web_contents);
+ DCHECK(mixed_content_settings);
+ if (allowed_per_settings ||
+ mixed_content_settings->insecure_content_allowed_displaying()) {
+ return true;
+ }
+
+ InfoBarService* info_bar = InfoBarService::FromWebContents(web_contents);
+ info_bar->OnDidBlockDisplayingInsecureContent();
+ return false;
+}
+
+bool ChromeContentBrowserClient::ShouldAllowRunningInsecureContent(
+ bool allowed_per_settings,
+ const url::Origin& origin,
+ const GURL& resource_url,
+ content::WebContents* web_contents) {
+ // Note: this implementation is a mirror of
+ // ContentSettingsObserver::allowRunningInsecureContent
+ FilteredReportInsecureContentRan(resource_url);
+
+ MixedContentSettings* mixed_content_settings =
+ MixedContentSettings::FromWebContents(web_contents);
+ DCHECK(mixed_content_settings);
+ if (allowed_per_settings ||
+ mixed_content_settings->insecure_content_allowed_running()) {
+ return true;
+ }
+
+ if (!origin.host().empty()) {
+ TabSpecificContentSettings* tab_settings =
+ TabSpecificContentSettings::FromWebContents(web_contents);
+ DCHECK(tab_settings);
+ tab_settings->OnContentBlockedWithDetail(CONTENT_SETTINGS_TYPE_MIXEDSCRIPT,
+ base::UTF8ToUTF16(origin.host()));
+ }
+ return false;
+}
+
#if defined(ENABLE_WEBRTC)
void ChromeContentBrowserClient::MaybeCopyDisableWebRtcEncryptionSwitch(
base::CommandLine* to_command_line,

Powered by Google App Engine
This is Rietveld 408576698