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

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

Issue 8515027: Define the public version of the browser side RenderProcessHost interface. This interface is not ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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) 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/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.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/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/task.h" 15 #include "base/task.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "base/time.h" 17 #include "base/time.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/prefs/pref_service.h" 19 #include "chrome/browser/prefs/pref_service.h"
20 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/safe_browsing/safe_browsing_util.h" 21 #include "chrome/browser/safe_browsing/safe_browsing_util.h"
22 #include "chrome/common/net/http_return.h" 22 #include "chrome/common/net/http_return.h"
23 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
24 #include "chrome/common/safe_browsing/client_model.pb.h" 24 #include "chrome/common/safe_browsing/client_model.pb.h"
25 #include "chrome/common/safe_browsing/csd.pb.h" 25 #include "chrome/common/safe_browsing/csd.pb.h"
26 #include "chrome/common/safe_browsing/safebrowsing_messages.h" 26 #include "chrome/common/safe_browsing/safebrowsing_messages.h"
27 #include "content/browser/renderer_host/render_process_host.h"
28 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/notification_service.h" 28 #include "content/public/browser/notification_service.h"
30 #include "content/public/browser/notification_types.h" 29 #include "content/public/browser/notification_types.h"
30 #include "content/public/browser/render_process_host.h"
31 #include "content/public/common/url_fetcher.h" 31 #include "content/public/common/url_fetcher.h"
32 #include "crypto/sha2.h" 32 #include "crypto/sha2.h"
33 #include "googleurl/src/gurl.h" 33 #include "googleurl/src/gurl.h"
34 #include "net/base/load_flags.h" 34 #include "net/base/load_flags.h"
35 #include "net/http/http_response_headers.h" 35 #include "net/http/http_response_headers.h"
36 #include "net/url_request/url_request_context_getter.h" 36 #include "net/url_request/url_request_context_getter.h"
37 #include "net/url_request/url_request_status.h" 37 #include "net/url_request/url_request_status.h"
38 38
39 using content::BrowserThread; 39 using content::BrowserThread;
40 40
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 void ClientSideDetectionService::Observe( 207 void ClientSideDetectionService::Observe(
208 int type, 208 int type,
209 const content::NotificationSource& source, 209 const content::NotificationSource& source,
210 const content::NotificationDetails& details) { 210 const content::NotificationDetails& details) {
211 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 211 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
212 DCHECK(type == content::NOTIFICATION_RENDERER_PROCESS_CREATED); 212 DCHECK(type == content::NOTIFICATION_RENDERER_PROCESS_CREATED);
213 if (!model_.get()) { 213 if (!model_.get()) {
214 // Model might not be ready or maybe there was an error. 214 // Model might not be ready or maybe there was an error.
215 return; 215 return;
216 } 216 }
217 SendModelToProcess(content::Source<RenderProcessHost>(source).ptr()); 217 SendModelToProcess(
218 content::Source<content::RenderProcessHost>(source).ptr());
218 } 219 }
219 220
220 void ClientSideDetectionService::SendModelToProcess( 221 void ClientSideDetectionService::SendModelToProcess(
221 RenderProcessHost* process) { 222 content::RenderProcessHost* process) {
222 // The ClientSideDetectionService is enabled if _any_ active profile has 223 // The ClientSideDetectionService is enabled if _any_ active profile has
223 // SafeBrowsing turned on. Here we check the profile for each renderer 224 // SafeBrowsing turned on. Here we check the profile for each renderer
224 // process and only send the model to those that have SafeBrowsing enabled. 225 // process and only send the model to those that have SafeBrowsing enabled.
225 Profile* profile = Profile::FromBrowserContext(process->browser_context()); 226 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
226 std::string model; 227 std::string model;
227 if (profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) { 228 if (profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) {
228 VLOG(2) << "Sending phishing model to RenderProcessHost @" << process; 229 VLOG(2) << "Sending phishing model to RenderProcessHost @" << process;
229 model = model_str_; 230 model = model_str_;
230 } else { 231 } else {
231 VLOG(2) << "Disabling client-side phishing detection for " 232 VLOG(2) << "Disabling client-side phishing detection for "
232 << "RenderProcessHost @" << process; 233 << "RenderProcessHost @" << process;
233 } 234 }
234 process->Send(new SafeBrowsingMsg_SetPhishingModel(model)); 235 process->Send(new SafeBrowsingMsg_SetPhishingModel(model));
235 } 236 }
236 237
237 void ClientSideDetectionService::SendModelToRenderers() { 238 void ClientSideDetectionService::SendModelToRenderers() {
238 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); 239 for (content::RenderProcessHost::iterator i(
240 content::RenderProcessHost::AllHostsIterator());
239 !i.IsAtEnd(); i.Advance()) { 241 !i.IsAtEnd(); i.Advance()) {
240 SendModelToProcess(i.GetCurrentValue()); 242 SendModelToProcess(i.GetCurrentValue());
241 } 243 }
242 } 244 }
243 245
244 void ClientSideDetectionService::ScheduleFetchModel(int64 delay_ms) { 246 void ClientSideDetectionService::ScheduleFetchModel(int64 delay_ms) {
245 MessageLoop::current()->PostDelayedTask( 247 MessageLoop::current()->PostDelayedTask(
246 FROM_HERE, 248 FROM_HERE,
247 base::Bind(&ClientSideDetectionService::StartFetchModel, 249 base::Bind(&ClientSideDetectionService::StartFetchModel,
248 weak_factory_.GetWeakPtr()), 250 weak_factory_.GetWeakPtr()),
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 &whitelist_patterns); 577 &whitelist_patterns);
576 for (size_t j = 0; j < whitelist_patterns.size(); ++j) { 578 for (size_t j = 0; j < whitelist_patterns.size(); ++j) {
577 if (whitelist_patterns[j] == canonical_url_as_pattern) { 579 if (whitelist_patterns[j] == canonical_url_as_pattern) {
578 return true; 580 return true;
579 } 581 }
580 } 582 }
581 } 583 }
582 return false; 584 return false;
583 } 585 }
584 } // namespace safe_browsing 586 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/client_side_detection_service.h ('k') | chrome/browser/safe_browsing/malware_details_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698