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

Unified Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page.h

Issue 2623733002: Componentize SafeBrowsingBlockingPage for WebView use (Closed)
Patch Set: address final comments 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/safe_browsing_blocking_page.h
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.h b/chrome/browser/safe_browsing/safe_browsing_blocking_page.h
index 93ce1114be7947a456641d41fc9891a383b66ba4..759f622d16215a92d6931cf44e03dc17f131e5fc 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.h
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.h
@@ -32,31 +32,19 @@
#include <string>
#include <vector>
-#include <stdint.h>
-
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/task/cancelable_task_tracker.h"
-#include "chrome/browser/interstitials/chrome_metrics_helper.h"
#include "chrome/browser/safe_browsing/ui_manager.h"
-#include "components/security_interstitials/content/security_interstitial_page.h"
-#include "components/security_interstitials/core/safe_browsing_error_ui.h"
-#include "content/public/browser/interstitial_page_delegate.h"
-#include "url/gurl.h"
+#include "components/safe_browsing/base_blocking_page.h"
namespace safe_browsing {
class SafeBrowsingBlockingPageFactory;
class ThreatDetails;
-class SafeBrowsingBlockingPage
- : public security_interstitials::SecurityInterstitialPage {
+class SafeBrowsingBlockingPage : public BaseBlockingPage {
public:
- typedef security_interstitials::UnsafeResource UnsafeResource;
- typedef security_interstitials::SafeBrowsingErrorUI SafeBrowsingErrorUI;
- typedef std::vector<UnsafeResource> UnsafeResourceList;
- typedef std::map<content::WebContents*, UnsafeResourceList> UnsafeResourceMap;
-
// Interstitial type, used in tests.
static content::InterstitialPageDelegate::TypeID kTypeForTesting;
@@ -65,7 +53,7 @@ class SafeBrowsingBlockingPage
// Creates a blocking page. Use ShowBlockingPage if you don't need to access
// the blocking page directly.
static SafeBrowsingBlockingPage* CreateBlockingPage(
- SafeBrowsingUIManager* ui_manager,
+ BaseUIManager* ui_manager,
content::WebContents* web_contents,
const GURL& main_frame_url,
const UnsafeResource& unsafe_resource);
@@ -75,8 +63,8 @@ class SafeBrowsingBlockingPage
// You can call this method several times, if an interstitial is already
// showing, the new one will be queued and displayed if the user decides
// to proceed on the currently showing interstitial.
- static void ShowBlockingPage(
- SafeBrowsingUIManager* ui_manager, const UnsafeResource& resource);
+ static void ShowBlockingPage(BaseUIManager* ui_manager,
+ const UnsafeResource& resource);
// Makes the passed |factory| the factory used to instantiate
// SafeBrowsingBlockingPage objects. Useful for tests.
@@ -86,8 +74,6 @@ class SafeBrowsingBlockingPage
// InterstitialPageDelegate method:
void OnProceed() override;
- void OnDontProceed() override;
- void CommandReceived(const std::string& command) override;
void OverrideRendererPrefs(content::RendererPreferences* prefs) override;
content::InterstitialPageDelegate::TypeID GetTypeForTesting() const override;
@@ -115,15 +101,12 @@ class SafeBrowsingBlockingPage
void UpdateReportingPref(); // Used for the transition from old to new pref.
// Don't instantiate this class directly, use ShowBlockingPage instead.
- SafeBrowsingBlockingPage(SafeBrowsingUIManager* ui_manager,
- content::WebContents* web_contents,
- const GURL& main_frame_url,
- const UnsafeResourceList& unsafe_resources);
-
- // SecurityInterstitialPage methods:
- bool ShouldCreateNewNavigation() const override;
- void PopulateInterstitialStrings(
- base::DictionaryValue* load_time_data) override;
+ SafeBrowsingBlockingPage(
+ BaseUIManager* ui_manager,
+ content::WebContents* web_contents,
+ const GURL& main_frame_url,
+ const UnsafeResourceList& unsafe_resources,
+ const SafeBrowsingErrorUI::SBErrorDisplayOptions& display_options);
// After a safe browsing interstitial where the user opted-in to the
// report but clicked "proceed anyway", we delay the call to
@@ -135,65 +118,28 @@ class SafeBrowsingBlockingPage
// pending threat details object, we look at the user's
// preferences, and if the option to send threat details is
// enabled, the report is scheduled to be sent on the |ui_manager_|.
- void FinishThreatDetails(int64_t delay_ms, bool did_proceed, int num_visits);
-
- // A list of SafeBrowsingUIManager::UnsafeResource for a tab that the user
- // should be warned about. They are queued when displaying more than one
- // interstitial at a time.
- static UnsafeResourceMap* GetUnsafeResourcesMap();
-
- // Returns true if the passed |unsafe_resources| is blocking the load of
- // the main page.
- static bool IsMainPageLoadBlocked(
- const UnsafeResourceList& unsafe_resources);
-
- // For reporting back user actions.
- SafeBrowsingUIManager* ui_manager_;
-
- // For displaying safe browsing interstitial.
- std::unique_ptr<SafeBrowsingErrorUI> sb_error_ui_;
-
- // The URL of the main frame that caused the warning.
- GURL main_frame_url_;
-
- // The index of a navigation entry that should be removed when DontProceed()
- // is invoked, -1 if not entry should be removed.
- int navigation_entry_index_to_remove_;
-
- // The list of unsafe resources this page is warning about.
- UnsafeResourceList unsafe_resources_;
+ void FinishThreatDetails(const base::TimeDelta& delay,
+ bool did_proceed,
+ int num_visits) override;
// A ThreatDetails object that we start generating when the
// blocking page is shown. The object will be sent when the warning
// is gone (if the user enables the feature).
scoped_refptr<ThreatDetails> threat_details_;
- bool proceeded_;
-
- // Which type of Safe Browsing interstitial this is.
- SafeBrowsingErrorUI::SBInterstitialReason interstitial_reason_;
-
// The factory used to instantiate SafeBrowsingBlockingPage objects.
// Useful for tests, so they can provide their own implementation of
// SafeBrowsingBlockingPage.
static SafeBrowsingBlockingPageFactory* factory_;
private:
- static std::string GetMetricPrefix(
- const UnsafeResourceList& unsafe_resources,
- SafeBrowsingErrorUI::SBInterstitialReason interstitial_reason);
- static std::string GetExtraMetricsSuffix(
- const UnsafeResourceList& unsafe_resources);
static std::string GetSamplingEventName(
SafeBrowsingErrorUI::SBInterstitialReason interstitial_reason);
- static SafeBrowsingErrorUI::SBInterstitialReason GetInterstitialReason(
- const UnsafeResourceList& unsafe_resources);
-
- std::unique_ptr<security_interstitials::SecurityInterstitialControllerClient>
- CreateControllerClient(
- content::WebContents* web_contents,
- const UnsafeResourceList& unsafe_resources);
+ static std::unique_ptr<
+ security_interstitials::SecurityInterstitialControllerClient>
+ CreateControllerClient(content::WebContents* web_contents,
+ const UnsafeResourceList& unsafe_resources);
DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPage);
};
@@ -204,7 +150,7 @@ class SafeBrowsingBlockingPageFactory {
virtual ~SafeBrowsingBlockingPageFactory() { }
virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage(
- SafeBrowsingUIManager* ui_manager,
+ BaseUIManager* ui_manager,
content::WebContents* web_contents,
const GURL& main_frame_url,
const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0;
« no previous file with comments | « chrome/browser/loader/safe_browsing_resource_throttle.cc ('k') | chrome/browser/safe_browsing/safe_browsing_blocking_page.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698