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

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

Issue 7080034: Currently, there is a bug in the way we show the csd phishing interstitial. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Address Brian's comments. Created 9 years, 6 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
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 void SafeBrowsingService::DisplayBlockingPage( 334 void SafeBrowsingService::DisplayBlockingPage(
335 const GURL& url, 335 const GURL& url,
336 const GURL& original_url, 336 const GURL& original_url,
337 const std::vector<GURL>& redirect_urls, 337 const std::vector<GURL>& redirect_urls,
338 ResourceType::Type resource_type, 338 ResourceType::Type resource_type,
339 UrlCheckResult result, 339 UrlCheckResult result,
340 Client* client, 340 Client* client,
341 int render_process_host_id, 341 int render_process_host_id,
342 int render_view_id) { 342 int render_view_id) {
343 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 343 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
344
345 // Check if the user has already ignored our warning for this render_view
346 // and domain.
347 for (size_t i = 0; i < white_listed_entries_.size(); ++i) {
348 const WhiteListedEntry& entry = white_listed_entries_[i];
349 if (entry.render_process_host_id == render_process_host_id &&
350 entry.render_view_id == render_view_id &&
351 entry.result == result &&
352 entry.domain ==
353 net::RegistryControlledDomainService::GetDomainAndRegistry(url)) {
354 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
355 this, &SafeBrowsingService::NotifyClientBlockingComplete,
356 client, true));
357 return;
358 }
359 }
360
361 UnsafeResource resource; 344 UnsafeResource resource;
362 resource.url = url; 345 resource.url = url;
363 resource.original_url = original_url; 346 resource.original_url = original_url;
364 resource.redirect_urls = redirect_urls; 347 resource.redirect_urls = redirect_urls;
365 resource.resource_type = resource_type; 348 resource.resource_type = resource_type;
366 resource.threat_type= result; 349 resource.threat_type= result;
367 resource.client = client; 350 resource.client = client;
368 resource.render_process_host_id = render_process_host_id; 351 resource.render_process_host_id = render_process_host_id;
369 resource.render_view_id = render_view_id; 352 resource.render_view_id = render_view_id;
370 353
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 429
447 void SafeBrowsingService::OnBlockingPageDone( 430 void SafeBrowsingService::OnBlockingPageDone(
448 const std::vector<UnsafeResource>& resources, 431 const std::vector<UnsafeResource>& resources,
449 bool proceed) { 432 bool proceed) {
450 for (std::vector<UnsafeResource>::const_iterator iter = resources.begin(); 433 for (std::vector<UnsafeResource>::const_iterator iter = resources.begin();
451 iter != resources.end(); ++iter) { 434 iter != resources.end(); ++iter) {
452 const UnsafeResource& resource = *iter; 435 const UnsafeResource& resource = *iter;
453 NotifyClientBlockingComplete(resource.client, proceed); 436 NotifyClientBlockingComplete(resource.client, proceed);
454 437
455 if (proceed) { 438 if (proceed) {
456 // Whitelist this domain and warning type for the given tab. 439 BrowserThread::PostTask(
457 WhiteListedEntry entry; 440 BrowserThread::UI,
458 entry.render_process_host_id = resource.render_process_host_id; 441 FROM_HERE,
459 entry.render_view_id = resource.render_view_id; 442 NewRunnableMethod(this,
460 entry.domain = net::RegistryControlledDomainService::GetDomainAndRegistry( 443 &SafeBrowsingService::UpdateWhitelist,
461 resource.url); 444 resource));
462 entry.result = resource.threat_type;
463 white_listed_entries_.push_back(entry);
464 } 445 }
465 } 446 }
466 } 447 }
467 448
468 void SafeBrowsingService::OnNewMacKeys(const std::string& client_key, 449 void SafeBrowsingService::OnNewMacKeys(const std::string& client_key,
469 const std::string& wrapped_key) { 450 const std::string& wrapped_key) {
470 PrefService* prefs = g_browser_process->local_state(); 451 PrefService* prefs = g_browser_process->local_state();
471 if (prefs) { 452 if (prefs) {
472 prefs->SetString(prefs::kSafeBrowsingClientKey, client_key); 453 prefs->SetString(prefs::kSafeBrowsingClientKey, client_key);
473 prefs->SetString(prefs::kSafeBrowsingWrappedKey, wrapped_key); 454 prefs->SetString(prefs::kSafeBrowsingWrappedKey, wrapped_key);
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 check->result = SAFE; 962 check->result = SAFE;
982 if (index != -1) 963 if (index != -1)
983 check->result = GetResultFromListname(full_hashes[index].list_name); 964 check->result = GetResultFromListname(full_hashes[index].list_name);
984 } 965 }
985 SafeBrowsingCheckDone(check); 966 SafeBrowsingCheckDone(check);
986 return (index != -1); 967 return (index != -1);
987 } 968 }
988 969
989 void SafeBrowsingService::DoDisplayBlockingPage( 970 void SafeBrowsingService::DoDisplayBlockingPage(
990 const UnsafeResource& resource) { 971 const UnsafeResource& resource) {
972 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
973 // Check if the user has already ignored our warning for this render_view
974 // and domain.
975 if (IsWhitelisted(resource)) {
976 BrowserThread::PostTask(
977 BrowserThread::IO, FROM_HERE,
978 NewRunnableMethod(this,
979 &SafeBrowsingService::NotifyClientBlockingComplete,
980 resource.client, true));
981 return;
982 }
983
991 // The tab might have been closed. 984 // The tab might have been closed.
992 TabContents* wc = 985 TabContents* wc =
993 tab_util::GetTabContentsByID(resource.render_process_host_id, 986 tab_util::GetTabContentsByID(resource.render_process_host_id,
994 resource.render_view_id); 987 resource.render_view_id);
995 988
996 if (!wc) { 989 if (!wc) {
997 // The tab is gone and we did not have a chance at showing the interstitial. 990 // The tab is gone and we did not have a chance at showing the interstitial.
998 // Just act as "Don't Proceed" was chosen. 991 // Just act as "Don't Proceed" was chosen.
999 std::vector<UnsafeResource> resources; 992 std::vector<UnsafeResource> resources;
1000 resources.push_back(resource); 993 resources.push_back(resource);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 check->is_download = true; 1182 check->is_download = true;
1190 check->timeout_task = 1183 check->timeout_task =
1191 NewRunnableMethod(this, &SafeBrowsingService::TimeoutCallback, check); 1184 NewRunnableMethod(this, &SafeBrowsingService::TimeoutCallback, check);
1192 checks_.insert(check); 1185 checks_.insert(check);
1193 1186
1194 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, task); 1187 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, task);
1195 1188
1196 MessageLoop::current()->PostDelayedTask( 1189 MessageLoop::current()->PostDelayedTask(
1197 FROM_HERE, check->timeout_task, timeout_ms); 1190 FROM_HERE, check->timeout_task, timeout_ms);
1198 } 1191 }
1192
1193 void SafeBrowsingService::UpdateWhitelist(UnsafeResource resource) {
1194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1195 // Whitelist this domain and warning type for the given tab.
1196 WhiteListedEntry entry;
1197 entry.render_process_host_id = resource.render_process_host_id;
1198 entry.render_view_id = resource.render_view_id;
1199 entry.domain = net::RegistryControlledDomainService::GetDomainAndRegistry(
1200 resource.url);
1201 entry.result = resource.threat_type;
1202 white_listed_entries_.push_back(entry);
1203 }
1204
1205 bool SafeBrowsingService::IsWhitelisted(const UnsafeResource& resource) {
1206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1207 // Check if the user has already ignored our warning for this render_view
1208 // and domain.
1209 for (size_t i = 0; i < white_listed_entries_.size(); ++i) {
1210 const WhiteListedEntry& entry = white_listed_entries_[i];
1211 if (entry.render_process_host_id == resource.render_process_host_id &&
1212 entry.render_view_id == resource.render_view_id &&
1213 // Threat type must be the same or in the case of phishing they can
1214 // either be client-side phishing URL or a SafeBrowsing phishing URL.
1215 // If we show one type of phishing warning we don't want to show a
1216 // second phishing warning.
1217 (entry.result == resource.threat_type ||
1218 (entry.result == URL_PHISHING &&
1219 resource.threat_type == CLIENT_SIDE_PHISHING_URL) ||
1220 (entry.result == CLIENT_SIDE_PHISHING_URL &&
1221 resource.threat_type == URL_PHISHING)) &&
1222 entry.domain ==
1223 net::RegistryControlledDomainService::GetDomainAndRegistry(
1224 resource.url)) {
1225 return true;
1226 }
1227 }
1228 return false;
1229 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698