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

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

Issue 8310014: Only send the client-side phishing model to a renderer if its profile has SafeBrowsing enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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 | « no previous file | 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/client_side_detection_service.h" 5 #include "chrome/browser/safe_browsing/client_side_detection_service.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/task.h" 15 #include "base/task.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/prefs/pref_service.h"
19 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/safe_browsing/browser_features.h" 20 #include "chrome/browser/safe_browsing/browser_features.h"
19 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 21 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
20 #include "chrome/common/net/http_return.h" 22 #include "chrome/common/net/http_return.h"
23 #include "chrome/common/pref_names.h"
21 #include "chrome/common/safe_browsing/client_model.pb.h" 24 #include "chrome/common/safe_browsing/client_model.pb.h"
22 #include "chrome/common/safe_browsing/csd.pb.h" 25 #include "chrome/common/safe_browsing/csd.pb.h"
23 #include "chrome/common/safe_browsing/safebrowsing_messages.h" 26 #include "chrome/common/safe_browsing/safebrowsing_messages.h"
24 #include "chrome/renderer/safe_browsing/features.h" 27 #include "chrome/renderer/safe_browsing/features.h"
25 #include "content/browser/browser_thread.h" 28 #include "content/browser/browser_thread.h"
26 #include "content/browser/renderer_host/render_process_host.h" 29 #include "content/browser/renderer_host/render_process_host.h"
27 #include "content/common/notification_service.h" 30 #include "content/common/notification_service.h"
28 #include "crypto/sha2.h" 31 #include "crypto/sha2.h"
29 #include "googleurl/src/gurl.h" 32 #include "googleurl/src/gurl.h"
30 #include "net/base/load_flags.h" 33 #include "net/base/load_flags.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 timestamp(time) {} 66 timestamp(time) {}
64 67
65 ClientSideDetectionService::ClientSideDetectionService( 68 ClientSideDetectionService::ClientSideDetectionService(
66 net::URLRequestContextGetter* request_context_getter) 69 net::URLRequestContextGetter* request_context_getter)
67 : enabled_(false), 70 : enabled_(false),
68 sb_service_(g_browser_process->safe_browsing_service()), 71 sb_service_(g_browser_process->safe_browsing_service()),
69 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), 72 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
70 request_context_getter_(request_context_getter) { 73 request_context_getter_(request_context_getter) {
71 InitializeAllowedFeatures(); 74 InitializeAllowedFeatures();
72 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, 75 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED,
73 NotificationService::AllSources()); 76 NotificationService::AllSources());
mattm 2011/10/18 01:26:46 Should change to NotificationService::AllBrowserCo
Brian Ryner 2011/10/18 22:02:23 Done.
74 } 77 }
75 78
76 ClientSideDetectionService::~ClientSideDetectionService() { 79 ClientSideDetectionService::~ClientSideDetectionService() {
77 method_factory_.RevokeAll(); 80 method_factory_.RevokeAll();
78 STLDeleteContainerPairPointers(client_phishing_reports_.begin(), 81 STLDeleteContainerPairPointers(client_phishing_reports_.begin(),
79 client_phishing_reports_.end()); 82 client_phishing_reports_.end());
80 client_phishing_reports_.clear(); 83 client_phishing_reports_.clear();
81 } 84 }
82 85
83 // static 86 // static
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 DCHECK(type == content::NOTIFICATION_RENDERER_PROCESS_CREATED); 209 DCHECK(type == content::NOTIFICATION_RENDERER_PROCESS_CREATED);
207 if (!model_.get()) { 210 if (!model_.get()) {
208 // Model might not be ready or maybe there was an error. 211 // Model might not be ready or maybe there was an error.
209 return; 212 return;
210 } 213 }
211 SendModelToProcess(Source<RenderProcessHost>(source).ptr()); 214 SendModelToProcess(Source<RenderProcessHost>(source).ptr());
212 } 215 }
213 216
214 void ClientSideDetectionService::SendModelToProcess( 217 void ClientSideDetectionService::SendModelToProcess(
215 RenderProcessHost* process) { 218 RenderProcessHost* process) {
216 VLOG(2) << "Sending phishing model to renderer"; 219 Profile* profile = Profile::FromBrowserContext(process->browser_context());
217 process->Send(new SafeBrowsingMsg_SetPhishingModel(model_str_)); 220 if (profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) {
221 VLOG(2) << "Sending phishing model to renderer";
222 process->Send(new SafeBrowsingMsg_SetPhishingModel(model_str_));
noelutz 2011/10/17 17:48:13 What if the renderer already has an older model?
223 }
218 } 224 }
219 225
220 void ClientSideDetectionService::SendModelToRenderers() { 226 void ClientSideDetectionService::SendModelToRenderers() {
221 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); 227 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator());
222 !i.IsAtEnd(); i.Advance()) { 228 !i.IsAtEnd(); i.Advance()) {
223 SendModelToProcess(i.GetCurrentValue()); 229 SendModelToProcess(i.GetCurrentValue());
224 } 230 }
225 } 231 }
226 232
227 void ClientSideDetectionService::ScheduleFetchModel(int64 delay_ms) { 233 void ClientSideDetectionService::ScheduleFetchModel(int64 delay_ms) {
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 &whitelist_patterns); 645 &whitelist_patterns);
640 for (size_t j = 0; j < whitelist_patterns.size(); ++j) { 646 for (size_t j = 0; j < whitelist_patterns.size(); ++j) {
641 if (whitelist_patterns[j] == canonical_url_as_pattern) { 647 if (whitelist_patterns[j] == canonical_url_as_pattern) {
642 return true; 648 return true;
643 } 649 }
644 } 650 }
645 } 651 }
646 return false; 652 return false;
647 } 653 }
648 } // namespace safe_browsing 654 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698