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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 DCHECK(!enabled_); 486 DCHECK(!enabled_);
487 } 487 }
488 488
489 void SafeBrowsingService::OnIOInitialize( 489 void SafeBrowsingService::OnIOInitialize(
490 const std::string& client_key, 490 const std::string& client_key,
491 const std::string& wrapped_key, 491 const std::string& wrapped_key,
492 net::URLRequestContextGetter* request_context_getter) { 492 net::URLRequestContextGetter* request_context_getter) {
493 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 493 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
494 enabled_ = true; 494 enabled_ = true;
495 495
496 registrar_.Add(this, NotificationType::PURGE_MEMORY, 496 registrar_.Add(this, content::NOTIFICATION_PURGE_MEMORY,
497 NotificationService::AllSources()); 497 NotificationService::AllSources());
498 498
499 MakeDatabaseAvailable(); 499 MakeDatabaseAvailable();
500 500
501 // On Windows, get the safe browsing client name from the browser 501 // On Windows, get the safe browsing client name from the browser
502 // distribution classes in installer util. These classes don't yet have 502 // distribution classes in installer util. These classes don't yet have
503 // an analog on non-Windows builds so just keep the name specified here. 503 // an analog on non-Windows builds so just keep the name specified here.
504 #if defined(OS_WIN) 504 #if defined(OS_WIN)
505 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 505 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
506 std::string client_name(dist->GetSafeBrowsingName()); 506 std::string client_name(dist->GetSafeBrowsingName());
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 // Whitelist this domain and warning type for the given tab. 1201 // Whitelist this domain and warning type for the given tab.
1202 WhiteListedEntry entry; 1202 WhiteListedEntry entry;
1203 entry.render_process_host_id = resource.render_process_host_id; 1203 entry.render_process_host_id = resource.render_process_host_id;
1204 entry.render_view_id = resource.render_view_id; 1204 entry.render_view_id = resource.render_view_id;
1205 entry.domain = net::RegistryControlledDomainService::GetDomainAndRegistry( 1205 entry.domain = net::RegistryControlledDomainService::GetDomainAndRegistry(
1206 resource.url); 1206 resource.url);
1207 entry.result = resource.threat_type; 1207 entry.result = resource.threat_type;
1208 white_listed_entries_.push_back(entry); 1208 white_listed_entries_.push_back(entry);
1209 } 1209 }
1210 1210
1211 void SafeBrowsingService::Observe(NotificationType type, 1211 void SafeBrowsingService::Observe(int type,
1212 const NotificationSource& source, 1212 const NotificationSource& source,
1213 const NotificationDetails& details) { 1213 const NotificationDetails& details) {
1214 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1214 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1215 DCHECK(type == NotificationType::PURGE_MEMORY); 1215 DCHECK(type == content::NOTIFICATION_PURGE_MEMORY);
1216 CloseDatabase(); 1216 CloseDatabase();
1217 } 1217 }
1218 1218
1219 bool SafeBrowsingService::IsWhitelisted(const UnsafeResource& resource) { 1219 bool SafeBrowsingService::IsWhitelisted(const UnsafeResource& resource) {
1220 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1220 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1221 // Check if the user has already ignored our warning for this render_view 1221 // Check if the user has already ignored our warning for this render_view
1222 // and domain. 1222 // and domain.
1223 for (size_t i = 0; i < white_listed_entries_.size(); ++i) { 1223 for (size_t i = 0; i < white_listed_entries_.size(); ++i) {
1224 const WhiteListedEntry& entry = white_listed_entries_[i]; 1224 const WhiteListedEntry& entry = white_listed_entries_[i];
1225 if (entry.render_process_host_id == resource.render_process_host_id && 1225 if (entry.render_process_host_id == resource.render_process_host_id &&
1226 entry.render_view_id == resource.render_view_id && 1226 entry.render_view_id == resource.render_view_id &&
1227 // Threat type must be the same or in the case of phishing they can 1227 // Threat type must be the same or in the case of phishing they can
1228 // either be client-side phishing URL or a SafeBrowsing phishing URL. 1228 // either be client-side phishing URL or a SafeBrowsing phishing URL.
1229 // If we show one type of phishing warning we don't want to show a 1229 // If we show one type of phishing warning we don't want to show a
1230 // second phishing warning. 1230 // second phishing warning.
1231 (entry.result == resource.threat_type || 1231 (entry.result == resource.threat_type ||
1232 (entry.result == URL_PHISHING && 1232 (entry.result == URL_PHISHING &&
1233 resource.threat_type == CLIENT_SIDE_PHISHING_URL) || 1233 resource.threat_type == CLIENT_SIDE_PHISHING_URL) ||
1234 (entry.result == CLIENT_SIDE_PHISHING_URL && 1234 (entry.result == CLIENT_SIDE_PHISHING_URL &&
1235 resource.threat_type == URL_PHISHING)) && 1235 resource.threat_type == URL_PHISHING)) &&
1236 entry.domain == 1236 entry.domain ==
1237 net::RegistryControlledDomainService::GetDomainAndRegistry( 1237 net::RegistryControlledDomainService::GetDomainAndRegistry(
1238 resource.url)) { 1238 resource.url)) {
1239 return true; 1239 return true;
1240 } 1240 }
1241 } 1241 }
1242 return false; 1242 return false;
1243 } 1243 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service.h ('k') | chrome/browser/search_engines/search_provider_install_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698