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