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

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

Issue 2241673002: Make UnsafeResource hold a WebContents getter instead of RenderFrame ids (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 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/browser/safe_browsing/client_side_detection_host.h" 5 #include "chrome/browser/safe_browsing/client_side_detection_host.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 const SafeBrowsingUIManager::UnsafeResource& resource) { 410 const SafeBrowsingUIManager::UnsafeResource& resource) {
411 if (!web_contents()) 411 if (!web_contents())
412 return; 412 return;
413 413
414 // Check that the hit is either malware or phishing. 414 // Check that the hit is either malware or phishing.
415 if (resource.threat_type != SB_THREAT_TYPE_URL_PHISHING && 415 if (resource.threat_type != SB_THREAT_TYPE_URL_PHISHING &&
416 resource.threat_type != SB_THREAT_TYPE_URL_MALWARE) 416 resource.threat_type != SB_THREAT_TYPE_URL_MALWARE)
417 return; 417 return;
418 418
419 // Check that this notification is really for us. 419 // Check that this notification is really for us.
420 content::RenderFrameHost* hit_rfh = content::RenderFrameHost::FromID( 420 if (web_contents() != resource.web_contents_getter.Run())
421 resource.render_process_host_id, resource.render_frame_id);
422 if (!hit_rfh ||
423 web_contents() != content::WebContents::FromRenderFrameHost(hit_rfh))
424 return; 421 return;
425 422
426 NavigationEntry *entry = resource.GetNavigationEntryForResource(); 423 NavigationEntry *entry = resource.GetNavigationEntryForResource();
427 if (!entry) 424 if (!entry)
428 return; 425 return;
429 426
430 // Store the unique page ID for later. 427 // Store the unique page ID for later.
431 unsafe_unique_page_id_ = entry->GetUniqueID(); 428 unsafe_unique_page_id_ = entry->GetUniqueID();
432 429
433 // We also keep the resource around in order to be able to send the 430 // We also keep the resource around in order to be able to send the
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 if (is_phishing) { 553 if (is_phishing) {
557 DCHECK(web_contents()); 554 DCHECK(web_contents());
558 if (ui_manager_.get()) { 555 if (ui_manager_.get()) {
559 SafeBrowsingUIManager::UnsafeResource resource; 556 SafeBrowsingUIManager::UnsafeResource resource;
560 resource.url = phishing_url; 557 resource.url = phishing_url;
561 resource.original_url = phishing_url; 558 resource.original_url = phishing_url;
562 resource.is_subresource = false; 559 resource.is_subresource = false;
563 resource.threat_type = SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL; 560 resource.threat_type = SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL;
564 resource.threat_source = 561 resource.threat_source =
565 safe_browsing::ThreatSource::CLIENT_SIDE_DETECTION; 562 safe_browsing::ThreatSource::CLIENT_SIDE_DETECTION;
566 resource.render_process_host_id = 563 resource.web_contents_getter = safe_browsing::SafeBrowsingUIManager::
567 web_contents()->GetRenderProcessHost()->GetID(); 564 UnsafeResource::GetWebContentsGetter(
568 resource.render_frame_id = web_contents()->GetMainFrame()->GetRoutingID(); 565 web_contents()->GetRenderProcessHost()->GetID(),
566 web_contents()->GetMainFrame()->GetRoutingID());
569 if (!ui_manager_->IsWhitelisted(resource)) { 567 if (!ui_manager_->IsWhitelisted(resource)) {
570 // We need to stop any pending navigations, otherwise the interstital 568 // We need to stop any pending navigations, otherwise the interstital
571 // might not get created properly. 569 // might not get created properly.
572 web_contents()->GetController().DiscardNonCommittedEntries(); 570 web_contents()->GetController().DiscardNonCommittedEntries();
573 } 571 }
574 ui_manager_->DisplayBlockingPage(resource); 572 ui_manager_->DisplayBlockingPage(resource);
575 } 573 }
576 // If there is true phishing verdict, invalidate weakptr so that no longer 574 // If there is true phishing verdict, invalidate weakptr so that no longer
577 // consider the malware vedict. 575 // consider the malware vedict.
578 weak_factory_.InvalidateWeakPtrs(); 576 weak_factory_.InvalidateWeakPtrs();
(...skipping 12 matching lines...) Expand all
591 if (is_malware && malware_url.is_valid() && original_url.is_valid()) { 589 if (is_malware && malware_url.is_valid() && original_url.is_valid()) {
592 DCHECK(web_contents()); 590 DCHECK(web_contents());
593 if (ui_manager_.get()) { 591 if (ui_manager_.get()) {
594 SafeBrowsingUIManager::UnsafeResource resource; 592 SafeBrowsingUIManager::UnsafeResource resource;
595 resource.url = malware_url; 593 resource.url = malware_url;
596 resource.original_url = original_url; 594 resource.original_url = original_url;
597 resource.is_subresource = (malware_url.host() != original_url.host()); 595 resource.is_subresource = (malware_url.host() != original_url.host());
598 resource.threat_type = SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL; 596 resource.threat_type = SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL;
599 resource.threat_source = 597 resource.threat_source =
600 safe_browsing::ThreatSource::CLIENT_SIDE_DETECTION; 598 safe_browsing::ThreatSource::CLIENT_SIDE_DETECTION;
601 resource.render_process_host_id = 599 resource.web_contents_getter = safe_browsing::SafeBrowsingUIManager::
602 web_contents()->GetRenderProcessHost()->GetID(); 600 UnsafeResource::GetWebContentsGetter(
603 resource.render_frame_id = web_contents()->GetMainFrame()->GetRoutingID(); 601 web_contents()->GetRenderProcessHost()->GetID(),
602 web_contents()->GetMainFrame()->GetRoutingID());
604 603
605 if (!ui_manager_->IsWhitelisted(resource)) { 604 if (!ui_manager_->IsWhitelisted(resource)) {
606 // We need to stop any pending navigations, otherwise the interstital 605 // We need to stop any pending navigations, otherwise the interstital
607 // might not get created properly. 606 // might not get created properly.
608 web_contents()->GetController().DiscardNonCommittedEntries(); 607 web_contents()->GetController().DiscardNonCommittedEntries();
609 } 608 }
610 ui_manager_->DisplayBlockingPage(resource); 609 ui_manager_->DisplayBlockingPage(resource);
611 } 610 }
612 // If there is true malware verdict, invalidate weakptr so that no longer 611 // If there is true malware verdict, invalidate weakptr so that no longer
613 // consider the phishing vedict. 612 // consider the phishing vedict.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 ui_manager_->RemoveObserver(this); 715 ui_manager_->RemoveObserver(this);
717 716
718 ui_manager_ = ui_manager; 717 ui_manager_ = ui_manager;
719 if (ui_manager) 718 if (ui_manager)
720 ui_manager_->AddObserver(this); 719 ui_manager_->AddObserver(this);
721 720
722 database_manager_ = database_manager; 721 database_manager_ = database_manager;
723 } 722 }
724 723
725 } // namespace safe_browsing 724 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698