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

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: addressed sky's nit 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()), 271 csd_service_(NULL),
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)) { 272 cb_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
275 DCHECK(tab); 273 DCHECK(tab);
276 // Note: csd_service_ and sb_service_ might be NULL. 274 csd_service_ = g_browser_process->safe_browsing_detection_service();
275 feature_extractor_.reset(new BrowserFeatureExtractor(tab, csd_service_));
277 sb_service_ = g_browser_process->safe_browsing_service(); 276 sb_service_ = g_browser_process->safe_browsing_service();
277 // Note: csd_service_ and sb_service_ will be NULL here in testing.
278 registrar_.Add(this, content::NOTIFICATION_RESOURCE_RESPONSE_STARTED, 278 registrar_.Add(this, content::NOTIFICATION_RESOURCE_RESPONSE_STARTED,
279 Source<RenderViewHostDelegate>(tab)); 279 Source<RenderViewHostDelegate>(tab));
280 } 280 }
281 281
282 ClientSideDetectionHost::~ClientSideDetectionHost() {} 282 ClientSideDetectionHost::~ClientSideDetectionHost() {}
283 283
284 bool ClientSideDetectionHost::OnMessageReceived(const IPC::Message& message) { 284 bool ClientSideDetectionHost::OnMessageReceived(const IPC::Message& message) {
285 bool handled = true; 285 bool handled = true;
286 IPC_BEGIN_MESSAGE_MAP(ClientSideDetectionHost, message) 286 IPC_BEGIN_MESSAGE_MAP(ClientSideDetectionHost, message)
287 IPC_MESSAGE_HANDLER(SafeBrowsingHostMsg_DetectedPhishingSite, 287 IPC_MESSAGE_HANDLER(SafeBrowsingHostMsg_DetectedPhishingSite,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 ClientSideDetectionService* service) { 439 ClientSideDetectionService* service) {
440 csd_service_ = service; 440 csd_service_ = service;
441 } 441 }
442 442
443 void ClientSideDetectionHost::set_safe_browsing_service( 443 void ClientSideDetectionHost::set_safe_browsing_service(
444 SafeBrowsingService* service) { 444 SafeBrowsingService* service) {
445 sb_service_ = service; 445 sb_service_ = service;
446 } 446 }
447 447
448 } // namespace safe_browsing 448 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698