summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_process_impl.cc
diff options
context:
space:
mode:
authornoelutz@google.com <noelutz@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-09 23:39:51 +0000
committernoelutz@google.com <noelutz@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-09 23:39:51 +0000
commita7a5e99010728cca53432ef392a44ce392c73353 (patch)
tree62250e23c35ab69bbc6a896ec33bf441470ee922 /chrome/browser/browser_process_impl.cc
parent0f2a30dbc1bf1d99adc0a67008e85550bff4fa9d (diff)
downloadchromium_src-a7a5e99010728cca53432ef392a44ce392c73353.zip
chromium_src-a7a5e99010728cca53432ef392a44ce392c73353.tar.gz
chromium_src-a7a5e99010728cca53432ef392a44ce392c73353.tar.bz2
Send phishing model from the browser to the renderer.
BUG=None TEST=None Review URL: http://codereview.chromium.org/5206006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68791 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_process_impl.cc')
-rw-r--r--chrome/browser/browser_process_impl.cc43
1 files changed, 43 insertions, 0 deletions
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 9a1201e..ea52797 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -44,6 +44,7 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
+#include "chrome/browser/safe_browsing/client_side_detection_service.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/browser/sidebar/sidebar_manager.h"
#include "chrome/browser/tab_closeable_state_watcher.h"
@@ -98,6 +99,7 @@ BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line)
created_devtools_manager_(false),
created_sidebar_manager_(false),
created_notification_ui_manager_(false),
+ created_safe_browsing_detection_service_(false),
module_ref_count_(0),
did_start_(false),
checked_for_new_frames_(false),
@@ -483,6 +485,15 @@ TabCloseableStateWatcher* BrowserProcessImpl::tab_closeable_state_watcher() {
return tab_closeable_state_watcher_.get();
}
+safe_browsing::ClientSideDetectionService*
+ BrowserProcessImpl::safe_browsing_detection_service() {
+ DCHECK(CalledOnValidThread());
+ if (!created_safe_browsing_detection_service_) {
+ CreateSafeBrowsingDetectionService();
+ }
+ return safe_browsing_detection_service_.get();
+}
+
void BrowserProcessImpl::CheckForInspectorFiles() {
file_thread()->message_loop()->PostTask
(FROM_HERE,
@@ -712,6 +723,38 @@ void BrowserProcessImpl::CreatePrintPreviewTabController() {
print_preview_tab_controller_ = new printing::PrintPreviewTabController();
}
+void BrowserProcessImpl::CreateSafeBrowsingDetectionService() {
+ DCHECK(safe_browsing_detection_service_.get() == NULL);
+ // Set this flag to true so that we don't retry indefinitely to
+ // create the service class if there was an error.
+ created_safe_browsing_detection_service_ = true;
+
+ FilePath model_file_path;
+ Profile* profile = profile_manager() ?
+ profile_manager()->GetDefaultProfile() : NULL;
+ if (IsSafeBrowsingDetectionServiceEnabled() &&
+ PathService::Get(chrome::DIR_USER_DATA, &model_file_path) &&
+ profile && profile->GetRequestContext()) {
+ safe_browsing_detection_service_.reset(
+ safe_browsing::ClientSideDetectionService::Create(
+ model_file_path.Append(chrome::kSafeBrowsingPhishingModelFilename),
+ profile->GetRequestContext()));
+ }
+}
+
+bool BrowserProcessImpl::IsSafeBrowsingDetectionServiceEnabled() {
+ // The safe browsing client-side detection is enabled only if the switch is
+ // enabled, the user has opted in to UMA usage stats and SafeBrowsing
+ // is enabled.
+ Profile* profile = profile_manager() ?
+ profile_manager()->GetDefaultProfile() : NULL;
+ return (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableClientSidePhishingDetection) &&
+ metrics_service() && metrics_service()->reporting_active() &&
+ profile && profile->GetPrefs() &&
+ profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled));
+}
+
// The BrowserProcess object must outlive the file thread so we use traits
// which don't do any management.
DISABLE_RUNNABLE_METHOD_REFCOUNT(BrowserProcessImpl);