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

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)) {
476 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent",
477 INSECURE_CONTENT_DISPLAY_HOST_GOOGLE_READER,
478 INSECURE_CONTENT_NUM_EVENTS);
479 }
480 } else if (host == kMailDotGoogleDotCom) { 474 } else if (host == kMailDotGoogleDotCom) {
481 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 475 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_MAIL_GOOGLE);
482 INSECURE_CONTENT_DISPLAY_HOST_MAIL_GOOGLE,
483 INSECURE_CONTENT_NUM_EVENTS);
484 } else if (host == kPlusDotGoogleDotCom) { 476 } else if (host == kPlusDotGoogleDotCom) {
485 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 477 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_PLUS_GOOGLE);
486 INSECURE_CONTENT_DISPLAY_HOST_PLUS_GOOGLE,
487 INSECURE_CONTENT_NUM_EVENTS);
488 } else if (host == kDocsDotGoogleDotCom) { 478 } else if (host == kDocsDotGoogleDotCom) {
489 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 479 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_DOCS_GOOGLE);
490 INSECURE_CONTENT_DISPLAY_HOST_DOCS_GOOGLE,
491 INSECURE_CONTENT_NUM_EVENTS);
492 } else if (host == kSitesDotGoogleDotCom) { 480 } else if (host == kSitesDotGoogleDotCom) {
493 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 481 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_SITES_GOOGLE);
494 INSECURE_CONTENT_DISPLAY_HOST_SITES_GOOGLE,
495 INSECURE_CONTENT_NUM_EVENTS);
496 } else if (host == kPicasawebDotGoogleDotCom) { 482 } else if (host == kPicasawebDotGoogleDotCom) {
497 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 483 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_PICASAWEB_GOOGLE);
498 INSECURE_CONTENT_DISPLAY_HOST_PICASAWEB_GOOGLE,
499 INSECURE_CONTENT_NUM_EVENTS);
500 } else if (host == kCodeDotGoogleDotCom) { 484 } else if (host == kCodeDotGoogleDotCom) {
501 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 485 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_CODE_GOOGLE);
502 INSECURE_CONTENT_DISPLAY_HOST_CODE_GOOGLE,
503 INSECURE_CONTENT_NUM_EVENTS);
504 } else if (host == kGroupsDotGoogleDotCom) { 486 } else if (host == kGroupsDotGoogleDotCom) {
505 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 487 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_GROUPS_GOOGLE);
506 INSECURE_CONTENT_DISPLAY_HOST_GROUPS_GOOGLE,
507 INSECURE_CONTENT_NUM_EVENTS);
508 } else if (host == kMapsDotGoogleDotCom) { 488 } else if (host == kMapsDotGoogleDotCom) {
509 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 489 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_MAPS_GOOGLE);
510 INSECURE_CONTENT_DISPLAY_HOST_MAPS_GOOGLE,
511 INSECURE_CONTENT_NUM_EVENTS);
512 } else if (host == kWWWDotYoutubeDotCom) { 490 } else if (host == kWWWDotYoutubeDotCom) {
513 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 491 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HOST_YOUTUBE);
514 INSECURE_CONTENT_DISPLAY_HOST_YOUTUBE,
515 INSECURE_CONTENT_NUM_EVENTS);
516 } 492 }
493
517 GURL gurl(url); 494 GURL gurl(url);
518 if (EndsWith(gurl.path(), kDotHTML, false)) { 495 if (EndsWith(gurl.path(), kDotHTML, false))
519 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 496 SendInsecureContentSignal(INSECURE_CONTENT_DISPLAY_HTML);
520 INSECURE_CONTENT_DISPLAY_HTML,
521 INSECURE_CONTENT_NUM_EVENTS);
522 }
523 497
524 if (allowed_per_settings || allow_displaying_insecure_content_) 498 if (allowed_per_settings || allow_displaying_insecure_content_)
525 return true; 499 return true;
526 500
527 Send(new ChromeViewHostMsg_DidBlockDisplayingInsecureContent(routing_id())); 501 Send(new ChromeViewHostMsg_DidBlockDisplayingInsecureContent(routing_id()));
528 return false; 502 return false;
529 } 503 }
530 504
531 bool ChromeRenderViewObserver::allowRunningInsecureContent( 505 bool ChromeRenderViewObserver::allowRunningInsecureContent(
532 WebKit::WebFrame* frame, 506 WebKit::WebFrame* frame,
533 bool allowed_per_settings, 507 bool allowed_per_settings,
534 const WebKit::WebSecurityOrigin& origin, 508 const WebKit::WebSecurityOrigin& origin,
535 const WebKit::WebURL& url) { 509 const WebKit::WebURL& url) {
536 // Single value to control permissive mixed content behaviour. 510 // Single value to control permissive mixed content behaviour.
537 const bool enforce_insecure_content_on_all_domains = true; 511 const bool enforce_insecure_content_on_all_domains = true;
538 512
539 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent",
540 INSECURE_CONTENT_RUN,
541 INSECURE_CONTENT_NUM_EVENTS);
542 std::string host(origin.host().utf8()); 513 std::string host(origin.host().utf8());
543 GURL frame_url(frame->document().url()); 514 GURL frame_url(frame->document().url());
544 bool is_google = isHostInDomain(host, kGoogleDotCom); 515 bool is_google = isHostInDomain(host, kGoogleDotCom);
545 if (is_google) { 516 if (is_google) {
546 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 517 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)) { 518 if (StartsWithASCII(frame_url.path(), kGoogleSupportPathPrefix, false)) {
550 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 519 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(), 520 } else if (StartsWithASCII(frame_url.path(),
554 kGoogleIntlPathPrefix, 521 kGoogleIntlPathPrefix,
555 false)) { 522 false)) {
556 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 523 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLE_INTL);
557 INSECURE_CONTENT_RUN_HOST_GOOGLE_INTL,
558 INSECURE_CONTENT_NUM_EVENTS);
559 } 524 }
560 } 525 }
526
561 if (host == kWWWDotGoogleDotCom) { 527 if (host == kWWWDotGoogleDotCom) {
562 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 528 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_WWW_GOOGLE);
563 INSECURE_CONTENT_RUN_HOST_WWW_GOOGLE, 529 if (StartsWithASCII(frame_url.path(), kGoogleReaderPathPrefix, false))
564 INSECURE_CONTENT_NUM_EVENTS); 530 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLE_READER);
565 if (StartsWithASCII(frame_url.path(), kGoogleReaderPathPrefix, false)) {
566 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent",
567 INSECURE_CONTENT_RUN_HOST_GOOGLE_READER,
568 INSECURE_CONTENT_NUM_EVENTS);
569 }
570 } else if (host == kMailDotGoogleDotCom) { 531 } else if (host == kMailDotGoogleDotCom) {
571 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 532 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_MAIL_GOOGLE);
572 INSECURE_CONTENT_RUN_HOST_MAIL_GOOGLE,
573 INSECURE_CONTENT_NUM_EVENTS);
574 } else if (host == kPlusDotGoogleDotCom) { 533 } else if (host == kPlusDotGoogleDotCom) {
575 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 534 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_PLUS_GOOGLE);
576 INSECURE_CONTENT_RUN_HOST_PLUS_GOOGLE,
577 INSECURE_CONTENT_NUM_EVENTS);
578 } else if (host == kDocsDotGoogleDotCom) { 535 } else if (host == kDocsDotGoogleDotCom) {
579 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 536 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_DOCS_GOOGLE);
580 INSECURE_CONTENT_RUN_HOST_DOCS_GOOGLE,
581 INSECURE_CONTENT_NUM_EVENTS);
582 } else if (host == kSitesDotGoogleDotCom) { 537 } else if (host == kSitesDotGoogleDotCom) {
583 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 538 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_SITES_GOOGLE);
584 INSECURE_CONTENT_RUN_HOST_SITES_GOOGLE,
585 INSECURE_CONTENT_NUM_EVENTS);
586 } else if (host == kPicasawebDotGoogleDotCom) { 539 } else if (host == kPicasawebDotGoogleDotCom) {
587 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 540 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_PICASAWEB_GOOGLE);
588 INSECURE_CONTENT_RUN_HOST_PICASAWEB_GOOGLE,
589 INSECURE_CONTENT_NUM_EVENTS);
590 } else if (host == kCodeDotGoogleDotCom) { 541 } else if (host == kCodeDotGoogleDotCom) {
591 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 542 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_CODE_GOOGLE);
592 INSECURE_CONTENT_RUN_HOST_CODE_GOOGLE,
593 INSECURE_CONTENT_NUM_EVENTS);
594 } else if (host == kGroupsDotGoogleDotCom) { 543 } else if (host == kGroupsDotGoogleDotCom) {
595 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 544 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GROUPS_GOOGLE);
596 INSECURE_CONTENT_RUN_HOST_GROUPS_GOOGLE,
597 INSECURE_CONTENT_NUM_EVENTS);
598 } else if (host == kMapsDotGoogleDotCom) { 545 } else if (host == kMapsDotGoogleDotCom) {
599 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 546 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_MAPS_GOOGLE);
600 INSECURE_CONTENT_RUN_HOST_MAPS_GOOGLE,
601 INSECURE_CONTENT_NUM_EVENTS);
602 } else if (host == kWWWDotYoutubeDotCom) { 547 } else if (host == kWWWDotYoutubeDotCom) {
603 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 548 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_YOUTUBE);
604 INSECURE_CONTENT_RUN_HOST_YOUTUBE,
605 INSECURE_CONTENT_NUM_EVENTS);
606 } else if (EndsWith(host, kDotGoogleUserContentDotCom, false)) { 549 } else if (EndsWith(host, kDotGoogleUserContentDotCom, false)) {
607 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 550 SendInsecureContentSignal(INSECURE_CONTENT_RUN_HOST_GOOGLEUSERCONTENT);
608 INSECURE_CONTENT_RUN_HOST_GOOGLEUSERCONTENT,
609 INSECURE_CONTENT_NUM_EVENTS);
610 } 551 }
552
611 GURL gurl(url); 553 GURL gurl(url);
612 if (gurl.host() == kWWWDotYoutubeDotCom) { 554 if (gurl.host() == kWWWDotYoutubeDotCom)
613 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 555 SendInsecureContentSignal(INSECURE_CONTENT_RUN_TARGET_YOUTUBE);
614 INSECURE_CONTENT_RUN_TARGET_YOUTUBE, 556
615 INSECURE_CONTENT_NUM_EVENTS); 557 if (EndsWith(gurl.path(), kDotJS, false))
616 } 558 SendInsecureContentSignal(INSECURE_CONTENT_RUN_JS);
617 if (EndsWith(gurl.path(), kDotJS, false)) { 559 else if (EndsWith(gurl.path(), kDotCSS, false))
618 UMA_HISTOGRAM_ENUMERATION("SSL.InsecureContent", 560 SendInsecureContentSignal(INSECURE_CONTENT_RUN_CSS);
619 INSECURE_CONTENT_RUN_JS, 561 else if (EndsWith(gurl.path(), kDotSWF, false))
620 INSECURE_CONTENT_NUM_EVENTS); 562 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 563
631 if (allow_running_insecure_content_ || allowed_per_settings) 564 if (allow_running_insecure_content_ || allowed_per_settings)
632 return true; 565 return true;
633 566
634 if (!(enforce_insecure_content_on_all_domains || 567 if (!(enforce_insecure_content_on_all_domains ||
635 CommandLine::ForCurrentProcess()->HasSwitch( 568 CommandLine::ForCurrentProcess()->HasSwitch(
636 switches::kNoRunningInsecureContent))) { 569 switches::kNoRunningInsecureContent))) {
637 bool mandatory_enforcement = (is_google || 570 bool mandatory_enforcement = (is_google ||
638 isHostInDomain(host, kFacebookDotCom) || 571 isHostInDomain(host, kFacebookDotCom) ||
639 isHostInDomain(host, kTwitterDotCom)); 572 isHostInDomain(host, kTwitterDotCom));
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 // Decode the favicon using WebKit's image decoder. 1018 // Decode the favicon using WebKit's image decoder.
1086 webkit_glue::ImageDecoder decoder( 1019 webkit_glue::ImageDecoder decoder(
1087 gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize)); 1020 gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize));
1088 const unsigned char* src_data = 1021 const unsigned char* src_data =
1089 reinterpret_cast<const unsigned char*>(&data[0]); 1022 reinterpret_cast<const unsigned char*>(&data[0]);
1090 1023
1091 return decoder.Decode(src_data, data.size()); 1024 return decoder.Decode(src_data, data.size());
1092 } 1025 }
1093 return SkBitmap(); 1026 return SkBitmap();
1094 } 1027 }
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