Chromium Code Reviews| Index: chrome/renderer/content_settings_observer.cc |
| diff --git a/chrome/renderer/content_settings_observer.cc b/chrome/renderer/content_settings_observer.cc |
| index 1e00b6cb13b413fc408f4680a4760943f5e11a2a..04068d2da92befe1fec150185a4877525fa9f671 100644 |
| --- a/chrome/renderer/content_settings_observer.cc |
| +++ b/chrome/renderer/content_settings_observer.cc |
| @@ -5,7 +5,6 @@ |
| #include "chrome/renderer/content_settings_observer.h" |
| #include "base/command_line.h" |
| -#include "base/metrics/histogram.h" |
| #include "components/content_settings/content/common/content_settings_messages.h" |
| #include "content/public/common/url_constants.h" |
| #include "content/public/renderer/document_state.h" |
| @@ -43,76 +42,6 @@ using content::NavigationState; |
| namespace { |
| -enum { |
| - INSECURE_CONTENT_DISPLAY = 0, |
| - INSECURE_CONTENT_DISPLAY_HOST_GOOGLE, |
| - INSECURE_CONTENT_DISPLAY_HOST_WWW_GOOGLE, |
| - INSECURE_CONTENT_DISPLAY_HTML, |
| - INSECURE_CONTENT_RUN, |
| - INSECURE_CONTENT_RUN_HOST_GOOGLE, |
| - INSECURE_CONTENT_RUN_HOST_WWW_GOOGLE, |
| - INSECURE_CONTENT_RUN_TARGET_YOUTUBE, |
| - INSECURE_CONTENT_RUN_JS, |
| - INSECURE_CONTENT_RUN_CSS, |
| - INSECURE_CONTENT_RUN_SWF, |
| - INSECURE_CONTENT_DISPLAY_HOST_YOUTUBE, |
| - INSECURE_CONTENT_RUN_HOST_YOUTUBE, |
| - INSECURE_CONTENT_RUN_HOST_GOOGLEUSERCONTENT, |
| - INSECURE_CONTENT_DISPLAY_HOST_MAIL_GOOGLE, |
| - INSECURE_CONTENT_RUN_HOST_MAIL_GOOGLE, |
| - INSECURE_CONTENT_DISPLAY_HOST_PLUS_GOOGLE, |
| - INSECURE_CONTENT_RUN_HOST_PLUS_GOOGLE, |
| - INSECURE_CONTENT_DISPLAY_HOST_DOCS_GOOGLE, |
| - INSECURE_CONTENT_RUN_HOST_DOCS_GOOGLE, |
| - INSECURE_CONTENT_DISPLAY_HOST_SITES_GOOGLE, |
| - INSECURE_CONTENT_RUN_HOST_SITES_GOOGLE, |
| - INSECURE_CONTENT_DISPLAY_HOST_PICASAWEB_GOOGLE, |
| - INSECURE_CONTENT_RUN_HOST_PICASAWEB_GOOGLE, |
| - INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_READER, |
| - INSECURE_CONTENT_RUN_HOST_GOOGLE_READER, |
| - INSECURE_CONTENT_DISPLAY_HOST_CODE_GOOGLE, |
| - INSECURE_CONTENT_RUN_HOST_CODE_GOOGLE, |
| - INSECURE_CONTENT_DISPLAY_HOST_GROUPS_GOOGLE, |
| - INSECURE_CONTENT_RUN_HOST_GROUPS_GOOGLE, |
| - INSECURE_CONTENT_DISPLAY_HOST_MAPS_GOOGLE, |
| - INSECURE_CONTENT_RUN_HOST_MAPS_GOOGLE, |
| - INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_SUPPORT, |
| - INSECURE_CONTENT_RUN_HOST_GOOGLE_SUPPORT, |
| - INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_INTL, |
| - INSECURE_CONTENT_RUN_HOST_GOOGLE_INTL, |
| - INSECURE_CONTENT_NUM_EVENTS |
| -}; |
| - |
| -// Constants for UMA statistic collection. |
| -static const char kWWWDotGoogleDotCom[] = "www.google.com"; |
| -static const char kMailDotGoogleDotCom[] = "mail.google.com"; |
| -static const char kPlusDotGoogleDotCom[] = "plus.google.com"; |
| -static const char kDocsDotGoogleDotCom[] = "docs.google.com"; |
| -static const char kSitesDotGoogleDotCom[] = "sites.google.com"; |
| -static const char kPicasawebDotGoogleDotCom[] = "picasaweb.google.com"; |
| -static const char kCodeDotGoogleDotCom[] = "code.google.com"; |
| -static const char kGroupsDotGoogleDotCom[] = "groups.google.com"; |
| -static const char kMapsDotGoogleDotCom[] = "maps.google.com"; |
| -static const char kWWWDotYoutubeDotCom[] = "www.youtube.com"; |
| -static const char kDotGoogleUserContentDotCom[] = ".googleusercontent.com"; |
| -static const char kGoogleReaderPathPrefix[] = "/reader/"; |
| -static const char kGoogleSupportPathPrefix[] = "/support/"; |
| -static const char kGoogleIntlPathPrefix[] = "/intl/"; |
| -static const char kDotJS[] = ".js"; |
| -static const char kDotCSS[] = ".css"; |
| -static const char kDotSWF[] = ".swf"; |
| -static const char kDotHTML[] = ".html"; |
| - |
| -// Constants for mixed-content blocking. |
| -static const char kGoogleDotCom[] = "google.com"; |
| - |
| -static bool IsHostInDomain(const std::string& host, const std::string& domain) { |
| - return (base::EndsWith(host, domain, base::CompareCase::INSENSITIVE_ASCII) && |
| - (host.length() == domain.length() || |
| - (host.length() > domain.length() && |
| - host[host.length() - domain.length() - 1] == '.'))); |
| -} |
| - |
| GURL GetOriginOrURL(const WebFrame* frame) { |
| WebString top_origin = frame->top()->securityOrigin().toString(); |
| // The |top_origin| is unique ("null") e.g., for file:// URLs. Use the |
| @@ -459,66 +388,13 @@ bool ContentSettingsObserver::allowMutationEvents(bool default_value) { |
| return IsPlatformApp() ? false : default_value; |
| } |
| -static void SendInsecureContentSignal(int signal) { |
| - UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", signal, |
| - INSECURE_CONTENT_NUM_EVENTS); |
| -} |
| - |
| bool ContentSettingsObserver::allowDisplayingInsecureContent( |
| bool allowed_per_settings, |
| const blink::WebSecurityOrigin& origin, |
| const blink::WebURL& resource_url) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY); |
| - |
| - std::string origin_host(origin.host().utf8()); |
| - WebFrame* frame = render_frame()->GetWebFrame(); |
| - GURL frame_gurl(frame->document().url()); |
| - if (IsHostInDomain(origin_host, kGoogleDotCom)) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_GOOGLE); |
| - if (base::StartsWith(frame_gurl.path(), kGoogleSupportPathPrefix, |
| - base::CompareCase::INSENSITIVE_ASCII)) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_SUPPORT); |
| - } else if (base::StartsWith(frame_gurl.path(), kGoogleIntlPathPrefix, |
| - base::CompareCase::INSENSITIVE_ASCII)) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_INTL); |
| - } |
| - } |
| - |
| - if (origin_host == kWWWDotGoogleDotCom) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_WWW_GOOGLE); |
| - if (base::StartsWith(frame_gurl.path(), kGoogleReaderPathPrefix, |
| - base::CompareCase::INSENSITIVE_ASCII)) |
| - SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_READER); |
| - } else if (origin_host == kMailDotGoogleDotCom) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_MAIL_GOOGLE); |
| - } else if (origin_host == kPlusDotGoogleDotCom) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_PLUS_GOOGLE); |
| - } else if (origin_host == kDocsDotGoogleDotCom) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_DOCS_GOOGLE); |
| - } else if (origin_host == kSitesDotGoogleDotCom) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_SITES_GOOGLE); |
| - } else if (origin_host == kPicasawebDotGoogleDotCom) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_PICASAWEB_GOOGLE); |
| - } else if (origin_host == kCodeDotGoogleDotCom) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_CODE_GOOGLE); |
| - } else if (origin_host == kGroupsDotGoogleDotCom) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_GROUPS_GOOGLE); |
| - } else if (origin_host == kMapsDotGoogleDotCom) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_MAPS_GOOGLE); |
| - } else if (origin_host == kWWWDotYoutubeDotCom) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_YOUTUBE); |
| - } |
| - |
| - GURL resource_gurl(resource_url); |
| - if (base::EndsWith(resource_gurl.path(), kDotHTML, |
| - base::CompareCase::INSENSITIVE_ASCII)) |
| - SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HTML); |
| - |
| if (allowed_per_settings || allow_displaying_insecure_content_) |
| return true; |
| - |
| Send(new ChromeViewHostMsg_DidBlockDisplayingInsecureContent(routing_id())); |
|
alexmos
2016/01/09 01:39:02
Just curious, how does this still work once you ch
|
| - |
| return false; |
| } |
| @@ -526,70 +402,10 @@ bool ContentSettingsObserver::allowRunningInsecureContent( |
| bool allowed_per_settings, |
| const blink::WebSecurityOrigin& origin, |
| const blink::WebURL& resource_url) { |
| - std::string origin_host(origin.host().utf8()); |
| - WebFrame* frame = render_frame()->GetWebFrame(); |
| - GURL frame_gurl(frame->document().url()); |
| - DCHECK_EQ(frame_gurl.host(), origin_host); |
| - |
| - bool is_google = IsHostInDomain(origin_host, kGoogleDotCom); |
| - if (is_google) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLE); |
| - if (base::StartsWith(frame_gurl.path(), kGoogleSupportPathPrefix, |
| - base::CompareCase::INSENSITIVE_ASCII)) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLE_SUPPORT); |
| - } else if (base::StartsWith(frame_gurl.path(), kGoogleIntlPathPrefix, |
| - base::CompareCase::INSENSITIVE_ASCII)) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLE_INTL); |
| - } |
| - } |
| - |
| - if (origin_host == kWWWDotGoogleDotCom) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_WWW_GOOGLE); |
| - if (base::StartsWith(frame_gurl.path(), kGoogleReaderPathPrefix, |
| - base::CompareCase::INSENSITIVE_ASCII)) |
| - SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLE_READER); |
| - } else if (origin_host == kMailDotGoogleDotCom) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_MAIL_GOOGLE); |
| - } else if (origin_host == kPlusDotGoogleDotCom) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_PLUS_GOOGLE); |
| - } else if (origin_host == kDocsDotGoogleDotCom) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_DOCS_GOOGLE); |
| - } else if (origin_host == kSitesDotGoogleDotCom) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_SITES_GOOGLE); |
| - } else if (origin_host == kPicasawebDotGoogleDotCom) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_PICASAWEB_GOOGLE); |
| - } else if (origin_host == kCodeDotGoogleDotCom) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_CODE_GOOGLE); |
| - } else if (origin_host == kGroupsDotGoogleDotCom) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GROUPS_GOOGLE); |
| - } else if (origin_host == kMapsDotGoogleDotCom) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_MAPS_GOOGLE); |
| - } else if (origin_host == kWWWDotYoutubeDotCom) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_YOUTUBE); |
| - } else if (base::EndsWith(origin_host, kDotGoogleUserContentDotCom, |
| - base::CompareCase::INSENSITIVE_ASCII)) { |
| - SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLEUSERCONTENT); |
| - } |
| - |
| - GURL resource_gurl(resource_url); |
| - if (resource_gurl.host() == kWWWDotYoutubeDotCom) |
| - SendInsecureContentSignal(INSECURE_CONTENT_RUN_TARGET_YOUTUBE); |
| - |
| - if (base::EndsWith(resource_gurl.path(), kDotJS, |
| - base::CompareCase::INSENSITIVE_ASCII)) |
| - SendInsecureContentSignal(INSECURE_CONTENT_RUN_JS); |
| - else if (base::EndsWith(resource_gurl.path(), kDotCSS, |
| - base::CompareCase::INSENSITIVE_ASCII)) |
| - SendInsecureContentSignal(INSECURE_CONTENT_RUN_CSS); |
| - else if (base::EndsWith(resource_gurl.path(), kDotSWF, |
| - base::CompareCase::INSENSITIVE_ASCII)) |
| - SendInsecureContentSignal(INSECURE_CONTENT_RUN_SWF); |
| - |
| if (!allow_running_insecure_content_ && !allowed_per_settings) { |
| DidBlockContentType(CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, origin.host()); |
| return false; |
| } |
| - |
| return true; |
| } |