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

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

Powered by Google App Engine
This is Rietveld 408576698