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

Unified Diff: android_webview/browser/aw_safe_browsing_ui_manager.cc

Issue 2932703003: Plumbing for safe browsing reporting for Android WebView. (Closed)
Patch Set: modify client name to android_webview Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/browser/aw_safe_browsing_ui_manager.h ('k') | android_webview/common/aw_paths.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/browser/aw_safe_browsing_ui_manager.cc
diff --git a/android_webview/browser/aw_safe_browsing_ui_manager.cc b/android_webview/browser/aw_safe_browsing_ui_manager.cc
index cf33463c1e22080ced25dee1270c52f7de603574..0dc54b9407a2a0f6405603e5b9b921ae69563c4c 100644
--- a/android_webview/browser/aw_safe_browsing_ui_manager.cc
+++ b/android_webview/browser/aw_safe_browsing_ui_manager.cc
@@ -5,15 +5,44 @@
#include "android_webview/browser/aw_safe_browsing_ui_manager.h"
#include "android_webview/browser/aw_safe_browsing_blocking_page.h"
+#include "android_webview/browser/net/aw_url_request_context_getter.h"
+#include "android_webview/common/aw_paths.h"
+#include "base/command_line.h"
+#include "base/path_service.h"
+#include "components/safe_browsing/base_ping_manager.h"
+#include "components/safe_browsing/base_ui_manager.h"
+#include "components/safe_browsing/browser/safe_browsing_url_request_context_getter.h"
+#include "components/safe_browsing/common/safebrowsing_constants.h"
+#include "components/safe_browsing/common/safebrowsing_switches.h"
#include "content/public/browser/browser_thread.h"
using content::BrowserThread;
using content::WebContents;
+namespace {
+
+std::string GetProtocolConfigClientName() {
+ // Return a webview specific client name, see crbug.com/732373 for details.
+ return "android_webview";
+}
+
+} // namespace
+
namespace android_webview {
-AwSafeBrowsingUIManager::AwSafeBrowsingUIManager() {
+AwSafeBrowsingUIManager::AwSafeBrowsingUIManager(
+ AwURLRequestContextGetter* browser_url_request_context_getter) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ // TODO(timvolodine): verify this is what we want regarding the directory.
+ base::FilePath user_data_dir;
+ bool result =
+ PathService::Get(android_webview::DIR_SAFE_BROWSING, &user_data_dir);
+ DCHECK(result);
+
+ url_request_context_getter_ =
+ new safe_browsing::SafeBrowsingURLRequestContextGetter(
+ browser_url_request_context_getter, user_data_dir);
}
AwSafeBrowsingUIManager::~AwSafeBrowsingUIManager() {}
@@ -47,4 +76,32 @@ int AwSafeBrowsingUIManager::GetErrorUiType(
return client->GetErrorUiType();
}
+void AwSafeBrowsingUIManager::SendSerializedThreatDetails(
+ const std::string& serialized) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ if (!ping_manager_) {
+ // Lazy creation of ping manager, needs to happen on IO thread.
+ safe_browsing::SafeBrowsingProtocolConfig config;
+ config.client_name = GetProtocolConfigClientName();
+ base::CommandLine* cmdline = ::base::CommandLine::ForCurrentProcess();
+ config.disable_auto_update =
+ cmdline->HasSwitch(::safe_browsing::switches::kSbDisableAutoUpdate);
+ config.url_prefix = ::safe_browsing::kSbDefaultURLPrefix;
+ config.backup_connect_error_url_prefix =
+ ::safe_browsing::kSbBackupConnectErrorURLPrefix;
+ config.backup_http_error_url_prefix =
+ ::safe_browsing::kSbBackupHttpErrorURLPrefix;
+ config.backup_network_error_url_prefix =
+ ::safe_browsing::kSbBackupNetworkErrorURLPrefix;
+ ping_manager_ = ::safe_browsing::BasePingManager::Create(
+ url_request_context_getter_.get(), config);
+ }
+
+ if (!serialized.empty()) {
+ DVLOG(1) << "Sending serialized threat details";
+ ping_manager_->ReportThreatDetails(serialized);
+ }
+}
+
} // namespace android_webview
« no previous file with comments | « android_webview/browser/aw_safe_browsing_ui_manager.h ('k') | android_webview/common/aw_paths.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698