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

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

Issue 7863006: Add a whitelist for the new binary download protection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Brian's comment. Created 9 years, 3 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 | 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/safe_browsing_service.h" 5 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 factory_ = g_safe_browsing_service_factory_impl.Pointer(); 154 factory_ = g_safe_browsing_service_factory_impl.Pointer();
155 return factory_->CreateSafeBrowsingService(); 155 return factory_->CreateSafeBrowsingService();
156 } 156 }
157 157
158 SafeBrowsingService::SafeBrowsingService() 158 SafeBrowsingService::SafeBrowsingService()
159 : database_(NULL), 159 : database_(NULL),
160 protocol_manager_(NULL), 160 protocol_manager_(NULL),
161 enabled_(false), 161 enabled_(false),
162 enable_download_protection_(false), 162 enable_download_protection_(false),
163 enable_csd_whitelist_(false), 163 enable_csd_whitelist_(false),
164 enable_download_whitelist_(false),
164 update_in_progress_(false), 165 update_in_progress_(false),
165 database_update_in_progress_(false), 166 database_update_in_progress_(false),
166 closing_database_(false), 167 closing_database_(false),
167 download_urlcheck_timeout_ms_(kDownloadUrlCheckTimeoutMs), 168 download_urlcheck_timeout_ms_(kDownloadUrlCheckTimeoutMs),
168 download_hashcheck_timeout_ms_(kDownloadHashCheckTimeoutMs) { 169 download_hashcheck_timeout_ms_(kDownloadHashCheckTimeoutMs) {
169 #if !defined(OS_CHROMEOS) 170 #if !defined(OS_CHROMEOS)
170 if (!CommandLine::ForCurrentProcess()->HasSwitch( 171 if (!CommandLine::ForCurrentProcess()->HasSwitch(
171 switches::kDisableClientSidePhishingDetection) && 172 switches::kDisableClientSidePhishingDetection) &&
172 (!CommandLine::ForCurrentProcess()->HasSwitch( 173 (!CommandLine::ForCurrentProcess()->HasSwitch(
173 switches::kDisableSanitizedClientSidePhishingDetection) || 174 switches::kDisableSanitizedClientSidePhishingDetection) ||
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 681
681 FilePath path; 682 FilePath path;
682 bool result = PathService::Get(chrome::DIR_USER_DATA, &path); 683 bool result = PathService::Get(chrome::DIR_USER_DATA, &path);
683 DCHECK(result); 684 DCHECK(result);
684 path = path.Append(chrome::kSafeBrowsingBaseFilename); 685 path = path.Append(chrome::kSafeBrowsingBaseFilename);
685 686
686 const base::TimeTicks before = base::TimeTicks::Now(); 687 const base::TimeTicks before = base::TimeTicks::Now();
687 688
688 SafeBrowsingDatabase* database = 689 SafeBrowsingDatabase* database =
689 SafeBrowsingDatabase::Create(enable_download_protection_, 690 SafeBrowsingDatabase::Create(enable_download_protection_,
690 enable_csd_whitelist_); 691 enable_csd_whitelist_,
692 enable_download_whitelist_);
691 693
692 database->Init(path); 694 database->Init(path);
693 { 695 {
694 // Acquiring the lock here guarantees correct ordering between the writes to 696 // Acquiring the lock here guarantees correct ordering between the writes to
695 // the new database object above, and the setting of |databse_| below. 697 // the new database object above, and the setting of |databse_| below.
696 base::AutoLock lock(database_lock_); 698 base::AutoLock lock(database_lock_);
697 database_ = database; 699 database_ = database;
698 } 700 }
699 701
700 BrowserThread::PostTask( 702 BrowserThread::PostTask(
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 enable_csd_whitelist_ = false; 902 enable_csd_whitelist_ = false;
901 #else 903 #else
902 enable_csd_whitelist_ = 904 enable_csd_whitelist_ =
903 (!cmdline->HasSwitch(switches::kDisableClientSidePhishingDetection) && 905 (!cmdline->HasSwitch(switches::kDisableClientSidePhishingDetection) &&
904 (!cmdline->HasSwitch( 906 (!cmdline->HasSwitch(
905 switches::kDisableSanitizedClientSidePhishingDetection) || 907 switches::kDisableSanitizedClientSidePhishingDetection) ||
906 (local_state && 908 (local_state &&
907 local_state->GetBoolean(prefs::kMetricsReportingEnabled)))); 909 local_state->GetBoolean(prefs::kMetricsReportingEnabled))));
908 #endif 910 #endif
909 911
912 const PrefService::Preference* pref = (local_state ?
913 local_state->FindPreference(
914 prefs::kSafeBrowsingOptinDownloadProtectionEnabled) : NULL);
915 bool pref_value = false;
916 enable_download_whitelist_ = (pref &&
917 pref->GetValue()->GetAsBoolean(&pref_value) &&
918 pref_value);
mattm 2011/09/13 00:29:02 Oh, thinking about this a bit harder, this isn't q
noelutz 2011/09/13 20:35:39 That does seem a bit complicated. How about we al
mattm 2011/09/14 01:15:18 Yeah, just always updating it sounds fine.
919
910 BrowserThread::PostTask( 920 BrowserThread::PostTask(
911 BrowserThread::IO, FROM_HERE, 921 BrowserThread::IO, FROM_HERE,
912 NewRunnableMethod( 922 NewRunnableMethod(
913 this, &SafeBrowsingService::OnIOInitialize, client_key, wrapped_key, 923 this, &SafeBrowsingService::OnIOInitialize, client_key, wrapped_key,
914 request_context_getter)); 924 request_context_getter));
915 } 925 }
916 926
917 void SafeBrowsingService::Stop() { 927 void SafeBrowsingService::Stop() {
918 BrowserThread::PostTask( 928 BrowserThread::PostTask(
919 BrowserThread::IO, FROM_HERE, 929 BrowserThread::IO, FROM_HERE,
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 } 1352 }
1343 1353
1344 if (enable) 1354 if (enable)
1345 Start(); 1355 Start();
1346 else 1356 else
1347 Stop(); 1357 Stop();
1348 1358
1349 if (csd_service_.get()) 1359 if (csd_service_.get())
1350 csd_service_->SetEnabled(enable); 1360 csd_service_->SetEnabled(enable);
1351 } 1361 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698