Commit ce717a5e authored by Tim Volodine's avatar Tim Volodine Committed by Commit Bot

[WebLayer] Add missing initialization bits for safebrowsing.

In this patch:
- Add safebrowsing threat types to watch (currently malware,
  phishing, unwanted and billing). This is needed by the
  RemoteSafeBrowsingDatabaseManager.
- Create and set native SafeBrowsingApiHandlerBridge during
  initialization. This is needed for native <-> java
  interactions.

BUG=1015418

Change-Id: I2ea97435a6e3885382ca6cad163337acd17dafa4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1901045Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Commit-Queue: Tim Volodine <timvolodine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713419}
parent 99a4d0a2
...@@ -169,6 +169,7 @@ jumbo_static_library("weblayer_lib") { ...@@ -169,6 +169,7 @@ jumbo_static_library("weblayer_lib") {
"//components/crash/android:crashpad_main", "//components/crash/android:crashpad_main",
"//components/safe_browsing", "//components/safe_browsing",
"//components/safe_browsing/android:remote_database_manager", "//components/safe_browsing/android:remote_database_manager",
"//components/safe_browsing/android:safe_browsing_api_handler",
"//components/safe_browsing/browser", "//components/safe_browsing/browser",
"//components/safe_browsing/browser:network_context", "//components/safe_browsing/browser:network_context",
"//components/safe_browsing/db:database_manager", "//components/safe_browsing/db:database_manager",
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/path_service.h" #include "base/path_service.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "components/safe_browsing/android/remote_database_manager.h" #include "components/safe_browsing/android/remote_database_manager.h"
#include "components/safe_browsing/android/safe_browsing_api_handler_bridge.h"
#include "components/safe_browsing/browser/browser_url_loader_throttle.h" #include "components/safe_browsing/browser/browser_url_loader_throttle.h"
#include "components/safe_browsing/browser/mojo_safe_browsing_impl.h" #include "components/safe_browsing/browser/mojo_safe_browsing_impl.h"
#include "components/safe_browsing/browser/safe_browsing_network_context.h" #include "components/safe_browsing/browser/safe_browsing_network_context.h"
...@@ -45,6 +46,11 @@ void SafeBrowsingService::Initialize() { ...@@ -45,6 +46,11 @@ void SafeBrowsingService::Initialize() {
return; return;
} }
safe_browsing_api_handler_.reset(
new safe_browsing::SafeBrowsingApiHandlerBridge());
safe_browsing::SafeBrowsingApiHandler::SetInstance(
safe_browsing_api_handler_.get());
base::FilePath user_data_dir; base::FilePath user_data_dir;
bool result = bool result =
base::PathService::Get(base::DIR_ANDROID_APP_DATA, &user_data_dir); base::PathService::Get(base::DIR_ANDROID_APP_DATA, &user_data_dir);
......
...@@ -26,6 +26,7 @@ class SharedURLLoaderFactory; ...@@ -26,6 +26,7 @@ class SharedURLLoaderFactory;
namespace safe_browsing { namespace safe_browsing {
class UrlCheckerDelegate; class UrlCheckerDelegate;
class RemoteSafeBrowsingDatabaseManager; class RemoteSafeBrowsingDatabaseManager;
class SafeBrowsingApiHandler;
class SafeBrowsingNetworkContext; class SafeBrowsingNetworkContext;
} // namespace safe_browsing } // namespace safe_browsing
...@@ -81,6 +82,9 @@ class SafeBrowsingService { ...@@ -81,6 +82,9 @@ class SafeBrowsingService {
scoped_refptr<safe_browsing::UrlCheckerDelegate> scoped_refptr<safe_browsing::UrlCheckerDelegate>
safe_browsing_url_checker_delegate_; safe_browsing_url_checker_delegate_;
std::unique_ptr<safe_browsing::SafeBrowsingApiHandler>
safe_browsing_api_handler_;
std::string user_agent_; std::string user_agent_;
DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService); DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService);
......
...@@ -13,7 +13,12 @@ UrlCheckerDelegateImpl::UrlCheckerDelegateImpl( ...@@ -13,7 +13,12 @@ UrlCheckerDelegateImpl::UrlCheckerDelegateImpl(
scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> database_manager, scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> database_manager,
scoped_refptr<SafeBrowsingUIManager> ui_manager) scoped_refptr<SafeBrowsingUIManager> ui_manager)
: database_manager_(std::move(database_manager)), : database_manager_(std::move(database_manager)),
ui_manager_(std::move(ui_manager)) {} ui_manager_(std::move(ui_manager)),
threat_types_(safe_browsing::CreateSBThreatTypeSet(
{safe_browsing::SB_THREAT_TYPE_URL_MALWARE,
safe_browsing::SB_THREAT_TYPE_URL_PHISHING,
safe_browsing::SB_THREAT_TYPE_URL_UNWANTED,
safe_browsing::SB_THREAT_TYPE_BILLING})) {}
UrlCheckerDelegateImpl::~UrlCheckerDelegateImpl() = default; UrlCheckerDelegateImpl::~UrlCheckerDelegateImpl() = default;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment