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

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

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

Powered by Google App Engine
This is Rietveld 408576698