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

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

Issue 8515027: Define the public version of the browser side RenderProcessHost interface. This interface is not ... (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
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/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"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/task.h" 13 #include "base/task.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/prefs/pref_service.h" 15 #include "chrome/browser/prefs/pref_service.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" 17 #include "chrome/browser/safe_browsing/browser_feature_extractor.h"
18 #include "chrome/browser/safe_browsing/client_side_detection_service.h" 18 #include "chrome/browser/safe_browsing/client_side_detection_service.h"
19 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 19 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
20 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
22 #include "chrome/common/safe_browsing/csd.pb.h" 22 #include "chrome/common/safe_browsing/csd.pb.h"
23 #include "chrome/common/safe_browsing/safebrowsing_messages.h" 23 #include "chrome/common/safe_browsing/safebrowsing_messages.h"
24 #include "content/browser/renderer_host/render_process_host.h"
25 #include "content/browser/renderer_host/render_view_host.h" 24 #include "content/browser/renderer_host/render_view_host.h"
26 #include "content/browser/renderer_host/render_view_host_delegate.h" 25 #include "content/browser/renderer_host/render_view_host_delegate.h"
27 #include "content/browser/renderer_host/resource_dispatcher_host.h" 26 #include "content/browser/renderer_host/resource_dispatcher_host.h"
28 #include "content/browser/renderer_host/resource_request_details.h" 27 #include "content/browser/renderer_host/resource_request_details.h"
29 #include "content/browser/tab_contents/navigation_details.h" 28 #include "content/browser/tab_contents/navigation_details.h"
30 #include "content/browser/tab_contents/tab_contents.h" 29 #include "content/browser/tab_contents/tab_contents.h"
31 #include "content/common/view_messages.h" 30 #include "content/common/view_messages.h"
32 #include "content/public/browser/browser_thread.h" 31 #include "content/public/browser/browser_thread.h"
33 #include "content/public/browser/notification_details.h" 32 #include "content/public/browser/notification_details.h"
34 #include "content/public/browser/notification_source.h" 33 #include "content/public/browser/notification_source.h"
35 #include "content/public/browser/notification_types.h" 34 #include "content/public/browser/notification_types.h"
35 #include "content/public/browser/render_process_host.h"
36 #include "googleurl/src/gurl.h" 36 #include "googleurl/src/gurl.h"
37 37
38 using content::BrowserThread; 38 using content::BrowserThread;
39 39
40 namespace safe_browsing { 40 namespace safe_browsing {
41 41
42 // This class is instantiated each time a new toplevel URL loads, and 42 // This class is instantiated each time a new toplevel URL loads, and
43 // asynchronously checks whether the phishing classifier should run for this 43 // asynchronously checks whether the phishing classifier should run for this
44 // URL. If so, it notifies the renderer with a StartPhishingDetection IPC. 44 // URL. If so, it notifies the renderer with a StartPhishingDetection IPC.
45 // Objects of this class are ref-counted and will be destroyed once nobody 45 // Objects of this class are ref-counted and will be destroyed once nobody
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 this); 336 this);
337 classification_request_->Start(); 337 classification_request_->Start();
338 } 338 }
339 339
340 void ClientSideDetectionHost::OnSafeBrowsingHit( 340 void ClientSideDetectionHost::OnSafeBrowsingHit(
341 const SafeBrowsingService::UnsafeResource& resource) { 341 const SafeBrowsingService::UnsafeResource& resource) {
342 // Check that this notification is really for us and that it corresponds to 342 // Check that this notification is really for us and that it corresponds to
343 // either a malware or phishing hit. In this case we store the unique page 343 // either a malware or phishing hit. In this case we store the unique page
344 // ID for later. 344 // ID for later.
345 if (tab_contents() && 345 if (tab_contents() &&
346 tab_contents()->GetRenderProcessHost()->id() == 346 tab_contents()->GetRenderProcessHost()->GetID() ==
347 resource.render_process_host_id && 347 resource.render_process_host_id &&
348 tab_contents()->render_view_host()->routing_id() == 348 tab_contents()->render_view_host()->routing_id() ==
349 resource.render_view_id && 349 resource.render_view_id &&
350 (resource.threat_type == SafeBrowsingService::URL_PHISHING || 350 (resource.threat_type == SafeBrowsingService::URL_PHISHING ||
351 resource.threat_type == SafeBrowsingService::URL_MALWARE) && 351 resource.threat_type == SafeBrowsingService::URL_MALWARE) &&
352 tab_contents()->controller().GetActiveEntry()) { 352 tab_contents()->controller().GetActiveEntry()) {
353 unsafe_unique_page_id_ = 353 unsafe_unique_page_id_ =
354 tab_contents()->controller().GetActiveEntry()->unique_id(); 354 tab_contents()->controller().GetActiveEntry()->unique_id();
355 // We also keep the resource around in order to be able to send the 355 // We also keep the resource around in order to be able to send the
356 // malicious URL to the server. 356 // malicious URL to the server.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 << " is_phishing:" << is_phishing; 414 << " is_phishing:" << is_phishing;
415 if (is_phishing) { 415 if (is_phishing) {
416 DCHECK(tab_contents()); 416 DCHECK(tab_contents());
417 if (sb_service_) { 417 if (sb_service_) {
418 SafeBrowsingService::UnsafeResource resource; 418 SafeBrowsingService::UnsafeResource resource;
419 resource.url = phishing_url; 419 resource.url = phishing_url;
420 resource.original_url = phishing_url; 420 resource.original_url = phishing_url;
421 resource.is_subresource = false; 421 resource.is_subresource = false;
422 resource.threat_type = SafeBrowsingService::CLIENT_SIDE_PHISHING_URL; 422 resource.threat_type = SafeBrowsingService::CLIENT_SIDE_PHISHING_URL;
423 resource.render_process_host_id = 423 resource.render_process_host_id =
424 tab_contents()->GetRenderProcessHost()->id(); 424 tab_contents()->GetRenderProcessHost()->GetID();
425 resource.render_view_id = 425 resource.render_view_id =
426 tab_contents()->render_view_host()->routing_id(); 426 tab_contents()->render_view_host()->routing_id();
427 if (!sb_service_->IsWhitelisted(resource)) { 427 if (!sb_service_->IsWhitelisted(resource)) {
428 // We need to stop any pending navigations, otherwise the interstital 428 // We need to stop any pending navigations, otherwise the interstital
429 // might not get created properly. 429 // might not get created properly.
430 tab_contents()->controller().DiscardNonCommittedEntries(); 430 tab_contents()->controller().DiscardNonCommittedEntries();
431 resource.client = new CsdClient(); // Will delete itself 431 resource.client = new CsdClient(); // Will delete itself
432 sb_service_->DoDisplayBlockingPage(resource); 432 sb_service_->DoDisplayBlockingPage(resource);
433 } 433 }
434 } 434 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 if (sb_service_) { 489 if (sb_service_) {
490 sb_service_->RemoveObserver(this); 490 sb_service_->RemoveObserver(this);
491 } 491 }
492 sb_service_ = service; 492 sb_service_ = service;
493 if (sb_service_) { 493 if (sb_service_) {
494 sb_service_->AddObserver(this); 494 sb_service_->AddObserver(this);
495 } 495 }
496 } 496 }
497 497
498 } // namespace safe_browsing 498 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698