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

Side by Side Diff: chrome/browser/safe_browsing/threat_details_unittest.cc

Issue 1509073002: Fixes for Safe Browsing with unrelated pending navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review changes for comment #13-15 Created 5 years 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/pickle.h" 8 #include "base/pickle.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "chrome/browser/history/history_service_factory.h" 11 #include "chrome/browser/history/history_service_factory.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 13 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
14 #include "chrome/browser/safe_browsing/threat_details.h" 14 #include "chrome/browser/safe_browsing/threat_details.h"
15 #include "chrome/browser/safe_browsing/threat_details_history.h" 15 #include "chrome/browser/safe_browsing/threat_details_history.h"
16 #include "chrome/browser/safe_browsing/ui_manager.h" 16 #include "chrome/browser/safe_browsing/ui_manager.h"
17 #include "chrome/common/safe_browsing/csd.pb.h" 17 #include "chrome/common/safe_browsing/csd.pb.h"
18 #include "chrome/common/safe_browsing/safebrowsing_messages.h" 18 #include "chrome/common/safe_browsing/safebrowsing_messages.h"
19 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 19 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
20 #include "chrome/test/base/testing_profile.h" 20 #include "chrome/test/base/testing_profile.h"
21 #include "components/history/core/browser/history_backend.h" 21 #include "components/history/core/browser/history_backend.h"
22 #include "components/history/core/browser/history_service.h" 22 #include "components/history/core/browser/history_service.h"
23 #include "content/public/browser/render_process_host.h" 23 #include "content/public/browser/render_process_host.h"
24 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
25 #include "content/public/test/web_contents_tester.h"
25 #include "net/base/io_buffer.h" 26 #include "net/base/io_buffer.h"
26 #include "net/base/net_errors.h" 27 #include "net/base/net_errors.h"
27 #include "net/base/test_completion_callback.h" 28 #include "net/base/test_completion_callback.h"
28 #include "net/disk_cache/disk_cache.h" 29 #include "net/disk_cache/disk_cache.h"
29 #include "net/http/http_cache.h" 30 #include "net/http/http_cache.h"
30 #include "net/http/http_response_headers.h" 31 #include "net/http/http_response_headers.h"
31 #include "net/http/http_response_info.h" 32 #include "net/http/http_response_info.h"
32 #include "net/http/http_util.h" 33 #include "net/http/http_util.h"
33 #include "net/url_request/url_request_context.h" 34 #include "net/url_request/url_request_context.h"
34 #include "net/url_request/url_request_context_getter.h" 35 #include "net/url_request/url_request_context_getter.h"
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 reinterpret_cast<history::ContextID>(1), 0, 325 reinterpret_cast<history::ContextID>(1), 0,
325 GURL(), *redirects, ui::PAGE_TRANSITION_TYPED, 326 GURL(), *redirects, ui::PAGE_TRANSITION_TYPED,
326 history::SOURCE_BROWSED, false); 327 history::SOURCE_BROWSED, false);
327 } 328 }
328 329
329 scoped_refptr<MockSafeBrowsingUIManager> ui_manager_; 330 scoped_refptr<MockSafeBrowsingUIManager> ui_manager_;
330 }; 331 };
331 332
332 // Tests creating a simple threat report of a malware URL. 333 // Tests creating a simple threat report of a malware URL.
333 TEST_F(ThreatDetailsTest, ThreatSubResource) { 334 TEST_F(ThreatDetailsTest, ThreatSubResource) {
334 // Start a load. 335 // Commit a load.
335 controller().LoadURL( 336 content::WebContentsTester::For(web_contents())
336 GURL(kLandingURL), 337 ->TestDidNavigateWithReferrer(
337 content::Referrer(GURL(kReferrerURL), blink::WebReferrerPolicyDefault), 338 web_contents()->GetMainFrame(), 1 /* page_id */, 0 /* nav_entry_id */,
338 ui::PAGE_TRANSITION_TYPED, std::string()); 339 true /* did_create_new_entry */, GURL(kLandingURL),
340 content::Referrer(GURL(kReferrerURL),
341 blink::WebReferrerPolicyDefault),
342 ui::PAGE_TRANSITION_TYPED);
339 343
340 UnsafeResource resource; 344 UnsafeResource resource;
341 InitResource(&resource, SB_THREAT_TYPE_URL_MALWARE, true, GURL(kThreatURL)); 345 InitResource(&resource, SB_THREAT_TYPE_URL_MALWARE, true /* is_subresource */,
346 GURL(kThreatURL));
342 347
343 scoped_refptr<ThreatDetailsWrap> report = 348 scoped_refptr<ThreatDetailsWrap> report =
344 new ThreatDetailsWrap(ui_manager_.get(), web_contents(), resource, NULL); 349 new ThreatDetailsWrap(ui_manager_.get(), web_contents(), resource, NULL);
345 350
346 std::string serialized = WaitForSerializedReport( 351 std::string serialized = WaitForSerializedReport(
347 report.get(), true /* did_proceed*/, 1 /* num_visit */); 352 report.get(), true /* did_proceed*/, 1 /* num_visit */);
348 353
349 ClientSafeBrowsingReportRequest actual; 354 ClientSafeBrowsingReportRequest actual;
350 actual.ParseFromString(serialized); 355 actual.ParseFromString(serialized);
351 356
(...skipping 17 matching lines...) Expand all
369 pb_resource = expected.add_resources(); 374 pb_resource = expected.add_resources();
370 pb_resource->set_id(2); 375 pb_resource->set_id(2);
371 pb_resource->set_url(kReferrerURL); 376 pb_resource->set_url(kReferrerURL);
372 377
373 VerifyResults(actual, expected); 378 VerifyResults(actual, expected);
374 } 379 }
375 380
376 // Tests creating a simple threat report of a phishing page where the 381 // Tests creating a simple threat report of a phishing page where the
377 // subresource has a different original_url. 382 // subresource has a different original_url.
378 TEST_F(ThreatDetailsTest, ThreatSubResourceWithOriginalUrl) { 383 TEST_F(ThreatDetailsTest, ThreatSubResourceWithOriginalUrl) {
379 controller().LoadURL(GURL(kLandingURL), content::Referrer(), 384 content::WebContentsTester::For(web_contents())
380 ui::PAGE_TRANSITION_TYPED, std::string()); 385 ->NavigateAndCommit(GURL(kLandingURL));
381 386
382 UnsafeResource resource; 387 UnsafeResource resource;
383 InitResource(&resource, SB_THREAT_TYPE_URL_PHISHING, true, GURL(kThreatURL)); 388 InitResource(&resource, SB_THREAT_TYPE_URL_PHISHING,
389 true /* is_subresource */, GURL(kThreatURL));
384 resource.original_url = GURL(kOriginalLandingURL); 390 resource.original_url = GURL(kOriginalLandingURL);
385 391
386 scoped_refptr<ThreatDetailsWrap> report = 392 scoped_refptr<ThreatDetailsWrap> report =
387 new ThreatDetailsWrap(ui_manager_.get(), web_contents(), resource, NULL); 393 new ThreatDetailsWrap(ui_manager_.get(), web_contents(), resource, NULL);
388 394
389 std::string serialized = WaitForSerializedReport( 395 std::string serialized = WaitForSerializedReport(
390 report.get(), false /* did_proceed*/, 1 /* num_visit */); 396 report.get(), false /* did_proceed*/, 1 /* num_visit */);
391 397
392 ClientSafeBrowsingReportRequest actual; 398 ClientSafeBrowsingReportRequest actual;
393 actual.ParseFromString(serialized); 399 actual.ParseFromString(serialized);
(...skipping 20 matching lines...) Expand all
414 pb_resource->set_url(kThreatURL); 420 pb_resource->set_url(kThreatURL);
415 // The Resource for kThreatURL should have the Resource for 421 // The Resource for kThreatURL should have the Resource for
416 // kOriginalLandingURL (with id 1) as parent. 422 // kOriginalLandingURL (with id 1) as parent.
417 pb_resource->set_parent_id(1); 423 pb_resource->set_parent_id(1);
418 424
419 VerifyResults(actual, expected); 425 VerifyResults(actual, expected);
420 } 426 }
421 427
422 // Tests creating a threat report of a UwS page with data from the renderer. 428 // Tests creating a threat report of a UwS page with data from the renderer.
423 TEST_F(ThreatDetailsTest, ThreatDOMDetails) { 429 TEST_F(ThreatDetailsTest, ThreatDOMDetails) {
424 controller().LoadURL(GURL(kLandingURL), content::Referrer(), 430 content::WebContentsTester::For(web_contents())
425 ui::PAGE_TRANSITION_TYPED, std::string()); 431 ->NavigateAndCommit(GURL(kLandingURL));
426 432
427 UnsafeResource resource; 433 UnsafeResource resource;
428 InitResource(&resource, SB_THREAT_TYPE_URL_UNWANTED, true, GURL(kThreatURL)); 434 InitResource(&resource, SB_THREAT_TYPE_URL_UNWANTED,
435 true /* is_subresource */, GURL(kThreatURL));
429 436
430 scoped_refptr<ThreatDetailsWrap> report = 437 scoped_refptr<ThreatDetailsWrap> report =
431 new ThreatDetailsWrap(ui_manager_.get(), web_contents(), resource, NULL); 438 new ThreatDetailsWrap(ui_manager_.get(), web_contents(), resource, NULL);
432 439
433 // Send a message from the DOM, with 2 nodes, a parent and a child. 440 // Send a message from the DOM, with 2 nodes, a parent and a child.
434 std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node> params; 441 std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node> params;
435 SafeBrowsingHostMsg_ThreatDOMDetails_Node child_node; 442 SafeBrowsingHostMsg_ThreatDOMDetails_Node child_node;
436 child_node.url = GURL(kDOMChildURL); 443 child_node.url = GURL(kDOMChildURL);
437 child_node.tag_name = "iframe"; 444 child_node.tag_name = "iframe";
438 child_node.parent = GURL(kDOMParentURL); 445 child_node.parent = GURL(kDOMParentURL);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 pb_resource->set_url(kDOMParentURL); 482 pb_resource->set_url(kDOMParentURL);
476 pb_resource->add_child_ids(2); 483 pb_resource->add_child_ids(2);
477 expected.set_complete(false); // Since the cache was missing. 484 expected.set_complete(false); // Since the cache was missing.
478 485
479 VerifyResults(actual, expected); 486 VerifyResults(actual, expected);
480 } 487 }
481 488
482 // Tests creating a threat report of a malware page where there are redirect 489 // Tests creating a threat report of a malware page where there are redirect
483 // urls to an unsafe resource url. 490 // urls to an unsafe resource url.
484 TEST_F(ThreatDetailsTest, ThreatWithRedirectUrl) { 491 TEST_F(ThreatDetailsTest, ThreatWithRedirectUrl) {
485 controller().LoadURL(GURL(kLandingURL), content::Referrer(), 492 content::WebContentsTester::For(web_contents())
486 ui::PAGE_TRANSITION_TYPED, std::string()); 493 ->NavigateAndCommit(GURL(kLandingURL));
487 494
488 UnsafeResource resource; 495 UnsafeResource resource;
489 InitResource(&resource, SB_THREAT_TYPE_URL_MALWARE, true, GURL(kThreatURL)); 496 InitResource(&resource, SB_THREAT_TYPE_URL_MALWARE, true /* is_subresource */,
497 GURL(kThreatURL));
490 resource.original_url = GURL(kOriginalLandingURL); 498 resource.original_url = GURL(kOriginalLandingURL);
491 499
492 // add some redirect urls 500 // add some redirect urls
493 resource.redirect_urls.push_back(GURL(kFirstRedirectURL)); 501 resource.redirect_urls.push_back(GURL(kFirstRedirectURL));
494 resource.redirect_urls.push_back(GURL(kSecondRedirectURL)); 502 resource.redirect_urls.push_back(GURL(kSecondRedirectURL));
495 resource.redirect_urls.push_back(GURL(kThreatURL)); 503 resource.redirect_urls.push_back(GURL(kThreatURL));
496 504
497 scoped_refptr<ThreatDetailsWrap> report = 505 scoped_refptr<ThreatDetailsWrap> report =
498 new ThreatDetailsWrap(ui_manager_.get(), web_contents(), resource, NULL); 506 new ThreatDetailsWrap(ui_manager_.get(), web_contents(), resource, NULL);
499 507
(...skipping 30 matching lines...) Expand all
530 pb_resource->set_parent_id(1); 538 pb_resource->set_parent_id(1);
531 539
532 pb_resource = expected.add_resources(); 540 pb_resource = expected.add_resources();
533 pb_resource->set_id(4); 541 pb_resource->set_id(4);
534 pb_resource->set_url(kSecondRedirectURL); 542 pb_resource->set_url(kSecondRedirectURL);
535 pb_resource->set_parent_id(3); 543 pb_resource->set_parent_id(3);
536 544
537 VerifyResults(actual, expected); 545 VerifyResults(actual, expected);
538 } 546 }
539 547
548 // Test collecting threat details for a blocked main frame load.
549 TEST_F(ThreatDetailsTest, ThreatOnMainPageLoadBlocked) {
550 const char* kUnrelatedReferrerURL =
551 "http://www.unrelatedreferrer.com/some/path";
552 const char* kUnrelatedURL = "http://www.unrelated.com/some/path";
553
554 // Load and commit an unrelated URL. The ThreatDetails should not use this
555 // navigation entry.
556 content::WebContentsTester::For(web_contents())
557 ->TestDidNavigateWithReferrer(
558 web_contents()->GetMainFrame(), 1 /* page_id */, 0 /* nav_entry_id */,
559 true /* did_create_new_entry */, GURL(kUnrelatedURL),
560 content::Referrer(GURL(kUnrelatedReferrerURL),
561 blink::WebReferrerPolicyDefault),
562 ui::PAGE_TRANSITION_TYPED);
563
564 // Start a pending load with a referrer.
565 controller().LoadURL(GURL(kLandingURL),
566 content::Referrer(GURL(kReferrerURL),
567 blink::WebReferrerPolicyDefault),
568 ui::PAGE_TRANSITION_TYPED, std::string());
569
570 // Create UnsafeResource for the pending main page load.
571 UnsafeResource resource;
572 InitResource(&resource, SB_THREAT_TYPE_URL_MALWARE,
573 false /* is_subresource */, GURL(kLandingURL));
574
575 // Start ThreatDetails collection.
576 scoped_refptr<ThreatDetailsWrap> report =
577 new ThreatDetailsWrap(ui_manager_.get(), web_contents(), resource, NULL);
578
579 // Simulate clicking don't proceed.
580 controller().DiscardNonCommittedEntries();
581
582 // Finish ThreatDetails collection.
583 std::string serialized = WaitForSerializedReport(
584 report.get(), false /* did_proceed*/, 1 /* num_visit */);
585
586 ClientSafeBrowsingReportRequest actual;
587 actual.ParseFromString(serialized);
588
589 ClientSafeBrowsingReportRequest expected;
590 expected.set_type(ClientSafeBrowsingReportRequest::URL_MALWARE);
591 expected.set_url(kLandingURL);
592 expected.set_page_url(kLandingURL);
593 // Note that the referrer policy is not actually enacted here, since that's
594 // done in Blink.
595 expected.set_referrer_url(kReferrerURL);
596 expected.set_did_proceed(false);
597 expected.set_repeat_visit(true);
598
599 ClientSafeBrowsingReportRequest::Resource* pb_resource =
600 expected.add_resources();
601 pb_resource->set_id(0);
602 pb_resource->set_url(kLandingURL);
603 pb_resource = expected.add_resources();
604 pb_resource->set_id(1);
605 pb_resource->set_url(kReferrerURL);
606
607 VerifyResults(actual, expected);
608 }
609
610 // Tests that a pending load does not interfere with collecting threat details
611 // for the committed page.
612 TEST_F(ThreatDetailsTest, ThreatWithPendingLoad) {
613 const char* kPendingReferrerURL = "http://www.pendingreferrer.com/some/path";
614 const char* kPendingURL = "http://www.pending.com/some/path";
615
616 // Load and commit the landing URL with a referrer.
617 content::WebContentsTester::For(web_contents())
618 ->TestDidNavigateWithReferrer(
619 web_contents()->GetMainFrame(), 1 /* page_id */, 0 /* nav_entry_id */,
620 true /* did_create_new_entry */, GURL(kLandingURL),
621 content::Referrer(GURL(kReferrerURL),
622 blink::WebReferrerPolicyDefault),
623 ui::PAGE_TRANSITION_TYPED);
624
625 // Create UnsafeResource for fake sub-resource of landing page.
626 UnsafeResource resource;
627 InitResource(&resource, SB_THREAT_TYPE_URL_MALWARE, true /* is_subresource */,
628 GURL(kThreatURL));
629
630 // Start a pending load before creating ThreatDetails.
631 controller().LoadURL(GURL(kPendingURL),
632 content::Referrer(GURL(kPendingReferrerURL),
633 blink::WebReferrerPolicyDefault),
634 ui::PAGE_TRANSITION_TYPED, std::string());
635
636 // Do ThreatDetails collection.
637 scoped_refptr<ThreatDetailsWrap> report =
638 new ThreatDetailsWrap(ui_manager_.get(), web_contents(), resource, NULL);
639 std::string serialized = WaitForSerializedReport(
640 report.get(), true /* did_proceed*/, 1 /* num_visit */);
641
642 ClientSafeBrowsingReportRequest actual;
643 actual.ParseFromString(serialized);
644
645 ClientSafeBrowsingReportRequest expected;
646 expected.set_type(ClientSafeBrowsingReportRequest::URL_MALWARE);
647 expected.set_url(kThreatURL);
648 expected.set_page_url(kLandingURL);
649 // Note that the referrer policy is not actually enacted here, since that's
650 // done in Blink.
651 expected.set_referrer_url(kReferrerURL);
652 expected.set_did_proceed(true);
653 expected.set_repeat_visit(true);
654
655 ClientSafeBrowsingReportRequest::Resource* pb_resource =
656 expected.add_resources();
657 pb_resource->set_id(0);
658 pb_resource->set_url(kLandingURL);
659 pb_resource = expected.add_resources();
660 pb_resource->set_id(1);
661 pb_resource->set_url(kThreatURL);
662 pb_resource = expected.add_resources();
663 pb_resource->set_id(2);
664 pb_resource->set_url(kReferrerURL);
665
666 VerifyResults(actual, expected);
667 }
668
669 TEST_F(ThreatDetailsTest, ThreatOnFreshTab) {
670 // A fresh WebContents should not have any NavigationEntries yet. (See
671 // https://crbug.com/524208.)
672 EXPECT_EQ(nullptr, controller().GetLastCommittedEntry());
673 EXPECT_EQ(nullptr, controller().GetPendingEntry());
674
675 // Simulate a subresource malware hit (this could happen if the WebContents
676 // was created with window.open, and had content injected into it).
677 UnsafeResource resource;
678 InitResource(&resource, SB_THREAT_TYPE_URL_MALWARE, true /* is_subresource */,
679 GURL(kThreatURL));
680
681 // Do ThreatDetails collection.
682 scoped_refptr<ThreatDetailsWrap> report =
683 new ThreatDetailsWrap(ui_manager_.get(), web_contents(), resource, NULL);
684 std::string serialized = WaitForSerializedReport(
685 report.get(), true /* did_proceed*/, 1 /* num_visit */);
686
687 ClientSafeBrowsingReportRequest actual;
688 actual.ParseFromString(serialized);
689
690 ClientSafeBrowsingReportRequest expected;
691 expected.set_type(ClientSafeBrowsingReportRequest::URL_MALWARE);
692 expected.set_url(kThreatURL);
693 expected.set_did_proceed(true);
694 expected.set_repeat_visit(true);
695
696 ClientSafeBrowsingReportRequest::Resource* pb_resource =
697 expected.add_resources();
698 pb_resource->set_id(0);
699 pb_resource->set_url(kThreatURL);
700
701 VerifyResults(actual, expected);
702 }
703
540 // Tests the interaction with the HTTP cache. 704 // Tests the interaction with the HTTP cache.
541 TEST_F(ThreatDetailsTest, HTTPCache) { 705 TEST_F(ThreatDetailsTest, HTTPCache) {
542 controller().LoadURL(GURL(kLandingURL), content::Referrer(), 706 content::WebContentsTester::For(web_contents())
543 ui::PAGE_TRANSITION_TYPED, std::string()); 707 ->NavigateAndCommit(GURL(kLandingURL));
544 708
545 UnsafeResource resource; 709 UnsafeResource resource;
546 InitResource(&resource, SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL, true, 710 InitResource(&resource, SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL,
547 GURL(kThreatURL)); 711 true /* is_subresource */, GURL(kThreatURL));
548 712
549 scoped_refptr<ThreatDetailsWrap> report = 713 scoped_refptr<ThreatDetailsWrap> report =
550 new ThreatDetailsWrap(ui_manager_.get(), web_contents(), resource, 714 new ThreatDetailsWrap(ui_manager_.get(), web_contents(), resource,
551 profile()->GetRequestContext()); 715 profile()->GetRequestContext());
552 716
553 BrowserThread::PostTask( 717 BrowserThread::PostTask(
554 BrowserThread::IO, FROM_HERE, 718 BrowserThread::IO, FROM_HERE,
555 base::Bind(&FillCache, 719 base::Bind(&FillCache,
556 make_scoped_refptr(profile()->GetRequestContext()))); 720 make_scoped_refptr(profile()->GetRequestContext())));
557 721
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 pb_response->set_bodylength(threat_data.size()); 775 pb_response->set_bodylength(threat_data.size());
612 pb_response->set_bodydigest(base::MD5String(threat_data)); 776 pb_response->set_bodydigest(base::MD5String(threat_data));
613 pb_response->set_remote_ip("1.2.3.4:80"); 777 pb_response->set_remote_ip("1.2.3.4:80");
614 expected.set_complete(true); 778 expected.set_complete(true);
615 779
616 VerifyResults(actual, expected); 780 VerifyResults(actual, expected);
617 } 781 }
618 782
619 // Tests the interaction with the HTTP cache (where the cache is empty). 783 // Tests the interaction with the HTTP cache (where the cache is empty).
620 TEST_F(ThreatDetailsTest, HTTPCacheNoEntries) { 784 TEST_F(ThreatDetailsTest, HTTPCacheNoEntries) {
621 controller().LoadURL(GURL(kLandingURL), content::Referrer(), 785 content::WebContentsTester::For(web_contents())
622 ui::PAGE_TRANSITION_TYPED, std::string()); 786 ->NavigateAndCommit(GURL(kLandingURL));
623 787
624 UnsafeResource resource; 788 UnsafeResource resource;
625 InitResource(&resource, SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL, true, 789 InitResource(&resource, SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL,
626 GURL(kThreatURL)); 790 true /* is_subresource */, GURL(kThreatURL));
627 791
628 scoped_refptr<ThreatDetailsWrap> report = 792 scoped_refptr<ThreatDetailsWrap> report =
629 new ThreatDetailsWrap(ui_manager_.get(), web_contents(), resource, 793 new ThreatDetailsWrap(ui_manager_.get(), web_contents(), resource,
630 profile()->GetRequestContext()); 794 profile()->GetRequestContext());
631 795
632 // No call to FillCache 796 // No call to FillCache
633 797
634 // The cache collection starts after the IPC from the DOM is fired. 798 // The cache collection starts after the IPC from the DOM is fired.
635 std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node> params; 799 std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node> params;
636 report->OnReceivedThreatDOMDetails(params); 800 report->OnReceivedThreatDOMDetails(params);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 // There are two redirect urls before reacing malware url: 833 // There are two redirect urls before reacing malware url:
670 // kFirstRedirectURL -> kSecondRedirectURL -> kThreatURL 834 // kFirstRedirectURL -> kSecondRedirectURL -> kThreatURL
671 GURL baseurl(kThreatURL); 835 GURL baseurl(kThreatURL);
672 history::RedirectList redirects; 836 history::RedirectList redirects;
673 redirects.push_back(GURL(kFirstRedirectURL)); 837 redirects.push_back(GURL(kFirstRedirectURL));
674 redirects.push_back(GURL(kSecondRedirectURL)); 838 redirects.push_back(GURL(kSecondRedirectURL));
675 AddPageToHistory(baseurl, &redirects); 839 AddPageToHistory(baseurl, &redirects);
676 // Wait for history service operation finished. 840 // Wait for history service operation finished.
677 profile()->BlockUntilHistoryProcessesPendingRequests(); 841 profile()->BlockUntilHistoryProcessesPendingRequests();
678 842
679 controller().LoadURL(GURL(kLandingURL), content::Referrer(), 843 content::WebContentsTester::For(web_contents())
680 ui::PAGE_TRANSITION_TYPED, std::string()); 844 ->NavigateAndCommit(GURL(kLandingURL));
681 845
682 UnsafeResource resource; 846 UnsafeResource resource;
683 InitResource(&resource, SB_THREAT_TYPE_URL_MALWARE, true, GURL(kThreatURL)); 847 InitResource(&resource, SB_THREAT_TYPE_URL_MALWARE, true /* is_subresource */,
848 GURL(kThreatURL));
684 scoped_refptr<ThreatDetailsWrap> report = 849 scoped_refptr<ThreatDetailsWrap> report =
685 new ThreatDetailsWrap(ui_manager_.get(), web_contents(), resource, NULL); 850 new ThreatDetailsWrap(ui_manager_.get(), web_contents(), resource, NULL);
686 851
687 // The redirects collection starts after the IPC from the DOM is fired. 852 // The redirects collection starts after the IPC from the DOM is fired.
688 std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node> params; 853 std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node> params;
689 report->OnReceivedThreatDOMDetails(params); 854 report->OnReceivedThreatDOMDetails(params);
690 855
691 // Let the redirects callbacks complete. 856 // Let the redirects callbacks complete.
692 base::RunLoop().RunUntilIdle(); 857 base::RunLoop().RunUntilIdle();
693 858
(...skipping 23 matching lines...) Expand all
717 pb_resource->set_parent_id(3); 882 pb_resource->set_parent_id(3);
718 pb_resource->set_url(kSecondRedirectURL); 883 pb_resource->set_url(kSecondRedirectURL);
719 pb_resource = expected.add_resources(); 884 pb_resource = expected.add_resources();
720 pb_resource->set_id(3); 885 pb_resource->set_id(3);
721 pb_resource->set_url(kFirstRedirectURL); 886 pb_resource->set_url(kFirstRedirectURL);
722 887
723 VerifyResults(actual, expected); 888 VerifyResults(actual, expected);
724 } 889 }
725 890
726 } // namespace safe_browsing 891 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/threat_details.cc ('k') | chrome/browser/safe_browsing/ui_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698