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

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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 return; 215 return;
216 } 216 }
217 SendModelToProcess(content::Source<RenderProcessHost>(source).ptr()); 217 SendModelToProcess(content::Source<RenderProcessHost>(source).ptr());
218 } 218 }
219 219
220 void ClientSideDetectionService::SendModelToProcess( 220 void ClientSideDetectionService::SendModelToProcess(
221 RenderProcessHost* process) { 221 RenderProcessHost* process) {
222 // The ClientSideDetectionService is enabled if _any_ active profile has 222 // The ClientSideDetectionService is enabled if _any_ active profile has
223 // SafeBrowsing turned on. Here we check the profile for each renderer 223 // SafeBrowsing turned on. Here we check the profile for each renderer
224 // process and only send the model to those that have SafeBrowsing enabled. 224 // process and only send the model to those that have SafeBrowsing enabled.
225 Profile* profile = Profile::FromBrowserContext(process->browser_context()); 225 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
226 std::string model; 226 std::string model;
227 if (profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) { 227 if (profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) {
228 VLOG(2) << "Sending phishing model to RenderProcessHost @" << process; 228 VLOG(2) << "Sending phishing model to RenderProcessHost @" << process;
229 model = model_str_; 229 model = model_str_;
230 } else { 230 } else {
231 VLOG(2) << "Disabling client-side phishing detection for " 231 VLOG(2) << "Disabling client-side phishing detection for "
232 << "RenderProcessHost @" << process; 232 << "RenderProcessHost @" << process;
233 } 233 }
234 process->Send(new SafeBrowsingMsg_SetPhishingModel(model)); 234 process->Send(new SafeBrowsingMsg_SetPhishingModel(model));
235 } 235 }
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 &whitelist_patterns); 575 &whitelist_patterns);
576 for (size_t j = 0; j < whitelist_patterns.size(); ++j) { 576 for (size_t j = 0; j < whitelist_patterns.size(); ++j) {
577 if (whitelist_patterns[j] == canonical_url_as_pattern) { 577 if (whitelist_patterns[j] == canonical_url_as_pattern) {
578 return true; 578 return true;
579 } 579 }
580 } 580 }
581 } 581 }
582 return false; 582 return false;
583 } 583 }
584 } // namespace safe_browsing 584 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698