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

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

Issue 1410853003: [Safe Browsing] Only check main frame and iframe URLs on Mobile, for speed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rm unecessary thread restriction that interferes with tests Created 5 years, 2 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
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/safe_browsing_service.h" 5 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 17 matching lines...) Expand all
28 #include "chrome/browser/safe_browsing/download_protection_service.h" 28 #include "chrome/browser/safe_browsing/download_protection_service.h"
29 #include "chrome/browser/safe_browsing/ping_manager.h" 29 #include "chrome/browser/safe_browsing/ping_manager.h"
30 #include "chrome/browser/safe_browsing/protocol_manager.h" 30 #include "chrome/browser/safe_browsing/protocol_manager.h"
31 #include "chrome/browser/safe_browsing/ui_manager.h" 31 #include "chrome/browser/safe_browsing/ui_manager.h"
32 #include "chrome/common/chrome_constants.h" 32 #include "chrome/common/chrome_constants.h"
33 #include "chrome/common/chrome_paths.h" 33 #include "chrome/common/chrome_paths.h"
34 #include "chrome/common/chrome_switches.h" 34 #include "chrome/common/chrome_switches.h"
35 #include "chrome/common/pref_names.h" 35 #include "chrome/common/pref_names.h"
36 #include "chrome/common/url_constants.h" 36 #include "chrome/common/url_constants.h"
37 #include "components/user_prefs/tracked/tracked_preference_validation_delegate.h " 37 #include "components/user_prefs/tracked/tracked_preference_validation_delegate.h "
38 #include "components/variations/variations_associated_data.h"
39 #include "content/public/browser/browser_thread.h" 38 #include "content/public/browser/browser_thread.h"
40 #include "content/public/browser/cookie_store_factory.h" 39 #include "content/public/browser/cookie_store_factory.h"
41 #include "content/public/browser/notification_service.h" 40 #include "content/public/browser/notification_service.h"
42 #include "net/cookies/cookie_monster.h" 41 #include "net/cookies/cookie_monster.h"
43 #include "net/extras/sqlite/cookie_crypto_delegate.h" 42 #include "net/extras/sqlite/cookie_crypto_delegate.h"
44 #include "net/url_request/url_request_context.h" 43 #include "net/url_request/url_request_context.h"
45 #include "net/url_request/url_request_context_getter.h" 44 #include "net/url_request/url_request_context_getter.h"
46 45
47 #if defined(OS_WIN) 46 #if defined(OS_WIN)
48 #include "chrome/installer/util/browser_distribution.h" 47 #include "chrome/installer/util/browser_distribution.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 86
88 // The backup URL prefix used when there are local network specific issues. 87 // The backup URL prefix used when there are local network specific issues.
89 const char kSbBackupNetworkErrorURLPrefix[] = 88 const char kSbBackupNetworkErrorURLPrefix[] =
90 "https://alt3-safebrowsing.google.com/safebrowsing"; 89 "https://alt3-safebrowsing.google.com/safebrowsing";
91 90
92 base::FilePath CookieFilePath() { 91 base::FilePath CookieFilePath() {
93 return base::FilePath( 92 return base::FilePath(
94 SafeBrowsingService::GetBaseFilename().value() + kCookiesFile); 93 SafeBrowsingService::GetBaseFilename().value() + kCookiesFile);
95 } 94 }
96 95
97 #if defined(SAFE_BROWSING_DB_REMOTE)
98 // Android field trial
99 const char kAndroidFieldExperiment[] = "SafeBrowsingAndroid";
100 const char kAndroidFieldParam[] = "enabled";
101 const char kAndroidCheckAllTypesParam[] = "check_all_resource_types";
102 const char kAndroidFieldParamEnabledValue[] = "true";
103 #endif // defined(SAFE_BROWSING_DB_REMOTE)
104 } // namespace 96 } // namespace
105 97
106 class SafeBrowsingURLRequestContextGetter 98 class SafeBrowsingURLRequestContextGetter
107 : public net::URLRequestContextGetter { 99 : public net::URLRequestContextGetter {
108 public: 100 public:
109 explicit SafeBrowsingURLRequestContextGetter( 101 explicit SafeBrowsingURLRequestContextGetter(
110 SafeBrowsingService* sb_service_); 102 SafeBrowsingService* sb_service_);
111 103
112 // Implementation for net::UrlRequestContextGetter. 104 // Implementation for net::UrlRequestContextGetter.
113 net::URLRequestContext* GetURLRequestContext() override; 105 net::URLRequestContext* GetURLRequestContext() override;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 SafeBrowsingService* SafeBrowsingService::CreateSafeBrowsingService() { 189 SafeBrowsingService* SafeBrowsingService::CreateSafeBrowsingService() {
198 if (!factory_) 190 if (!factory_)
199 factory_ = g_safe_browsing_service_factory_impl.Pointer(); 191 factory_ = g_safe_browsing_service_factory_impl.Pointer();
200 return factory_->CreateSafeBrowsingService(); 192 return factory_->CreateSafeBrowsingService();
201 } 193 }
202 194
203 SafeBrowsingService::SafeBrowsingService() 195 SafeBrowsingService::SafeBrowsingService()
204 : protocol_manager_(NULL), 196 : protocol_manager_(NULL),
205 ping_manager_(NULL), 197 ping_manager_(NULL),
206 enabled_(false), 198 enabled_(false),
207 enabled_by_prefs_(false) { 199 enabled_by_prefs_(false) {}
208 #if defined(SAFE_BROWSING_DB_REMOTE)
209 const std::string enabled_param = variations::GetVariationParamValue(
210 kAndroidFieldExperiment, kAndroidFieldParam);
211 is_android_field_trial_enabled_ =
212 (enabled_param == kAndroidFieldParamEnabledValue);
213
214 const std::string check_all_types_param = variations::GetVariationParamValue(
215 kAndroidFieldExperiment, kAndroidCheckAllTypesParam);
216 if (check_all_types_param == kAndroidFieldParamEnabledValue) {
217 resource_types_to_check_ = CHECK_ALL_RESOURCE_TYPES;
218 } else {
219 // Default
220 resource_types_to_check_ = CHECK_ONLY_DANGEROUS_TYPES;
221 }
222 #endif // defined(SAFE_BROWSING_DB_REMOTE)
223 }
224 200
225 SafeBrowsingService::~SafeBrowsingService() { 201 SafeBrowsingService::~SafeBrowsingService() {
226 // We should have already been shut down. If we're still enabled, then the 202 // We should have already been shut down. If we're still enabled, then the
227 // database isn't going to be closed properly, which could lead to corruption. 203 // database isn't going to be closed properly, which could lead to corruption.
228 DCHECK(!enabled_); 204 DCHECK(!enabled_);
229 } 205 }
230 206
231 void SafeBrowsingService::Initialize() { 207 void SafeBrowsingService::Initialize() {
232 url_request_context_getter_ = 208 url_request_context_getter_ =
233 new SafeBrowsingURLRequestContextGetter(this); 209 new SafeBrowsingURLRequestContextGetter(this);
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 635
660 state_callback_list_.Notify(); 636 state_callback_list_.Notify();
661 637
662 #if defined(FULL_SAFE_BROWSING) 638 #if defined(FULL_SAFE_BROWSING)
663 if (csd_service_) 639 if (csd_service_)
664 csd_service_->SetEnabledAndRefreshState(enable); 640 csd_service_->SetEnabledAndRefreshState(enable);
665 if (download_service_) 641 if (download_service_)
666 download_service_->SetEnabled(enable); 642 download_service_->SetEnabled(enable);
667 #endif 643 #endif
668 } 644 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service.h ('k') | chrome/browser/safe_browsing/test_database_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698