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

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

Issue 7134017: Make safe browsing work in a multi-profile environment. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: final tweaks 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/client_side_detection_host.h" 5 #include "chrome/browser/safe_browsing/client_side_detection_host.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/task.h" 13 #include "base/task.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/prefs/pref_service.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" 17 #include "chrome/browser/safe_browsing/browser_feature_extractor.h"
17 #include "chrome/browser/safe_browsing/client_side_detection_service.h" 18 #include "chrome/browser/safe_browsing/client_side_detection_service.h"
18 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 19 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
19 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/pref_names.h"
20 #include "chrome/common/safe_browsing/csd.pb.h" 22 #include "chrome/common/safe_browsing/csd.pb.h"
21 #include "chrome/common/safe_browsing/safebrowsing_messages.h" 23 #include "chrome/common/safe_browsing/safebrowsing_messages.h"
22 #include "content/browser/browser_thread.h" 24 #include "content/browser/browser_thread.h"
23 #include "content/browser/renderer_host/render_process_host.h" 25 #include "content/browser/renderer_host/render_process_host.h"
24 #include "content/browser/renderer_host/render_view_host.h" 26 #include "content/browser/renderer_host/render_view_host.h"
25 #include "content/browser/renderer_host/render_view_host_delegate.h" 27 #include "content/browser/renderer_host/render_view_host_delegate.h"
26 #include "content/browser/renderer_host/resource_dispatcher_host.h" 28 #include "content/browser/renderer_host/resource_dispatcher_host.h"
27 #include "content/browser/renderer_host/resource_request_details.h" 29 #include "content/browser/renderer_host/resource_request_details.h"
28 #include "content/browser/tab_contents/navigation_details.h" 30 #include "content/browser/tab_contents/navigation_details.h"
29 #include "content/browser/tab_contents/tab_contents.h" 31 #include "content/browser/tab_contents/tab_contents.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 }; 261 };
260 262
261 // static 263 // static
262 ClientSideDetectionHost* ClientSideDetectionHost::Create( 264 ClientSideDetectionHost* ClientSideDetectionHost::Create(
263 TabContents* tab) { 265 TabContents* tab) {
264 return new ClientSideDetectionHost(tab); 266 return new ClientSideDetectionHost(tab);
265 } 267 }
266 268
267 ClientSideDetectionHost::ClientSideDetectionHost(TabContents* tab) 269 ClientSideDetectionHost::ClientSideDetectionHost(TabContents* tab)
268 : TabContentsObserver(tab), 270 : TabContentsObserver(tab),
269 csd_service_(g_browser_process->safe_browsing_detection_service()),
270 feature_extractor_(
271 new BrowserFeatureExtractor(
272 tab,
273 g_browser_process->safe_browsing_detection_service())),
274 cb_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 271 cb_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
275 DCHECK(tab); 272 DCHECK(tab);
273 if (tab->profile()->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) {
274 csd_service_ = g_browser_process->safe_browsing_detection_service();
275 feature_extractor_.reset(new BrowserFeatureExtractor(tab, csd_service_));
276 } else {
277 csd_service_ = NULL;
278 feature_extractor_.reset(new BrowserFeatureExtractor(tab, NULL));
279 }
276 // Note: csd_service_ and sb_service_ might be NULL. 280 // Note: csd_service_ and sb_service_ might be NULL.
277 sb_service_ = g_browser_process->safe_browsing_service(); 281 sb_service_ = g_browser_process->safe_browsing_service();
278 registrar_.Add(this, NotificationType::RESOURCE_RESPONSE_STARTED, 282 registrar_.Add(this, NotificationType::RESOURCE_RESPONSE_STARTED,
279 Source<RenderViewHostDelegate>(tab)); 283 Source<RenderViewHostDelegate>(tab));
280 } 284 }
281 285
282 ClientSideDetectionHost::~ClientSideDetectionHost() {} 286 ClientSideDetectionHost::~ClientSideDetectionHost() {}
283 287
284 bool ClientSideDetectionHost::OnMessageReceived(const IPC::Message& message) { 288 bool ClientSideDetectionHost::OnMessageReceived(const IPC::Message& message) {
285 bool handled = true; 289 bool handled = true;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 ClientSideDetectionService* service) { 443 ClientSideDetectionService* service) {
440 csd_service_ = service; 444 csd_service_ = service;
441 } 445 }
442 446
443 void ClientSideDetectionHost::set_safe_browsing_service( 447 void ClientSideDetectionHost::set_safe_browsing_service(
444 SafeBrowsingService* service) { 448 SafeBrowsingService* service) {
445 sb_service_ = service; 449 sb_service_ = service;
446 } 450 }
447 451
448 } // namespace safe_browsing 452 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698