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

Unified Diff: chrome/browser/safe_browsing/ui_manager.cc

Issue 2623733002: Componentize SafeBrowsingBlockingPage for WebView use (Closed)
Patch Set: address comments from ntfischer Created 3 years, 11 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
Index: chrome/browser/safe_browsing/ui_manager.cc
diff --git a/chrome/browser/safe_browsing/ui_manager.cc b/chrome/browser/safe_browsing/ui_manager.cc
index 9baab76fa01dc728b10e585880041f334733440f..38d513c7b3963a1dd419718cd6d72796c7a41a08 100644
--- a/chrome/browser/safe_browsing/ui_manager.cc
+++ b/chrome/browser/safe_browsing/ui_manager.cc
@@ -10,6 +10,8 @@
#include "base/metrics/histogram_macros.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/ping_manager.h"
@@ -18,6 +20,7 @@
#include "chrome/browser/safe_browsing/threat_details.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/common/pref_names.h"
+#include "chrome/common/url_constants.h"
#include "components/prefs/pref_service.h"
#include "components/safe_browsing_db/metadata.pb.h"
#include "components/safe_browsing_db/safe_browsing_prefs.h"
@@ -38,23 +41,6 @@ using content::WebContents;
using safe_browsing::HitReport;
using safe_browsing::SBThreatType;
-namespace {
-
-// Returns the URL that should be used in a WhitelistUrlSet for the given
-// |resource|.
-GURL GetMainFrameWhitelistUrlForResource(
- const security_interstitials::UnsafeResource& resource) {
- if (resource.is_subresource) {
- NavigationEntry* entry = resource.GetNavigationEntryForResource();
- if (!entry)
- return GURL();
- return entry->GetURL().GetWithEmptyPath();
- }
- return resource.url.GetWithEmptyPath();
-}
-
-} // namespace
-
namespace safe_browsing {
SafeBrowsingUIManager::SafeBrowsingUIManager(
@@ -70,9 +56,9 @@ void SafeBrowsingUIManager::StopOnIOThread(bool shutdown) {
sb_service_ = NULL;
}
-void SafeBrowsingUIManager::LogPauseDelay(base::TimeDelta time) {
+/*void SafeBrowsingUIManager::LogPauseDelay(base::TimeDelta time) {
UMA_HISTOGRAM_LONG_TIMES("SB2.Delay", time);
-}
+}*/
void SafeBrowsingUIManager::DisplayBlockingPage(
const UnsafeResource& resource) {
@@ -215,6 +201,31 @@ void SafeBrowsingUIManager::CreateWhitelistForTesting(
EnsureWhitelistCreated(web_contents);
}
+void SafeBrowsingUIManager::AddObserver(Observer* observer) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ observer_list_.AddObserver(observer);
+}
+
+void SafeBrowsingUIManager::RemoveObserver(Observer* observer) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ observer_list_.RemoveObserver(observer);
+}
+
+const std::string SafeBrowsingUIManager::app_locale() {
+ return g_browser_process->GetApplicationLocale();
+}
+
+history::HistoryService* SafeBrowsingUIManager::history_service(
+ content::WebContents* web_contents) {
+ return HistoryServiceFactory::GetForProfile(
+ Profile::FromBrowserContext(web_contents->GetBrowserContext()),
+ ServiceAccessType::EXPLICIT_ACCESS);
+}
+
+const GURL SafeBrowsingUIManager::default_safe_page() {
+ return GURL(chrome::kChromeUINewTabURL);
+}
+
void SafeBrowsingUIManager::ReportPermissionActionOnIOThread(
const PermissionReportInfo& report_info) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);

Powered by Google App Engine
This is Rietveld 408576698