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

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

Issue 11414083: Remove PrefObserver usage, batch 9. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to sort-of good revision (r169014). 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 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 Profile* profile = content::Source<Profile>(source).ptr(); 1368 Profile* profile = content::Source<Profile>(source).ptr();
1369 if (!profile->IsOffTheRecord()) 1369 if (!profile->IsOffTheRecord())
1370 RemovePrefService(profile->GetPrefs()); 1370 RemovePrefService(profile->GetPrefs());
1371 break; 1371 break;
1372 } 1372 }
1373 default: 1373 default:
1374 NOTREACHED(); 1374 NOTREACHED();
1375 } 1375 }
1376 } 1376 }
1377 1377
1378 void SafeBrowsingService::OnPreferenceChanged(PrefServiceBase* service,
1379 const std::string& pref_name) {
1380 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1381 DCHECK(pref_name == prefs::kSafeBrowsingEnabled);
1382 RefreshState();
1383 }
1384
1385 bool SafeBrowsingService::IsWhitelisted(const UnsafeResource& resource) { 1378 bool SafeBrowsingService::IsWhitelisted(const UnsafeResource& resource) {
1386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1379 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1387 // Check if the user has already ignored our warning for this render_view 1380 // Check if the user has already ignored our warning for this render_view
1388 // and domain. 1381 // and domain.
1389 for (size_t i = 0; i < white_listed_entries_.size(); ++i) { 1382 for (size_t i = 0; i < white_listed_entries_.size(); ++i) {
1390 const WhiteListedEntry& entry = white_listed_entries_[i]; 1383 const WhiteListedEntry& entry = white_listed_entries_[i];
1391 if (entry.render_process_host_id == resource.render_process_host_id && 1384 if (entry.render_process_host_id == resource.render_process_host_id &&
1392 entry.render_view_id == resource.render_view_id && 1385 entry.render_view_id == resource.render_view_id &&
1393 // Threat type must be the same or in the case of phishing they can 1386 // Threat type must be the same or in the case of phishing they can
1394 // either be client-side phishing URL or a SafeBrowsing phishing URL. 1387 // either be client-side phishing URL or a SafeBrowsing phishing URL.
(...skipping 10 matching lines...) Expand all
1405 return true; 1398 return true;
1406 } 1399 }
1407 } 1400 }
1408 return false; 1401 return false;
1409 } 1402 }
1410 1403
1411 void SafeBrowsingService::AddPrefService(PrefService* pref_service) { 1404 void SafeBrowsingService::AddPrefService(PrefService* pref_service) {
1412 DCHECK(prefs_map_.find(pref_service) == prefs_map_.end()); 1405 DCHECK(prefs_map_.find(pref_service) == prefs_map_.end());
1413 PrefChangeRegistrar* registrar = new PrefChangeRegistrar(); 1406 PrefChangeRegistrar* registrar = new PrefChangeRegistrar();
1414 registrar->Init(pref_service); 1407 registrar->Init(pref_service);
1415 registrar->Add(prefs::kSafeBrowsingEnabled, this); 1408 registrar->Add(prefs::kSafeBrowsingEnabled,
1409 base::Bind(&SafeBrowsingService::RefreshState,
1410 base::Unretained(this)));
1416 prefs_map_[pref_service] = registrar; 1411 prefs_map_[pref_service] = registrar;
1417 RefreshState(); 1412 RefreshState();
1418 } 1413 }
1419 1414
1420 void SafeBrowsingService::RemovePrefService(PrefService* pref_service) { 1415 void SafeBrowsingService::RemovePrefService(PrefService* pref_service) {
1421 if (prefs_map_.find(pref_service) != prefs_map_.end()) { 1416 if (prefs_map_.find(pref_service) != prefs_map_.end()) {
1422 delete prefs_map_[pref_service]; 1417 delete prefs_map_[pref_service];
1423 prefs_map_.erase(pref_service); 1418 prefs_map_.erase(pref_service);
1424 RefreshState(); 1419 RefreshState();
1425 } else { 1420 } else {
(...skipping 18 matching lines...) Expand all
1444 Stop(); 1439 Stop();
1445 1440
1446 if (csd_service_.get()) 1441 if (csd_service_.get())
1447 csd_service_->SetEnabledAndRefreshState(enable); 1442 csd_service_->SetEnabledAndRefreshState(enable);
1448 if (download_service_.get()) { 1443 if (download_service_.get()) {
1449 download_service_->SetEnabled( 1444 download_service_->SetEnabled(
1450 enable && !CommandLine::ForCurrentProcess()->HasSwitch( 1445 enable && !CommandLine::ForCurrentProcess()->HasSwitch(
1451 switches::kDisableImprovedDownloadProtection)); 1446 switches::kDisableImprovedDownloadProtection));
1452 } 1447 }
1453 } 1448 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service.h ('k') | chrome/browser/safe_browsing/safe_browsing_tab_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698