| 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_service.h" | 5 #include "chrome/browser/safe_browsing/client_side_detection_service.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 15 #include "base/task.h" | 15 #include "base/task.h" |
| 16 #include "base/time.h" | 16 #include "base/time.h" |
| 17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 20 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
| 21 #include "chrome/common/net/http_return.h" | 21 #include "chrome/common/net/http_return.h" |
| 22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 23 #include "chrome/common/safe_browsing/client_model.pb.h" | 23 #include "chrome/common/safe_browsing/client_model.pb.h" |
| 24 #include "chrome/common/safe_browsing/csd.pb.h" | 24 #include "chrome/common/safe_browsing/csd.pb.h" |
| 25 #include "chrome/common/safe_browsing/safebrowsing_messages.h" | 25 #include "chrome/common/safe_browsing/safebrowsing_messages.h" |
| 26 #include "content/browser/browser_thread.h" | 26 #include "content/browser/browser_thread.h" |
| 27 #include "content/browser/renderer_host/render_process_host.h" | 27 #include "content/browser/renderer_host/render_process_host.h" |
| 28 #include "content/common/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
| 29 #include "content/public/browser/notification_types.h" | 29 #include "content/public/browser/notification_types.h" |
| 30 #include "crypto/sha2.h" | 30 #include "crypto/sha2.h" |
| 31 #include "googleurl/src/gurl.h" | 31 #include "googleurl/src/gurl.h" |
| 32 #include "net/base/load_flags.h" | 32 #include "net/base/load_flags.h" |
| 33 #include "net/http/http_response_headers.h" | 33 #include "net/http/http_response_headers.h" |
| 34 #include "net/url_request/url_request_context_getter.h" | 34 #include "net/url_request/url_request_context_getter.h" |
| 35 #include "net/url_request/url_request_status.h" | 35 #include "net/url_request/url_request_status.h" |
| 36 | 36 |
| 37 namespace safe_browsing { | 37 namespace safe_browsing { |
| 38 | 38 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 63 ClientSideDetectionService::CacheState::CacheState(bool phish, base::Time time) | 63 ClientSideDetectionService::CacheState::CacheState(bool phish, base::Time time) |
| 64 : is_phishing(phish), | 64 : is_phishing(phish), |
| 65 timestamp(time) {} | 65 timestamp(time) {} |
| 66 | 66 |
| 67 ClientSideDetectionService::ClientSideDetectionService( | 67 ClientSideDetectionService::ClientSideDetectionService( |
| 68 net::URLRequestContextGetter* request_context_getter) | 68 net::URLRequestContextGetter* request_context_getter) |
| 69 : enabled_(false), | 69 : enabled_(false), |
| 70 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), | 70 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), |
| 71 request_context_getter_(request_context_getter) { | 71 request_context_getter_(request_context_getter) { |
| 72 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, | 72 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
| 73 NotificationService::AllBrowserContextsAndSources()); | 73 content::NotificationService::AllBrowserContextsAndSources()); |
| 74 } | 74 } |
| 75 | 75 |
| 76 ClientSideDetectionService::~ClientSideDetectionService() { | 76 ClientSideDetectionService::~ClientSideDetectionService() { |
| 77 method_factory_.RevokeAll(); | 77 method_factory_.RevokeAll(); |
| 78 STLDeleteContainerPairPointers(client_phishing_reports_.begin(), | 78 STLDeleteContainerPairPointers(client_phishing_reports_.begin(), |
| 79 client_phishing_reports_.end()); | 79 client_phishing_reports_.end()); |
| 80 client_phishing_reports_.clear(); | 80 client_phishing_reports_.clear(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 // static | 83 // static |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 &whitelist_patterns); | 573 &whitelist_patterns); |
| 574 for (size_t j = 0; j < whitelist_patterns.size(); ++j) { | 574 for (size_t j = 0; j < whitelist_patterns.size(); ++j) { |
| 575 if (whitelist_patterns[j] == canonical_url_as_pattern) { | 575 if (whitelist_patterns[j] == canonical_url_as_pattern) { |
| 576 return true; | 576 return true; |
| 577 } | 577 } |
| 578 } | 578 } |
| 579 } | 579 } |
| 580 return false; | 580 return false; |
| 581 } | 581 } |
| 582 } // namespace safe_browsing | 582 } // namespace safe_browsing |
| OLD | NEW |