| Index: chrome/browser/safe_browsing/client_side_detection_host.cc
|
| ===================================================================
|
| --- chrome/browser/safe_browsing/client_side_detection_host.cc (revision 115777)
|
| +++ chrome/browser/safe_browsing/client_side_detection_host.cc (working copy)
|
| @@ -25,13 +25,13 @@
|
| #include "content/browser/renderer_host/render_view_host_delegate.h"
|
| #include "content/browser/renderer_host/resource_dispatcher_host.h"
|
| #include "content/browser/renderer_host/resource_request_details.h"
|
| -#include "content/browser/tab_contents/tab_contents.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/navigation_details.h"
|
| #include "content/public/browser/notification_details.h"
|
| #include "content/public/browser/notification_source.h"
|
| #include "content/public/browser/notification_types.h"
|
| #include "content/public/browser/render_process_host.h"
|
| +#include "content/public/browser/web_contents.h"
|
| #include "content/public/common/frame_navigate_params.h"
|
| #include "googleurl/src/gurl.h"
|
|
|
| @@ -52,18 +52,18 @@
|
| ClientSideDetectionHost::ShouldClassifyUrlRequest> {
|
| public:
|
| ShouldClassifyUrlRequest(const content::FrameNavigateParams& params,
|
| - TabContents* tab_contents,
|
| + WebContents* web_contents,
|
| ClientSideDetectionService* csd_service,
|
| SafeBrowsingService* sb_service,
|
| ClientSideDetectionHost* host)
|
| : canceled_(false),
|
| params_(params),
|
| - tab_contents_(tab_contents),
|
| + web_contents_(web_contents),
|
| csd_service_(csd_service),
|
| sb_service_(sb_service),
|
| host_(host) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| - DCHECK(tab_contents_);
|
| + DCHECK(web_contents_);
|
| DCHECK(csd_service_);
|
| DCHECK(sb_service_);
|
| DCHECK(host_);
|
| @@ -98,7 +98,7 @@
|
| }
|
|
|
| // Don't run the phishing classifier if the tab is incognito.
|
| - if (tab_contents_->GetBrowserContext()->IsOffTheRecord()) {
|
| + if (web_contents_->GetBrowserContext()->IsOffTheRecord()) {
|
| VLOG(1) << "Skipping phishing classification for URL: " << params_.url
|
| << " because we're browsing incognito.";
|
| UMA_HISTOGRAM_ENUMERATION("SBClientPhishing.PreClassificationCheckFail",
|
| @@ -125,7 +125,7 @@
|
| // Just to make sure we don't do anything stupid we reset all these
|
| // pointers except for the safebrowsing service class which may be
|
| // accessed by CheckCsdWhitelist().
|
| - tab_contents_ = NULL;
|
| + web_contents_ = NULL;
|
| csd_service_ = NULL;
|
| host_ = NULL;
|
| }
|
| @@ -201,11 +201,11 @@
|
| }
|
|
|
| // Everything checks out, so start classification.
|
| - // |tab_contents_| is safe to call as we will be destructed
|
| + // |web_contents_| is safe to call as we will be destructed
|
| // before it is.
|
| VLOG(1) << "Instruct renderer to start phishing detection for URL: "
|
| << params_.url;
|
| - RenderViewHost* rvh = tab_contents_->GetRenderViewHost();
|
| + RenderViewHost* rvh = web_contents_->GetRenderViewHost();
|
| rvh->Send(new SafeBrowsingMsg_StartPhishingDetection(
|
| rvh->routing_id(), params_.url));
|
| }
|
| @@ -214,7 +214,7 @@
|
| // written by the UI thread.
|
| bool canceled_;
|
| content::FrameNavigateParams params_;
|
| - TabContents* tab_contents_;
|
| + WebContents* web_contents_;
|
| ClientSideDetectionService* csd_service_;
|
| // We keep a ref pointer here just to make sure the service class stays alive
|
| // long enough.
|
| @@ -252,11 +252,11 @@
|
|
|
| // static
|
| ClientSideDetectionHost* ClientSideDetectionHost::Create(
|
| - TabContents* tab) {
|
| + WebContents* tab) {
|
| return new ClientSideDetectionHost(tab);
|
| }
|
|
|
| -ClientSideDetectionHost::ClientSideDetectionHost(TabContents* tab)
|
| +ClientSideDetectionHost::ClientSideDetectionHost(WebContents* tab)
|
| : content::WebContentsObserver(tab),
|
| csd_service_(NULL),
|
| weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
|
| @@ -267,7 +267,7 @@
|
| sb_service_ = g_browser_process->safe_browsing_service();
|
| // Note: csd_service_ and sb_service_ will be NULL here in testing.
|
| registrar_.Add(this, content::NOTIFICATION_RESOURCE_RESPONSE_STARTED,
|
| - content::Source<RenderViewHostDelegate>(tab));
|
| + content::Source<WebContents>(tab));
|
| if (sb_service_) {
|
| sb_service_->AddObserver(this);
|
| }
|
| @@ -292,7 +292,7 @@
|
| void ClientSideDetectionHost::DidNavigateMainFrame(
|
| const content::LoadCommittedDetails& details,
|
| const content::FrameNavigateParams& params) {
|
| - // TODO(noelutz): move this DCHECK to TabContents and fix all the unit tests
|
| + // TODO(noelutz): move this DCHECK to WebContents and fix all the unit tests
|
| // that don't call this method on the UI thread.
|
| // DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| if (details.is_in_page) {
|
| @@ -329,7 +329,7 @@
|
|
|
| // Notify the renderer if it should classify this URL.
|
| classification_request_ = new ShouldClassifyUrlRequest(params,
|
| - tab_contents(),
|
| + web_contents(),
|
| csd_service_,
|
| sb_service_,
|
| this);
|
| @@ -341,16 +341,16 @@
|
| // Check that this notification is really for us and that it corresponds to
|
| // either a malware or phishing hit. In this case we store the unique page
|
| // ID for later.
|
| - if (tab_contents() &&
|
| - tab_contents()->GetRenderProcessHost()->GetID() ==
|
| + if (web_contents() &&
|
| + web_contents()->GetRenderProcessHost()->GetID() ==
|
| resource.render_process_host_id &&
|
| - tab_contents()->GetRenderViewHost()->routing_id() ==
|
| + web_contents()->GetRenderViewHost()->routing_id() ==
|
| resource.render_view_id &&
|
| (resource.threat_type == SafeBrowsingService::URL_PHISHING ||
|
| resource.threat_type == SafeBrowsingService::URL_MALWARE) &&
|
| - tab_contents()->GetController().GetActiveEntry()) {
|
| + web_contents()->GetController().GetActiveEntry()) {
|
| unsafe_unique_page_id_ =
|
| - tab_contents()->GetController().GetActiveEntry()->GetUniqueID();
|
| + web_contents()->GetController().GetActiveEntry()->GetUniqueID();
|
| // We also keep the resource around in order to be able to send the
|
| // malicious URL to the server.
|
| unsafe_resource_.reset(new SafeBrowsingService::UnsafeResource(resource));
|
| @@ -413,7 +413,7 @@
|
| VLOG(2) << "Received server phishing verdict for URL:" << phishing_url
|
| << " is_phishing:" << is_phishing;
|
| if (is_phishing) {
|
| - DCHECK(tab_contents());
|
| + DCHECK(web_contents());
|
| if (sb_service_) {
|
| SafeBrowsingService::UnsafeResource resource;
|
| resource.url = phishing_url;
|
| @@ -421,13 +421,13 @@
|
| resource.is_subresource = false;
|
| resource.threat_type = SafeBrowsingService::CLIENT_SIDE_PHISHING_URL;
|
| resource.render_process_host_id =
|
| - tab_contents()->GetRenderProcessHost()->GetID();
|
| + web_contents()->GetRenderProcessHost()->GetID();
|
| resource.render_view_id =
|
| - tab_contents()->GetRenderViewHost()->routing_id();
|
| + web_contents()->GetRenderViewHost()->routing_id();
|
| if (!sb_service_->IsWhitelisted(resource)) {
|
| // We need to stop any pending navigations, otherwise the interstital
|
| // might not get created properly.
|
| - tab_contents()->GetController().DiscardNonCommittedEntries();
|
| + web_contents()->GetController().DiscardNonCommittedEntries();
|
| resource.client = new CsdClient(); // Will delete itself
|
| sb_service_->DoDisplayBlockingPage(resource);
|
| }
|
| @@ -471,11 +471,11 @@
|
| }
|
|
|
| bool ClientSideDetectionHost::DidShowSBInterstitial() {
|
| - if (unsafe_unique_page_id_ <= 0 || !tab_contents()) {
|
| + if (unsafe_unique_page_id_ <= 0 || !web_contents()) {
|
| return false;
|
| }
|
| const NavigationEntry* nav_entry =
|
| - tab_contents()->GetController().GetActiveEntry();
|
| + web_contents()->GetController().GetActiveEntry();
|
| return (nav_entry && nav_entry->GetUniqueID() == unsafe_unique_page_id_);
|
| }
|
|
|
|
|