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

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

Issue 8400043: Simplify and shrink the UMA reporting code for mixed content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/chrome_render_view_observer.h" 5 #include "chrome/renderer/chrome_render_view_observer.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 } 435 }
436 436
437 bool ChromeRenderViewObserver::allowWriteToClipboard(WebFrame* frame, 437 bool ChromeRenderViewObserver::allowWriteToClipboard(WebFrame* frame,
438 bool default_value) { 438 bool default_value) {
439 bool allowed = false; 439 bool allowed = false;
440 Send(new ChromeViewHostMsg_CanTriggerClipboardWrite( 440 Send(new ChromeViewHostMsg_CanTriggerClipboardWrite(
441 routing_id(), frame->document().url(), &allowed)); 441 routing_id(), frame->document().url(), &allowed));
442 return allowed; 442 return allowed;
443 } 443 }
444 444
445 static void SendInsecureContentSignal(int signal) {
446 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", signal,
447 INSECURE_CONTENT_NUM_EVENTS);
448 }
449
445 bool ChromeRenderViewObserver::allowDisplayingInsecureContent( 450 bool ChromeRenderViewObserver::allowDisplayingInsecureContent(
446 WebKit::WebFrame* frame, 451 WebKit::WebFrame* frame,
447 bool allowed_per_settings, 452 bool allowed_per_settings,
448 const WebKit::WebSecurityOrigin& origin, 453 const WebKit::WebSecurityOrigin& origin,
449 const WebKit::WebURL& url) { 454 const WebKit::WebURL& url) {
450 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 455 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY);
451 INSECURE_CONTENT_DISPLAY, 456
452 INSECURE_CONTENT_NUM_EVENTS);
453 std::string host(origin.host().utf8()); 457 std::string host(origin.host().utf8());
454 GURL frame_url(frame->document().url()); 458 GURL frame_url(frame->document().url());
455 if (isHostInDomain(host, kGoogleDotCom)) { 459 if (isHostInDomain(host, kGoogleDotCom)) {
456 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 460 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_GOOGLE);
457 INSECURE_CONTENT_DISPLAY_HOST_GOOGLE,
458 INSECURE_CONTENT_NUM_EVENTS);
459 if (StartsWithASCII(frame_url.path(), kGoogleSupportPathPrefix, false)) { 461 if (StartsWithASCII(frame_url.path(), kGoogleSupportPathPrefix, false)) {
460 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 462 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_SUPPORT);
461 INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_SUPPORT,
462 INSECURE_CONTENT_NUM_EVENTS);
463 } else if (StartsWithASCII(frame_url.path(), 463 } else if (StartsWithASCII(frame_url.path(),
464 kGoogleIntlPathPrefix, 464 kGoogleIntlPathPrefix,
465 false)) { 465 false)) {
466 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 466 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_INTL);
467 INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_INTL,
468 INSECURE_CONTENT_NUM_EVENTS);
469 } 467 }
470 } 468 }
469
471 if (host == kWWWDotGoogleDotCom) { 470 if (host == kWWWDotGoogleDotCom) {
472 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 471 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_WWW_GOOGLE);
473 INSECURE_CONTENT_DISPLAY_HOST_WWW_GOOGLE, 472 if (StartsWithASCII(frame_url.path(), kGoogleReaderPathPrefix, false))
474 INSECURE_CONTENT_NUM_EVENTS); 473 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_READER);
475 if (StartsWithASCII(frame_url.path(), kGoogleReaderPathPrefix, false)) { 474 } else if (host == kMailDotGoogleDotCom)
476 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 475 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_MAIL_GOOGLE);
477 INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_READER, 476 else if (host == kPlusDotGoogleDotCom)
jar (doing other things) 2011/10/27 23:41:31 nit: start all these even lines with a close curly
478 INSECURE_CONTENT_NUM_EVENTS); 477 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_PLUS_GOOGLE);
479 } 478 else if (host == kDocsDotGoogleDotCom)
480 } else if (host == kMailDotGoogleDotCom) { 479 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_DOCS_GOOGLE);
481 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 480 else if (host == kSitesDotGoogleDotCom)
482 INSECURE_CONTENT_DISPLAY_HOST_MAIL_GOOGLE, 481 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_SITES_GOOGLE);
483 INSECURE_CONTENT_NUM_EVENTS); 482 else if (host == kPicasawebDotGoogleDotCom)
484 } else if (host == kPlusDotGoogleDotCom) { 483 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_PICASAWEB_GOOGLE);
485 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 484 else if (host == kCodeDotGoogleDotCom)
486 INSECURE_CONTENT_DISPLAY_HOST_PLUS_GOOGLE, 485 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_CODE_GOOGLE);
487 INSECURE_CONTENT_NUM_EVENTS); 486 else if (host == kGroupsDotGoogleDotCom)
488 } else if (host == kDocsDotGoogleDotCom) { 487 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_GROUPS_GOOGLE);
489 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 488 else if (host == kMapsDotGoogleDotCom)
490 INSECURE_CONTENT_DISPLAY_HOST_DOCS_GOOGLE, 489 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_MAPS_GOOGLE);
491 INSECURE_CONTENT_NUM_EVENTS); 490 else if (host == kWWWDotYoutubeDotCom)
492 } else if (host == kSitesDotGoogleDotCom) { 491 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_YOUTUBE);
493 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 492
494 INSECURE_CONTENT_DISPLAY_HOST_SITES_GOOGLE,
495 INSECURE_CONTENT_NUM_EVENTS);
496 } else if (host == kPicasawebDotGoogleDotCom) {
497 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent",
498 INSECURE_CONTENT_DISPLAY_HOST_PICASAWEB_GOOGLE,
499 INSECURE_CONTENT_NUM_EVENTS);
500 } else if (host == kCodeDotGoogleDotCom) {
501 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent",
502 INSECURE_CONTENT_DISPLAY_HOST_CODE_GOOGLE,
503 INSECURE_CONTENT_NUM_EVENTS);
504 } else if (host == kGroupsDotGoogleDotCom) {
505 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent",
506 INSECURE_CONTENT_DISPLAY_HOST_GROUPS_GOOGLE,
507 INSECURE_CONTENT_NUM_EVENTS);
508 } else if (host == kMapsDotGoogleDotCom) {
509 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent",
510 INSECURE_CONTENT_DISPLAY_HOST_MAPS_GOOGLE,
511 INSECURE_CONTENT_NUM_EVENTS);
512 } else if (host == kWWWDotYoutubeDotCom) {
513 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent",
514 INSECURE_CONTENT_DISPLAY_HOST_YOUTUBE,
515 INSECURE_CONTENT_NUM_EVENTS);
516 }
517 GURL gurl(url); 493 GURL gurl(url);
518 if (EndsWith(gurl.path(), kDotHTML, false)) { 494 if (EndsWith(gurl.path(), kDotHTML, false))
519 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 495 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HTML);
520 INSECURE_CONTENT_DISPLAY_HTML,
521 INSECURE_CONTENT_NUM_EVENTS);
522 }
523 496
524 if (allowed_per_settings || allow_displaying_insecure_content_) 497 if (allowed_per_settings || allow_displaying_insecure_content_)
525 return true; 498 return true;
526 499
527 Send(new ChromeViewHostMsg_DidBlockDisplayingInsecureContent(routing_id())); 500 Send(new ChromeViewHostMsg_DidBlockDisplayingInsecureContent(routing_id()));
528 return false; 501 return false;
529 } 502 }
530 503
531 bool ChromeRenderViewObserver::allowRunningInsecureContent( 504 bool ChromeRenderViewObserver::allowRunningInsecureContent(
532 WebKit::WebFrame* frame, 505 WebKit::WebFrame* frame,
533 bool allowed_per_settings, 506 bool allowed_per_settings,
534 const WebKit::WebSecurityOrigin& origin, 507 const WebKit::WebSecurityOrigin& origin,
535 const WebKit::WebURL& url) { 508 const WebKit::WebURL& url) {
536 // Single value to control permissive mixed content behaviour. 509 // Single value to control permissive mixed content behaviour.
537 const bool enforce_insecure_content_on_all_domains = true; 510 const bool enforce_insecure_content_on_all_domains = true;
538 511
539 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent",
540 INSECURE_CONTENT_RUN,
541 INSECURE_CONTENT_NUM_EVENTS);
542 std::string host(origin.host().utf8()); 512 std::string host(origin.host().utf8());
543 GURL frame_url(frame->document().url()); 513 GURL frame_url(frame->document().url());
544 bool is_google = isHostInDomain(host, kGoogleDotCom); 514 bool is_google = isHostInDomain(host, kGoogleDotCom);
545 if (is_google) { 515 if (is_google) {
546 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 516 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLE);
547 INSECURE_CONTENT_RUN_HOST_GOOGLE,
548 INSECURE_CONTENT_NUM_EVENTS);
549 if (StartsWithASCII(frame_url.path(), kGoogleSupportPathPrefix, false)) { 517 if (StartsWithASCII(frame_url.path(), kGoogleSupportPathPrefix, false)) {
550 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 518 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLE_SUPPORT);
551 INSECURE_CONTENT_RUN_HOST_GOOGLE_SUPPORT,
552 INSECURE_CONTENT_NUM_EVENTS);
553 } else if (StartsWithASCII(frame_url.path(), 519 } else if (StartsWithASCII(frame_url.path(),
554 kGoogleIntlPathPrefix, 520 kGoogleIntlPathPrefix,
555 false)) { 521 false)) {
556 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 522 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLE_INTL);
557 INSECURE_CONTENT_RUN_HOST_GOOGLE_INTL,
558 INSECURE_CONTENT_NUM_EVENTS);
559 } 523 }
560 } 524 }
525
561 if (host == kWWWDotGoogleDotCom) { 526 if (host == kWWWDotGoogleDotCom) {
562 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 527 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_WWW_GOOGLE);
563 INSECURE_CONTENT_RUN_HOST_WWW_GOOGLE, 528 if (StartsWithASCII(frame_url.path(), kGoogleReaderPathPrefix, false))
564 INSECURE_CONTENT_NUM_EVENTS); 529 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLE_READER);
565 if (StartsWithASCII(frame_url.path(), kGoogleReaderPathPrefix, false)) { 530 } else if (host == kMailDotGoogleDotCom)
jar (doing other things) 2011/10/27 23:41:31 nit: Once you start using curlies, you need to use
566 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 531 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_MAIL_GOOGLE);
567 INSECURE_CONTENT_RUN_HOST_GOOGLE_READER, 532 else if (host == kPlusDotGoogleDotCom)
568 INSECURE_CONTENT_NUM_EVENTS); 533 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_PLUS_GOOGLE);
569 } 534 else if (host == kDocsDotGoogleDotCom)
570 } else if (host == kMailDotGoogleDotCom) { 535 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_DOCS_GOOGLE);
571 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 536 else if (host == kSitesDotGoogleDotCom)
572 INSECURE_CONTENT_RUN_HOST_MAIL_GOOGLE, 537 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_SITES_GOOGLE);
573 INSECURE_CONTENT_NUM_EVENTS); 538 else if (host == kPicasawebDotGoogleDotCom)
574 } else if (host == kPlusDotGoogleDotCom) { 539 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_PICASAWEB_GOOGLE);
575 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 540 else if (host == kCodeDotGoogleDotCom)
576 INSECURE_CONTENT_RUN_HOST_PLUS_GOOGLE, 541 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_CODE_GOOGLE);
577 INSECURE_CONTENT_NUM_EVENTS); 542 else if (host == kGroupsDotGoogleDotCom)
578 } else if (host == kDocsDotGoogleDotCom) { 543 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GROUPS_GOOGLE);
579 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 544 else if (host == kMapsDotGoogleDotCom)
580 INSECURE_CONTENT_RUN_HOST_DOCS_GOOGLE, 545 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_MAPS_GOOGLE);
581 INSECURE_CONTENT_NUM_EVENTS); 546 else if (host == kWWWDotYoutubeDotCom)
582 } else if (host == kSitesDotGoogleDotCom) { 547 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_YOUTUBE);
583 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 548 else if (EndsWith(host, kDotGoogleUserContentDotCom, false))
584 INSECURE_CONTENT_RUN_HOST_SITES_GOOGLE, 549 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLEUSERCONTENT);
585 INSECURE_CONTENT_NUM_EVENTS); 550
586 } else if (host == kPicasawebDotGoogleDotCom) {
587 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent",
588 INSECURE_CONTENT_RUN_HOST_PICASAWEB_GOOGLE,
589 INSECURE_CONTENT_NUM_EVENTS);
590 } else if (host == kCodeDotGoogleDotCom) {
591 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent",
592 INSECURE_CONTENT_RUN_HOST_CODE_GOOGLE,
593 INSECURE_CONTENT_NUM_EVENTS);
594 } else if (host == kGroupsDotGoogleDotCom) {
595 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent",
596 INSECURE_CONTENT_RUN_HOST_GROUPS_GOOGLE,
597 INSECURE_CONTENT_NUM_EVENTS);
598 } else if (host == kMapsDotGoogleDotCom) {
599 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent",
600 INSECURE_CONTENT_RUN_HOST_MAPS_GOOGLE,
601 INSECURE_CONTENT_NUM_EVENTS);
602 } else if (host == kWWWDotYoutubeDotCom) {
603 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent",
604 INSECURE_CONTENT_RUN_HOST_YOUTUBE,
605 INSECURE_CONTENT_NUM_EVENTS);
606 } else if (EndsWith(host, kDotGoogleUserContentDotCom, false)) {
607 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent",
608 INSECURE_CONTENT_RUN_HOST_GOOGLEUSERCONTENT,
609 INSECURE_CONTENT_NUM_EVENTS);
610 }
611 GURL gurl(url); 551 GURL gurl(url);
612 if (gurl.host() == kWWWDotYoutubeDotCom) { 552 if (gurl.host() == kWWWDotYoutubeDotCom)
613 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 553 SendInsecureContentSignal(INSECURE_CONTENT_RUN_TARGET_YOUTUBE);
614 INSECURE_CONTENT_RUN_TARGET_YOUTUBE, 554
615 INSECURE_CONTENT_NUM_EVENTS); 555 if (EndsWith(gurl.path(), kDotJS, false))
616 } 556 SendInsecureContentSignal(INSECURE_CONTENT_RUN_JS);
617 if (EndsWith(gurl.path(), kDotJS, false)) { 557 else if (EndsWith(gurl.path(), kDotCSS, false))
618 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 558 SendInsecureContentSignal(INSECURE_CONTENT_RUN_CSS);
619 INSECURE_CONTENT_RUN_JS, 559 else if (EndsWith(gurl.path(), kDotSWF, false))
620 INSECURE_CONTENT_NUM_EVENTS); 560 SendInsecureContentSignal(INSECURE_CONTENT_RUN_SWF);
621 } else if (EndsWith(gurl.path(), kDotCSS, false)) {
622 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent",
623 INSECURE_CONTENT_RUN_CSS,
624 INSECURE_CONTENT_NUM_EVENTS);
625 } else if (EndsWith(gurl.path(), kDotSWF, false)) {
626 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent",
627 INSECURE_CONTENT_RUN_SWF,
628 INSECURE_CONTENT_NUM_EVENTS);
629 }
630 561
631 if (allow_running_insecure_content_ || allowed_per_settings) 562 if (allow_running_insecure_content_ || allowed_per_settings)
632 return true; 563 return true;
633 564
634 if (!(enforce_insecure_content_on_all_domains || 565 if (!(enforce_insecure_content_on_all_domains ||
635 CommandLine::ForCurrentProcess()->HasSwitch( 566 CommandLine::ForCurrentProcess()->HasSwitch(
636 switches::kNoRunningInsecureContent))) { 567 switches::kNoRunningInsecureContent))) {
637 bool mandatory_enforcement = (is_google || 568 bool mandatory_enforcement = (is_google ||
638 isHostInDomain(host, kFacebookDotCom) || 569 isHostInDomain(host, kFacebookDotCom) ||
639 isHostInDomain(host, kTwitterDotCom)); 570 isHostInDomain(host, kTwitterDotCom));
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 // Decode the favicon using WebKit's image decoder. 1016 // Decode the favicon using WebKit's image decoder.
1086 webkit_glue::ImageDecoder decoder( 1017 webkit_glue::ImageDecoder decoder(
1087 gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize)); 1018 gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize));
1088 const unsigned char* src_data = 1019 const unsigned char* src_data =
1089 reinterpret_cast<const unsigned char*>(&data[0]); 1020 reinterpret_cast<const unsigned char*>(&data[0]);
1090 1021
1091 return decoder.Decode(src_data, data.size()); 1022 return decoder.Decode(src_data, data.size());
1092 } 1023 }
1093 return SkBitmap(); 1024 return SkBitmap();
1094 } 1025 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698