| 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 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1362 AddPrefService(profile->GetPrefs()); | 1362 AddPrefService(profile->GetPrefs()); |
| 1363 break; | 1363 break; |
| 1364 } | 1364 } |
| 1365 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 1365 case chrome::NOTIFICATION_PROFILE_DESTROYED: { |
| 1366 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1366 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1367 Profile* profile = content::Source<Profile>(source).ptr(); | 1367 Profile* profile = content::Source<Profile>(source).ptr(); |
| 1368 if (!profile->IsOffTheRecord()) | 1368 if (!profile->IsOffTheRecord()) |
| 1369 RemovePrefService(profile->GetPrefs()); | 1369 RemovePrefService(profile->GetPrefs()); |
| 1370 break; | 1370 break; |
| 1371 } | 1371 } |
| 1372 case chrome::NOTIFICATION_PREF_CHANGED: { | |
| 1373 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 1374 std::string* pref = content::Details<std::string>(details).ptr(); | |
| 1375 DCHECK(*pref == prefs::kSafeBrowsingEnabled); | |
| 1376 RefreshState(); | |
| 1377 break; | |
| 1378 } | |
| 1379 default: | 1372 default: |
| 1380 NOTREACHED(); | 1373 NOTREACHED(); |
| 1381 } | 1374 } |
| 1382 } | 1375 } |
| 1383 | 1376 |
| 1377 void SafeBrowsingService::OnPreferenceChanged(PrefServiceBase* service, |
| 1378 const std::string& pref_name) { |
| 1379 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1380 DCHECK(pref_name == prefs::kSafeBrowsingEnabled); |
| 1381 RefreshState(); |
| 1382 } |
| 1383 |
| 1384 bool SafeBrowsingService::IsWhitelisted(const UnsafeResource& resource) { | 1384 bool SafeBrowsingService::IsWhitelisted(const UnsafeResource& resource) { |
| 1385 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1385 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1386 // Check if the user has already ignored our warning for this render_view | 1386 // Check if the user has already ignored our warning for this render_view |
| 1387 // and domain. | 1387 // and domain. |
| 1388 for (size_t i = 0; i < white_listed_entries_.size(); ++i) { | 1388 for (size_t i = 0; i < white_listed_entries_.size(); ++i) { |
| 1389 const WhiteListedEntry& entry = white_listed_entries_[i]; | 1389 const WhiteListedEntry& entry = white_listed_entries_[i]; |
| 1390 if (entry.render_process_host_id == resource.render_process_host_id && | 1390 if (entry.render_process_host_id == resource.render_process_host_id && |
| 1391 entry.render_view_id == resource.render_view_id && | 1391 entry.render_view_id == resource.render_view_id && |
| 1392 // Threat type must be the same or in the case of phishing they can | 1392 // Threat type must be the same or in the case of phishing they can |
| 1393 // either be client-side phishing URL or a SafeBrowsing phishing URL. | 1393 // either be client-side phishing URL or a SafeBrowsing phishing URL. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1443 Stop(); | 1443 Stop(); |
| 1444 | 1444 |
| 1445 if (csd_service_.get()) | 1445 if (csd_service_.get()) |
| 1446 csd_service_->SetEnabledAndRefreshState(enable); | 1446 csd_service_->SetEnabledAndRefreshState(enable); |
| 1447 if (download_service_.get()) { | 1447 if (download_service_.get()) { |
| 1448 download_service_->SetEnabled( | 1448 download_service_->SetEnabled( |
| 1449 enable && !CommandLine::ForCurrentProcess()->HasSwitch( | 1449 enable && !CommandLine::ForCurrentProcess()->HasSwitch( |
| 1450 switches::kDisableImprovedDownloadProtection)); | 1450 switches::kDisableImprovedDownloadProtection)); |
| 1451 } | 1451 } |
| 1452 } | 1452 } |
| OLD | NEW |