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/safe_browsing_service.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 } | 265 } |
266 | 266 |
267 void SafeBrowsingService::Initialize() { | 267 void SafeBrowsingService::Initialize() { |
268 url_request_context_getter_ = | 268 url_request_context_getter_ = |
269 new SafeBrowsingURLRequestContextGetter(this); | 269 new SafeBrowsingURLRequestContextGetter(this); |
270 BrowserThread::PostTask( | 270 BrowserThread::PostTask( |
271 BrowserThread::IO, FROM_HERE, | 271 BrowserThread::IO, FROM_HERE, |
272 base::Bind( | 272 base::Bind( |
273 &SafeBrowsingService::InitURLRequestContextOnIOThread, this, | 273 &SafeBrowsingService::InitURLRequestContextOnIOThread, this, |
274 make_scoped_refptr(g_browser_process->system_request_context()))); | 274 make_scoped_refptr(g_browser_process->system_request_context()))); |
275 #if !defined(OS_CHROMEOS) | |
276 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 275 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
277 switches::kDisableClientSidePhishingDetection)) { | 276 switches::kDisableClientSidePhishingDetection)) { |
278 csd_service_.reset( | 277 csd_service_.reset( |
279 safe_browsing::ClientSideDetectionService::Create( | 278 safe_browsing::ClientSideDetectionService::Create( |
280 url_request_context_getter_)); | 279 url_request_context_getter_)); |
281 } | 280 } |
282 download_service_.reset(new safe_browsing::DownloadProtectionService( | 281 download_service_.reset(new safe_browsing::DownloadProtectionService( |
283 this, | 282 this, |
284 url_request_context_getter_)); | 283 url_request_context_getter_)); |
285 #endif | |
286 | 284 |
287 // Track the safe browsing preference of existing profiles. | 285 // Track the safe browsing preference of existing profiles. |
288 // The SafeBrowsingService will be started if any existing profile has the | 286 // The SafeBrowsingService will be started if any existing profile has the |
289 // preference enabled. It will also listen for updates to the preferences. | 287 // preference enabled. It will also listen for updates to the preferences. |
290 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 288 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
291 if (profile_manager) { | 289 if (profile_manager) { |
292 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles(); | 290 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles(); |
293 for (size_t i = 0; i < profiles.size(); ++i) { | 291 for (size_t i = 0; i < profiles.size(); ++i) { |
294 if (profiles[i]->IsOffTheRecord()) | 292 if (profiles[i]->IsOffTheRecord()) |
295 continue; | 293 continue; |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 | 995 |
998 void SafeBrowsingService::Start() { | 996 void SafeBrowsingService::Start() { |
999 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 997 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1000 | 998 |
1001 CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 999 CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
1002 enable_download_protection_ = | 1000 enable_download_protection_ = |
1003 !cmdline->HasSwitch(switches::kSbDisableDownloadProtection); | 1001 !cmdline->HasSwitch(switches::kSbDisableDownloadProtection); |
1004 | 1002 |
1005 // We only download the csd-whitelist if client-side phishing detection is | 1003 // We only download the csd-whitelist if client-side phishing detection is |
1006 // enabled. | 1004 // enabled. |
1007 #ifdef OS_CHROMEOS | |
1008 // Client-side detection is disabled on ChromeOS for now, so don't bother | |
1009 // downloading the whitelist. | |
1010 enable_csd_whitelist_ = false; | |
1011 #else | |
1012 enable_csd_whitelist_ = | 1005 enable_csd_whitelist_ = |
1013 !cmdline->HasSwitch(switches::kDisableClientSidePhishingDetection); | 1006 !cmdline->HasSwitch(switches::kDisableClientSidePhishingDetection); |
1014 #endif | |
1015 | 1007 |
1016 // TODO(noelutz): remove this boolean variable since it should always be true | 1008 // TODO(noelutz): remove this boolean variable since it should always be true |
1017 // if SafeBrowsing is enabled. Unfortunately, we have no test data for this | 1009 // if SafeBrowsing is enabled. Unfortunately, we have no test data for this |
1018 // list right now. This means that we need to be able to disable this list | 1010 // list right now. This means that we need to be able to disable this list |
1019 // for the SafeBrowsing test to pass. | 1011 // for the SafeBrowsing test to pass. |
1020 enable_download_whitelist_ = enable_csd_whitelist_; | 1012 enable_download_whitelist_ = enable_csd_whitelist_; |
1021 | 1013 |
1022 BrowserThread::PostTask( | 1014 BrowserThread::PostTask( |
1023 BrowserThread::IO, FROM_HERE, | 1015 BrowserThread::IO, FROM_HERE, |
1024 base::Bind(&SafeBrowsingService::StartOnIOThread, this)); | 1016 base::Bind(&SafeBrowsingService::StartOnIOThread, this)); |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1444 Stop(); | 1436 Stop(); |
1445 | 1437 |
1446 if (csd_service_.get()) | 1438 if (csd_service_.get()) |
1447 csd_service_->SetEnabledAndRefreshState(enable); | 1439 csd_service_->SetEnabledAndRefreshState(enable); |
1448 if (download_service_.get()) { | 1440 if (download_service_.get()) { |
1449 download_service_->SetEnabled( | 1441 download_service_->SetEnabled( |
1450 enable && !CommandLine::ForCurrentProcess()->HasSwitch( | 1442 enable && !CommandLine::ForCurrentProcess()->HasSwitch( |
1451 switches::kDisableImprovedDownloadProtection)); | 1443 switches::kDisableImprovedDownloadProtection)); |
1452 } | 1444 } |
1453 } | 1445 } |
OLD | NEW |