OLD | NEW |
---|---|
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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
281 bool ClientSideDetectionHost::OnMessageReceived(const IPC::Message& message) { | 281 bool ClientSideDetectionHost::OnMessageReceived(const IPC::Message& message) { |
282 bool handled = true; | 282 bool handled = true; |
283 IPC_BEGIN_MESSAGE_MAP(ClientSideDetectionHost, message) | 283 IPC_BEGIN_MESSAGE_MAP(ClientSideDetectionHost, message) |
284 IPC_MESSAGE_HANDLER(SafeBrowsingHostMsg_PhishingDetectionDone, | 284 IPC_MESSAGE_HANDLER(SafeBrowsingHostMsg_PhishingDetectionDone, |
285 OnPhishingDetectionDone) | 285 OnPhishingDetectionDone) |
286 IPC_MESSAGE_UNHANDLED(handled = false) | 286 IPC_MESSAGE_UNHANDLED(handled = false) |
287 IPC_END_MESSAGE_MAP() | 287 IPC_END_MESSAGE_MAP() |
288 return handled; | 288 return handled; |
289 } | 289 } |
290 | 290 |
291 // Should this be DidStartLoading instead? | |
mattm
2013/12/13 00:30:01
Hm, I'm not entirely sure.
The comment about "It
Greg Billock
2013/12/13 00:54:49
Yeah, that's the thing that made me worry.
mattm
2013/12/13 03:03:34
What do you mean by javascript urls? window.open?
| |
292 void ClientSideDetectionHost::DidStartNavigationToPendingEntry( | |
293 const GURL& url, | |
294 content::NavigationController::ReloadType reload_type) { | |
295 malware_or_phishing_match_ = false; | |
296 } | |
297 | |
291 void ClientSideDetectionHost::DidNavigateMainFrame( | 298 void ClientSideDetectionHost::DidNavigateMainFrame( |
292 const content::LoadCommittedDetails& details, | 299 const content::LoadCommittedDetails& details, |
293 const content::FrameNavigateParams& params) { | 300 const content::FrameNavigateParams& params) { |
294 malware_or_phishing_match_ = false; | |
295 | |
296 // TODO(noelutz): move this DCHECK to WebContents and fix all the unit tests | 301 // TODO(noelutz): move this DCHECK to WebContents and fix all the unit tests |
297 // that don't call this method on the UI thread. | 302 // that don't call this method on the UI thread. |
298 // DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 303 // DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
299 if (details.is_in_page) { | 304 if (details.is_in_page) { |
300 // If the navigation is within the same page, the user isn't really | 305 // If the navigation is within the same page, the user isn't really |
301 // navigating away. We don't need to cancel a pending callback or | 306 // navigating away. We don't need to cancel a pending callback or |
302 // begin a new classification. | 307 // begin a new classification. |
303 return; | 308 return; |
304 } | 309 } |
305 // If we navigate away and there currently is a pending phishing | 310 // If we navigate away and there currently is a pending phishing |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
365 const SafeBrowsingUIManager::UnsafeResource& resource) { | 370 const SafeBrowsingUIManager::UnsafeResource& resource) { |
366 malware_or_phishing_match_ = true; | 371 malware_or_phishing_match_ = true; |
367 } | 372 } |
368 | 373 |
369 scoped_refptr<SafeBrowsingDatabaseManager> | 374 scoped_refptr<SafeBrowsingDatabaseManager> |
370 ClientSideDetectionHost::database_manager() { | 375 ClientSideDetectionHost::database_manager() { |
371 return database_manager_; | 376 return database_manager_; |
372 } | 377 } |
373 | 378 |
374 bool ClientSideDetectionHost::DidPageReceiveSafeBrowsingMatch() const { | 379 bool ClientSideDetectionHost::DidPageReceiveSafeBrowsingMatch() const { |
380 // Don't report any malware match for pending entries until they're | |
381 // committed. This avoids reporting newly pending navigations as | |
382 // having matched the malware filter. | |
383 const NavigationEntry* nav_entry = | |
384 web_contents()->GetController().GetPendingEntry(); | |
385 if (nav_entry) | |
386 return malware_or_phishing_match_; | |
Scott Hess - ex-Googler
2013/12/12 21:28:44
I'm not sure I follow this. AFAICT, the reason yo
Greg Billock
2013/12/12 22:14:44
So in practice, the flaw I'm seeing is when switch
mattm
2013/12/13 00:30:01
It would be nice if there were tests for all the c
Greg Billock
2013/12/13 00:54:49
I think you're right. I'll take all this out and j
| |
387 | |
375 return malware_or_phishing_match_ || DidShowSBInterstitial(); | 388 return malware_or_phishing_match_ || DidShowSBInterstitial(); |
376 } | 389 } |
377 | 390 |
378 void ClientSideDetectionHost::WebContentsDestroyed(WebContents* tab) { | 391 void ClientSideDetectionHost::WebContentsDestroyed(WebContents* tab) { |
379 DCHECK(tab); | 392 DCHECK(tab); |
380 // Tell any pending classification request that it is being canceled. | 393 // Tell any pending classification request that it is being canceled. |
381 if (classification_request_.get()) { | 394 if (classification_request_.get()) { |
382 classification_request_->Cancel(); | 395 classification_request_->Cancel(); |
383 } | 396 } |
384 // Cancel all pending feature extractions. | 397 // Cancel all pending feature extractions. |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
615 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 628 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
616 return malware_killswitch_on_; | 629 return malware_killswitch_on_; |
617 } | 630 } |
618 | 631 |
619 void ClientSideDetectionHost::SetMalwareKillSwitch(bool killswitch_on) { | 632 void ClientSideDetectionHost::SetMalwareKillSwitch(bool killswitch_on) { |
620 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 633 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
621 malware_killswitch_on_ = killswitch_on; | 634 malware_killswitch_on_ = killswitch_on; |
622 } | 635 } |
623 | 636 |
624 } // namespace safe_browsing | 637 } // namespace safe_browsing |
OLD | NEW |