| OLD | NEW |
| 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" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "content/public/browser/navigation_entry.h" | 30 #include "content/public/browser/navigation_entry.h" |
| 31 #include "content/public/browser/notification_details.h" | 31 #include "content/public/browser/notification_details.h" |
| 32 #include "content/public/browser/notification_source.h" | 32 #include "content/public/browser/notification_source.h" |
| 33 #include "content/public/browser/notification_types.h" | 33 #include "content/public/browser/notification_types.h" |
| 34 #include "content/public/browser/render_process_host.h" | 34 #include "content/public/browser/render_process_host.h" |
| 35 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
| 36 #include "content/public/common/frame_navigate_params.h" | 36 #include "content/public/common/frame_navigate_params.h" |
| 37 #include "googleurl/src/gurl.h" | 37 #include "googleurl/src/gurl.h" |
| 38 | 38 |
| 39 using content::BrowserThread; | 39 using content::BrowserThread; |
| 40 using content::NavigationEntry; |
| 40 using content::WebContents; | 41 using content::WebContents; |
| 41 | 42 |
| 42 namespace safe_browsing { | 43 namespace safe_browsing { |
| 43 | 44 |
| 44 // This class is instantiated each time a new toplevel URL loads, and | 45 // This class is instantiated each time a new toplevel URL loads, and |
| 45 // asynchronously checks whether the phishing classifier should run for this | 46 // asynchronously checks whether the phishing classifier should run for this |
| 46 // URL. If so, it notifies the renderer with a StartPhishingDetection IPC. | 47 // URL. If so, it notifies the renderer with a StartPhishingDetection IPC. |
| 47 // Objects of this class are ref-counted and will be destroyed once nobody | 48 // Objects of this class are ref-counted and will be destroyed once nobody |
| 48 // uses it anymore. If |tab_contents|, |csd_service| or |host| go away you need | 49 // uses it anymore. If |tab_contents|, |csd_service| or |host| go away you need |
| 49 // to call Cancel(). We keep the |sb_service| alive in a ref pointer for as | 50 // to call Cancel(). We keep the |sb_service| alive in a ref pointer for as |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 details).ptr(); | 469 details).ptr(); |
| 469 if (req && browse_info_.get()) { | 470 if (req && browse_info_.get()) { |
| 470 browse_info_->ips.insert(req->socket_address().host()); | 471 browse_info_->ips.insert(req->socket_address().host()); |
| 471 } | 472 } |
| 472 } | 473 } |
| 473 | 474 |
| 474 bool ClientSideDetectionHost::DidShowSBInterstitial() { | 475 bool ClientSideDetectionHost::DidShowSBInterstitial() { |
| 475 if (unsafe_unique_page_id_ <= 0 || !web_contents()) { | 476 if (unsafe_unique_page_id_ <= 0 || !web_contents()) { |
| 476 return false; | 477 return false; |
| 477 } | 478 } |
| 478 const content::NavigationEntry* nav_entry = | 479 const NavigationEntry* nav_entry = |
| 479 web_contents()->GetController().GetActiveEntry(); | 480 web_contents()->GetController().GetActiveEntry(); |
| 480 return (nav_entry && nav_entry->GetUniqueID() == unsafe_unique_page_id_); | 481 return (nav_entry && nav_entry->GetUniqueID() == unsafe_unique_page_id_); |
| 481 } | 482 } |
| 482 | 483 |
| 483 void ClientSideDetectionHost::set_client_side_detection_service( | 484 void ClientSideDetectionHost::set_client_side_detection_service( |
| 484 ClientSideDetectionService* service) { | 485 ClientSideDetectionService* service) { |
| 485 csd_service_ = service; | 486 csd_service_ = service; |
| 486 } | 487 } |
| 487 | 488 |
| 488 void ClientSideDetectionHost::set_safe_browsing_service( | 489 void ClientSideDetectionHost::set_safe_browsing_service( |
| 489 SafeBrowsingService* service) { | 490 SafeBrowsingService* service) { |
| 490 if (sb_service_) { | 491 if (sb_service_) { |
| 491 sb_service_->RemoveObserver(this); | 492 sb_service_->RemoveObserver(this); |
| 492 } | 493 } |
| 493 sb_service_ = service; | 494 sb_service_ = service; |
| 494 if (sb_service_) { | 495 if (sb_service_) { |
| 495 sb_service_->AddObserver(this); | 496 sb_service_->AddObserver(this); |
| 496 } | 497 } |
| 497 } | 498 } |
| 498 | 499 |
| 499 } // namespace safe_browsing | 500 } // namespace safe_browsing |
| OLD | NEW |