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

Side by Side Diff: chrome/renderer/content_settings_observer.cc

Issue 1583813003: Remove obsolete histogram values from SSL.InsecureContent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: webview override Created 4 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/renderer/content_settings_observer.h" 5 #include "chrome/renderer/content_settings_observer.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "components/content_settings/content/common/content_settings_messages.h " 9 #include "components/content_settings/content/common/content_settings_messages.h "
10 #include "content/public/common/url_constants.h" 10 #include "content/public/common/url_constants.h"
(...skipping 25 matching lines...) Expand all
36 using blink::WebFrame; 36 using blink::WebFrame;
37 using blink::WebSecurityOrigin; 37 using blink::WebSecurityOrigin;
38 using blink::WebString; 38 using blink::WebString;
39 using blink::WebURL; 39 using blink::WebURL;
40 using blink::WebView; 40 using blink::WebView;
41 using content::DocumentState; 41 using content::DocumentState;
42 using content::NavigationState; 42 using content::NavigationState;
43 43
44 namespace { 44 namespace {
45 45
46 // This enum is histogrammed, so do not add, reorder, or remove values.
46 enum { 47 enum {
47 INSECURE_CONTENT_DISPLAY = 0, 48 INSECURE_CONTENT_DISPLAY = 0,
48 INSECURE_CONTENT_DISPLAY_HOST_GOOGLE, 49 INSECURE_CONTENT_DISPLAY_HOST_GOOGLE,
49 INSECURE_CONTENT_DISPLAY_HOST_WWW_GOOGLE, 50 INSECURE_CONTENT_DISPLAY_HOST_WWW_GOOGLE,
50 INSECURE_CONTENT_DISPLAY_HTML, 51 INSECURE_CONTENT_DISPLAY_HTML,
51 INSECURE_CONTENT_RUN, 52 INSECURE_CONTENT_RUN,
52 INSECURE_CONTENT_RUN_HOST_GOOGLE, 53 INSECURE_CONTENT_RUN_HOST_GOOGLE,
53 INSECURE_CONTENT_RUN_HOST_WWW_GOOGLE, 54 INSECURE_CONTENT_RUN_HOST_WWW_GOOGLE,
54 INSECURE_CONTENT_RUN_TARGET_YOUTUBE, 55 INSECURE_CONTENT_RUN_TARGET_YOUTUBE,
55 INSECURE_CONTENT_RUN_JS, 56 INSECURE_CONTENT_RUN_JS,
(...skipping 21 matching lines...) Expand all
77 INSECURE_CONTENT_DISPLAY_HOST_MAPS_GOOGLE, 78 INSECURE_CONTENT_DISPLAY_HOST_MAPS_GOOGLE,
78 INSECURE_CONTENT_RUN_HOST_MAPS_GOOGLE, 79 INSECURE_CONTENT_RUN_HOST_MAPS_GOOGLE,
79 INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_SUPPORT, 80 INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_SUPPORT,
80 INSECURE_CONTENT_RUN_HOST_GOOGLE_SUPPORT, 81 INSECURE_CONTENT_RUN_HOST_GOOGLE_SUPPORT,
81 INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_INTL, 82 INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_INTL,
82 INSECURE_CONTENT_RUN_HOST_GOOGLE_INTL, 83 INSECURE_CONTENT_RUN_HOST_GOOGLE_INTL,
83 INSECURE_CONTENT_NUM_EVENTS 84 INSECURE_CONTENT_NUM_EVENTS
84 }; 85 };
85 86
86 // Constants for UMA statistic collection. 87 // Constants for UMA statistic collection.
87 static const char kWWWDotGoogleDotCom[] = "www.google.com";
88 static const char kMailDotGoogleDotCom[] = "mail.google.com";
89 static const char kPlusDotGoogleDotCom[] = "plus.google.com";
90 static const char kDocsDotGoogleDotCom[] = "docs.google.com";
91 static const char kSitesDotGoogleDotCom[] = "sites.google.com";
92 static const char kPicasawebDotGoogleDotCom[] = "picasaweb.google.com";
93 static const char kCodeDotGoogleDotCom[] = "code.google.com";
94 static const char kGroupsDotGoogleDotCom[] = "groups.google.com";
95 static const char kMapsDotGoogleDotCom[] = "maps.google.com";
96 static const char kWWWDotYoutubeDotCom[] = "www.youtube.com";
97 static const char kDotGoogleUserContentDotCom[] = ".googleusercontent.com";
98 static const char kGoogleReaderPathPrefix[] = "/reader/";
99 static const char kGoogleSupportPathPrefix[] = "/support/";
100 static const char kGoogleIntlPathPrefix[] = "/intl/";
101 static const char kDotJS[] = ".js"; 88 static const char kDotJS[] = ".js";
102 static const char kDotCSS[] = ".css"; 89 static const char kDotCSS[] = ".css";
103 static const char kDotSWF[] = ".swf"; 90 static const char kDotSWF[] = ".swf";
104 static const char kDotHTML[] = ".html"; 91 static const char kDotHTML[] = ".html";
105 92
106 // Constants for mixed-content blocking.
107 static const char kGoogleDotCom[] = "google.com";
108
109 static bool IsHostInDomain(const std::string& host, const std::string& domain) {
110 return (base::EndsWith(host, domain, base::CompareCase::INSENSITIVE_ASCII) &&
111 (host.length() == domain.length() ||
112 (host.length() > domain.length() &&
113 host[host.length() - domain.length() - 1] == '.')));
114 }
115
116 GURL GetOriginOrURL(const WebFrame* frame) { 93 GURL GetOriginOrURL(const WebFrame* frame) {
117 WebString top_origin = frame->top()->securityOrigin().toString(); 94 WebString top_origin = frame->top()->securityOrigin().toString();
118 // The |top_origin| is unique ("null") e.g., for file:// URLs. Use the 95 // The |top_origin| is unique ("null") e.g., for file:// URLs. Use the
119 // document URL as the primary URL in those cases. 96 // document URL as the primary URL in those cases.
120 // TODO(alexmos): This is broken for --site-per-process, since top() can be a 97 // TODO(alexmos): This is broken for --site-per-process, since top() can be a
121 // WebRemoteFrame which does not have a document(), and the WebRemoteFrame's 98 // WebRemoteFrame which does not have a document(), and the WebRemoteFrame's
122 // URL is not replicated. 99 // URL is not replicated.
123 if (top_origin == "null") 100 if (top_origin == "null")
124 return frame->top()->document().url(); 101 return frame->top()->document().url();
125 return GURL(top_origin); 102 return GURL(top_origin);
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 return IsPlatformApp() ? false : default_value; 436 return IsPlatformApp() ? false : default_value;
460 } 437 }
461 438
462 static void SendInsecureContentSignal(int signal) { 439 static void SendInsecureContentSignal(int signal) {
463 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", signal, 440 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", signal,
464 INSECURE_CONTENT_NUM_EVENTS); 441 INSECURE_CONTENT_NUM_EVENTS);
465 } 442 }
466 443
467 bool ContentSettingsObserver::allowDisplayingInsecureContent( 444 bool ContentSettingsObserver::allowDisplayingInsecureContent(
468 bool allowed_per_settings, 445 bool allowed_per_settings,
469 const blink::WebSecurityOrigin& origin,
470 const blink::WebURL& resource_url) { 446 const blink::WebURL& resource_url) {
471 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY); 447 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY);
472 448
473 std::string origin_host(origin.host().utf8());
474 WebFrame* frame = render_frame()->GetWebFrame();
475 GURL frame_gurl(frame->document().url());
476 if (IsHostInDomain(origin_host, kGoogleDotCom)) {
477 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_GOOGLE);
478 if (base::StartsWith(frame_gurl.path(), kGoogleSupportPathPrefix,
479 base::CompareCase::INSENSITIVE_ASCII)) {
480 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_SUPPORT);
481 } else if (base::StartsWith(frame_gurl.path(), kGoogleIntlPathPrefix,
482 base::CompareCase::INSENSITIVE_ASCII)) {
483 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_INTL);
484 }
485 }
486
487 if (origin_host == kWWWDotGoogleDotCom) {
488 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_WWW_GOOGLE);
489 if (base::StartsWith(frame_gurl.path(), kGoogleReaderPathPrefix,
490 base::CompareCase::INSENSITIVE_ASCII))
491 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_READER);
492 } else if (origin_host == kMailDotGoogleDotCom) {
493 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_MAIL_GOOGLE);
494 } else if (origin_host == kPlusDotGoogleDotCom) {
495 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_PLUS_GOOGLE);
496 } else if (origin_host == kDocsDotGoogleDotCom) {
497 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_DOCS_GOOGLE);
498 } else if (origin_host == kSitesDotGoogleDotCom) {
499 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_SITES_GOOGLE);
500 } else if (origin_host == kPicasawebDotGoogleDotCom) {
501 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_PICASAWEB_GOOGLE);
502 } else if (origin_host == kCodeDotGoogleDotCom) {
503 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_CODE_GOOGLE);
504 } else if (origin_host == kGroupsDotGoogleDotCom) {
505 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_GROUPS_GOOGLE);
506 } else if (origin_host == kMapsDotGoogleDotCom) {
507 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_MAPS_GOOGLE);
508 } else if (origin_host == kWWWDotYoutubeDotCom) {
509 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_YOUTUBE);
510 }
511
512 GURL resource_gurl(resource_url); 449 GURL resource_gurl(resource_url);
513 if (base::EndsWith(resource_gurl.path(), kDotHTML, 450 if (base::EndsWith(resource_gurl.path(), kDotHTML,
514 base::CompareCase::INSENSITIVE_ASCII)) 451 base::CompareCase::INSENSITIVE_ASCII))
515 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HTML); 452 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HTML);
516 453
517 if (allowed_per_settings || allow_displaying_insecure_content_) 454 if (allowed_per_settings || allow_displaying_insecure_content_)
518 return true; 455 return true;
519 456
520 Send(new ChromeViewHostMsg_DidBlockDisplayingInsecureContent(routing_id())); 457 Send(new ChromeViewHostMsg_DidBlockDisplayingInsecureContent(routing_id()));
estark 2016/01/14 20:59:41 alexmos: in a different CL you had asked this:
alexmos 2016/01/14 22:23:01 Sorry, I didn't phrase that question correctly. :)
521 458
522 return false; 459 return false;
523 } 460 }
524 461
525 bool ContentSettingsObserver::allowRunningInsecureContent( 462 bool ContentSettingsObserver::allowRunningInsecureContent(
526 bool allowed_per_settings, 463 bool allowed_per_settings,
527 const blink::WebSecurityOrigin& origin, 464 const blink::WebSecurityOrigin& origin,
528 const blink::WebURL& resource_url) { 465 const blink::WebURL& resource_url) {
529 std::string origin_host(origin.host().utf8());
530 WebFrame* frame = render_frame()->GetWebFrame();
531 GURL frame_gurl(frame->document().url());
532 DCHECK_EQ(frame_gurl.host(), origin_host);
533
534 bool is_google = IsHostInDomain(origin_host, kGoogleDotCom);
535 if (is_google) {
536 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLE);
537 if (base::StartsWith(frame_gurl.path(), kGoogleSupportPathPrefix,
538 base::CompareCase::INSENSITIVE_ASCII)) {
539 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLE_SUPPORT);
540 } else if (base::StartsWith(frame_gurl.path(), kGoogleIntlPathPrefix,
541 base::CompareCase::INSENSITIVE_ASCII)) {
542 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLE_INTL);
543 }
544 }
545
546 if (origin_host == kWWWDotGoogleDotCom) {
547 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_WWW_GOOGLE);
548 if (base::StartsWith(frame_gurl.path(), kGoogleReaderPathPrefix,
549 base::CompareCase::INSENSITIVE_ASCII))
550 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLE_READER);
551 } else if (origin_host == kMailDotGoogleDotCom) {
552 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_MAIL_GOOGLE);
553 } else if (origin_host == kPlusDotGoogleDotCom) {
554 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_PLUS_GOOGLE);
555 } else if (origin_host == kDocsDotGoogleDotCom) {
556 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_DOCS_GOOGLE);
557 } else if (origin_host == kSitesDotGoogleDotCom) {
558 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_SITES_GOOGLE);
559 } else if (origin_host == kPicasawebDotGoogleDotCom) {
560 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_PICASAWEB_GOOGLE);
561 } else if (origin_host == kCodeDotGoogleDotCom) {
562 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_CODE_GOOGLE);
563 } else if (origin_host == kGroupsDotGoogleDotCom) {
564 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GROUPS_GOOGLE);
565 } else if (origin_host == kMapsDotGoogleDotCom) {
566 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_MAPS_GOOGLE);
567 } else if (origin_host == kWWWDotYoutubeDotCom) {
568 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_YOUTUBE);
569 } else if (base::EndsWith(origin_host, kDotGoogleUserContentDotCom,
570 base::CompareCase::INSENSITIVE_ASCII)) {
571 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLEUSERCONTENT);
572 }
573
574 GURL resource_gurl(resource_url); 466 GURL resource_gurl(resource_url);
575 if (resource_gurl.host() == kWWWDotYoutubeDotCom)
576 SendInsecureContentSignal(INSECURE_CONTENT_RUN_TARGET_YOUTUBE);
577
578 if (base::EndsWith(resource_gurl.path(), kDotJS, 467 if (base::EndsWith(resource_gurl.path(), kDotJS,
579 base::CompareCase::INSENSITIVE_ASCII)) 468 base::CompareCase::INSENSITIVE_ASCII))
580 SendInsecureContentSignal(INSECURE_CONTENT_RUN_JS); 469 SendInsecureContentSignal(INSECURE_CONTENT_RUN_JS);
581 else if (base::EndsWith(resource_gurl.path(), kDotCSS, 470 else if (base::EndsWith(resource_gurl.path(), kDotCSS,
582 base::CompareCase::INSENSITIVE_ASCII)) 471 base::CompareCase::INSENSITIVE_ASCII))
583 SendInsecureContentSignal(INSECURE_CONTENT_RUN_CSS); 472 SendInsecureContentSignal(INSECURE_CONTENT_RUN_CSS);
584 else if (base::EndsWith(resource_gurl.path(), kDotSWF, 473 else if (base::EndsWith(resource_gurl.path(), kDotSWF,
585 base::CompareCase::INSENSITIVE_ASCII)) 474 base::CompareCase::INSENSITIVE_ASCII))
586 SendInsecureContentSignal(INSECURE_CONTENT_RUN_SWF); 475 SendInsecureContentSignal(INSECURE_CONTENT_RUN_SWF);
587 476
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 620
732 // If the scheme is file:, an empty file name indicates a directory listing, 621 // If the scheme is file:, an empty file name indicates a directory listing,
733 // which requires JavaScript to function properly. 622 // which requires JavaScript to function properly.
734 if (base::EqualsASCII(protocol, url::kFileScheme)) { 623 if (base::EqualsASCII(protocol, url::kFileScheme)) {
735 return document_url.SchemeIs(url::kFileScheme) && 624 return document_url.SchemeIs(url::kFileScheme) &&
736 document_url.ExtractFileName().empty(); 625 document_url.ExtractFileName().empty();
737 } 626 }
738 627
739 return false; 628 return false;
740 } 629 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698