| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Classes for managing the SafeBrowsing interstitial pages. | 5 // Classes for managing the SafeBrowsing interstitial pages. |
| 6 // | 6 // |
| 7 // When a user is about to visit a page the SafeBrowsing system has deemed to | 7 // When a user is about to visit a page the SafeBrowsing system has deemed to |
| 8 // be malicious, either as malware or a phishing page, we show an interstitial | 8 // be malicious, either as malware or a phishing page, we show an interstitial |
| 9 // page with some options (go back, continue) to give the user a chance to avoid | 9 // page with some options (go back, continue) to give the user a chance to avoid |
| 10 // the harmful page. | 10 // the harmful page. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 void OnProceed() override; | 83 void OnProceed() override; |
| 84 void OnDontProceed() override; | 84 void OnDontProceed() override; |
| 85 void CommandReceived(const std::string& command) override; | 85 void CommandReceived(const std::string& command) override; |
| 86 void OverrideRendererPrefs(content::RendererPreferences* prefs) override; | 86 void OverrideRendererPrefs(content::RendererPreferences* prefs) override; |
| 87 content::InterstitialPageDelegate::TypeID GetTypeForTesting() const override; | 87 content::InterstitialPageDelegate::TypeID GetTypeForTesting() const override; |
| 88 | 88 |
| 89 protected: | 89 protected: |
| 90 friend class SafeBrowsingBlockingPageTest; | 90 friend class SafeBrowsingBlockingPageTest; |
| 91 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest, | 91 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest, |
| 92 ProceedThenDontProceed); | 92 ProceedThenDontProceed); |
| 93 void SetReportingPreference(bool report); | 93 |
| 94 void UpdateReportingPref(); // Used for the transition from old to new pref. | 94 void UpdateReportingPref(); // Used for the transition from old to new pref. |
| 95 | 95 |
| 96 // Don't instantiate this class directly, use ShowBlockingPage instead. | 96 // Don't instantiate this class directly, use ShowBlockingPage instead. |
| 97 SafeBrowsingBlockingPage(SafeBrowsingUIManager* ui_manager, | 97 SafeBrowsingBlockingPage(SafeBrowsingUIManager* ui_manager, |
| 98 content::WebContents* web_contents, | 98 content::WebContents* web_contents, |
| 99 const UnsafeResourceList& unsafe_resources); | 99 const UnsafeResourceList& unsafe_resources); |
| 100 | 100 |
| 101 // SecurityInterstitialPage methods: | 101 // SecurityInterstitialPage methods: |
| 102 bool ShouldCreateNewNavigation() const override; | 102 bool ShouldCreateNewNavigation() const override; |
| 103 void PopulateInterstitialStrings( | 103 void PopulateInterstitialStrings( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 117 // Checks if we should even show the malware details option. For example, we | 117 // Checks if we should even show the malware details option. For example, we |
| 118 // don't show it in incognito mode. | 118 // don't show it in incognito mode. |
| 119 bool CanShowMalwareDetailsOption(); | 119 bool CanShowMalwareDetailsOption(); |
| 120 | 120 |
| 121 // Called when the insterstitial is going away. If there is a | 121 // Called when the insterstitial is going away. If there is a |
| 122 // pending malware details object, we look at the user's | 122 // pending malware details object, we look at the user's |
| 123 // preferences, and if the option to send malware details is | 123 // preferences, and if the option to send malware details is |
| 124 // enabled, the report is scheduled to be sent on the |ui_manager_|. | 124 // enabled, the report is scheduled to be sent on the |ui_manager_|. |
| 125 void FinishMalwareDetails(int64 delay_ms); | 125 void FinishMalwareDetails(int64 delay_ms); |
| 126 | 126 |
| 127 // Returns the boolean value of the given |pref| from the PrefService of the | |
| 128 // Profile associated with |web_contents_|. | |
| 129 bool IsPrefEnabled(const char* pref); | |
| 130 | |
| 131 // A list of SafeBrowsingUIManager::UnsafeResource for a tab that the user | 127 // A list of SafeBrowsingUIManager::UnsafeResource for a tab that the user |
| 132 // should be warned about. They are queued when displaying more than one | 128 // should be warned about. They are queued when displaying more than one |
| 133 // interstitial at a time. | 129 // interstitial at a time. |
| 134 static UnsafeResourceMap* GetUnsafeResourcesMap(); | 130 static UnsafeResourceMap* GetUnsafeResourcesMap(); |
| 135 | 131 |
| 136 // Notifies the SafeBrowsingUIManager on the IO thread whether to proceed | 132 // Notifies the SafeBrowsingUIManager on the IO thread whether to proceed |
| 137 // or not for the |resources|. | 133 // or not for the |resources|. |
| 138 static void NotifySafeBrowsingUIManager( | 134 static void NotifySafeBrowsingUIManager( |
| 139 SafeBrowsingUIManager* ui_manager, | 135 SafeBrowsingUIManager* ui_manager, |
| 140 const UnsafeResourceList& resources, bool proceed); | 136 const UnsafeResourceList& resources, bool proceed); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 } interstitial_reason_; | 174 } interstitial_reason_; |
| 179 | 175 |
| 180 // The factory used to instantiate SafeBrowsingBlockingPage objects. | 176 // The factory used to instantiate SafeBrowsingBlockingPage objects. |
| 181 // Usefull for tests, so they can provide their own implementation of | 177 // Usefull for tests, so they can provide their own implementation of |
| 182 // SafeBrowsingBlockingPage. | 178 // SafeBrowsingBlockingPage. |
| 183 static SafeBrowsingBlockingPageFactory* factory_; | 179 static SafeBrowsingBlockingPageFactory* factory_; |
| 184 | 180 |
| 185 private: | 181 private: |
| 186 // Fills the passed dictionary with the values to be passed to the template | 182 // Fills the passed dictionary with the values to be passed to the template |
| 187 // when creating the HTML. | 183 // when creating the HTML. |
| 188 void PopulateExtendedReportingOption(base::DictionaryValue* load_time_data); | |
| 189 void PopulateMalwareLoadTimeData(base::DictionaryValue* load_time_data); | 184 void PopulateMalwareLoadTimeData(base::DictionaryValue* load_time_data); |
| 190 void PopulateHarmfulLoadTimeData(base::DictionaryValue* load_time_data); | 185 void PopulateHarmfulLoadTimeData(base::DictionaryValue* load_time_data); |
| 191 void PopulatePhishingLoadTimeData(base::DictionaryValue* load_time_data); | 186 void PopulatePhishingLoadTimeData(base::DictionaryValue* load_time_data); |
| 187 // SecurityInterstitialPage implementation |
| 188 void PopulateExtendedReportingOption( |
| 189 base::DictionaryValue* load_time_data) override; |
| 192 | 190 |
| 193 std::string GetMetricPrefix() const; | 191 std::string GetMetricPrefix() const; |
| 194 std::string GetSamplingEventName() const; | 192 std::string GetSamplingEventName() const; |
| 195 | 193 |
| 196 scoped_ptr<SecurityInterstitialMetricsHelper> metrics_helper_; | 194 scoped_ptr<SecurityInterstitialMetricsHelper> metrics_helper_; |
| 197 | 195 |
| 198 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPage); | 196 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPage); |
| 199 }; | 197 }; |
| 200 | 198 |
| 201 // Factory for creating SafeBrowsingBlockingPage. Useful for tests. | 199 // Factory for creating SafeBrowsingBlockingPage. Useful for tests. |
| 202 class SafeBrowsingBlockingPageFactory { | 200 class SafeBrowsingBlockingPageFactory { |
| 203 public: | 201 public: |
| 204 virtual ~SafeBrowsingBlockingPageFactory() { } | 202 virtual ~SafeBrowsingBlockingPageFactory() { } |
| 205 | 203 |
| 206 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( | 204 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( |
| 207 SafeBrowsingUIManager* ui_manager, | 205 SafeBrowsingUIManager* ui_manager, |
| 208 content::WebContents* web_contents, | 206 content::WebContents* web_contents, |
| 209 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0; | 207 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0; |
| 210 }; | 208 }; |
| 211 | 209 |
| 212 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ | 210 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ |
| OLD | NEW |