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

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

Issue 9473001: Extract minimal RenderViewHost interface for embedders, leaving (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to LKGR. Created 8 years, 9 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 | Annotate | Revision Log
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 <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 return; 211 return;
212 } 212 }
213 213
214 // Everything checks out, so start classification. 214 // Everything checks out, so start classification.
215 // |web_contents_| is safe to call as we will be destructed 215 // |web_contents_| is safe to call as we will be destructed
216 // before it is. 216 // before it is.
217 VLOG(1) << "Instruct renderer to start phishing detection for URL: " 217 VLOG(1) << "Instruct renderer to start phishing detection for URL: "
218 << params_.url; 218 << params_.url;
219 RenderViewHost* rvh = web_contents_->GetRenderViewHost(); 219 RenderViewHost* rvh = web_contents_->GetRenderViewHost();
220 rvh->Send(new SafeBrowsingMsg_StartPhishingDetection( 220 rvh->Send(new SafeBrowsingMsg_StartPhishingDetection(
221 rvh->routing_id(), params_.url)); 221 rvh->GetRoutingID(), params_.url));
222 } 222 }
223 223
224 // No need to protect |canceled_| with a lock because it is only read and 224 // No need to protect |canceled_| with a lock because it is only read and
225 // written by the UI thread. 225 // written by the UI thread.
226 bool canceled_; 226 bool canceled_;
227 content::FrameNavigateParams params_; 227 content::FrameNavigateParams params_;
228 WebContents* web_contents_; 228 WebContents* web_contents_;
229 ClientSideDetectionService* csd_service_; 229 ClientSideDetectionService* csd_service_;
230 // We keep a ref pointer here just to make sure the service class stays alive 230 // We keep a ref pointer here just to make sure the service class stays alive
231 // long enough. 231 // long enough.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 } 322 }
323 323
324 void ClientSideDetectionHost::OnSafeBrowsingHit( 324 void ClientSideDetectionHost::OnSafeBrowsingHit(
325 const SafeBrowsingService::UnsafeResource& resource) { 325 const SafeBrowsingService::UnsafeResource& resource) {
326 // Check that this notification is really for us and that it corresponds to 326 // Check that this notification is really for us and that it corresponds to
327 // either a malware or phishing hit. In this case we store the unique page 327 // either a malware or phishing hit. In this case we store the unique page
328 // ID for later. 328 // ID for later.
329 if (web_contents() && 329 if (web_contents() &&
330 web_contents()->GetRenderProcessHost()->GetID() == 330 web_contents()->GetRenderProcessHost()->GetID() ==
331 resource.render_process_host_id && 331 resource.render_process_host_id &&
332 web_contents()->GetRenderViewHost()->routing_id() == 332 web_contents()->GetRenderViewHost()->GetRoutingID() ==
333 resource.render_view_id && 333 resource.render_view_id &&
334 (resource.threat_type == SafeBrowsingService::URL_PHISHING || 334 (resource.threat_type == SafeBrowsingService::URL_PHISHING ||
335 resource.threat_type == SafeBrowsingService::URL_MALWARE) && 335 resource.threat_type == SafeBrowsingService::URL_MALWARE) &&
336 web_contents()->GetController().GetActiveEntry()) { 336 web_contents()->GetController().GetActiveEntry()) {
337 unsafe_unique_page_id_ = 337 unsafe_unique_page_id_ =
338 web_contents()->GetController().GetActiveEntry()->GetUniqueID(); 338 web_contents()->GetController().GetActiveEntry()->GetUniqueID();
339 // We also keep the resource around in order to be able to send the 339 // We also keep the resource around in order to be able to send the
340 // malicious URL to the server. 340 // malicious URL to the server.
341 unsafe_resource_.reset(new SafeBrowsingService::UnsafeResource(resource)); 341 unsafe_resource_.reset(new SafeBrowsingService::UnsafeResource(resource));
342 unsafe_resource_->callback.Reset(); // Don't do anything stupid. 342 unsafe_resource_->callback.Reset(); // Don't do anything stupid.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 DCHECK(web_contents()); 401 DCHECK(web_contents());
402 if (sb_service_) { 402 if (sb_service_) {
403 SafeBrowsingService::UnsafeResource resource; 403 SafeBrowsingService::UnsafeResource resource;
404 resource.url = phishing_url; 404 resource.url = phishing_url;
405 resource.original_url = phishing_url; 405 resource.original_url = phishing_url;
406 resource.is_subresource = false; 406 resource.is_subresource = false;
407 resource.threat_type = SafeBrowsingService::CLIENT_SIDE_PHISHING_URL; 407 resource.threat_type = SafeBrowsingService::CLIENT_SIDE_PHISHING_URL;
408 resource.render_process_host_id = 408 resource.render_process_host_id =
409 web_contents()->GetRenderProcessHost()->GetID(); 409 web_contents()->GetRenderProcessHost()->GetID();
410 resource.render_view_id = 410 resource.render_view_id =
411 web_contents()->GetRenderViewHost()->routing_id(); 411 web_contents()->GetRenderViewHost()->GetRoutingID();
412 if (!sb_service_->IsWhitelisted(resource)) { 412 if (!sb_service_->IsWhitelisted(resource)) {
413 // We need to stop any pending navigations, otherwise the interstital 413 // We need to stop any pending navigations, otherwise the interstital
414 // might not get created properly. 414 // might not get created properly.
415 web_contents()->GetController().DiscardNonCommittedEntries(); 415 web_contents()->GetController().DiscardNonCommittedEntries();
416 resource.callback = base::Bind(&EmptyUrlCheckCallback); 416 resource.callback = base::Bind(&EmptyUrlCheckCallback);
417 sb_service_->DoDisplayBlockingPage(resource); 417 sb_service_->DoDisplayBlockingPage(resource);
418 } 418 }
419 } 419 }
420 } 420 }
421 } 421 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 if (sb_service_) { 474 if (sb_service_) {
475 sb_service_->RemoveObserver(this); 475 sb_service_->RemoveObserver(this);
476 } 476 }
477 sb_service_ = service; 477 sb_service_ = service;
478 if (sb_service_) { 478 if (sb_service_) {
479 sb_service_->AddObserver(this); 479 sb_service_->AddObserver(this);
480 } 480 }
481 } 481 }
482 482
483 } // namespace safe_browsing 483 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698