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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 void CommandReceived(const std::string& command) override; | 84 void CommandReceived(const std::string& command) override; |
85 void OverrideRendererPrefs(content::RendererPreferences* prefs) override; | 85 void OverrideRendererPrefs(content::RendererPreferences* prefs) override; |
86 | 86 |
87 // SecurityInterstitialPage method: | 87 // SecurityInterstitialPage method: |
88 const void* GetTypeForTesting() const override; | 88 const void* GetTypeForTesting() const override; |
89 | 89 |
90 protected: | 90 protected: |
91 friend class SafeBrowsingBlockingPageTest; | 91 friend class SafeBrowsingBlockingPageTest; |
92 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest, | 92 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest, |
93 ProceedThenDontProceed); | 93 ProceedThenDontProceed); |
94 void SetReportingPreference(bool report); | 94 |
95 void UpdateReportingPref(); // Used for the transition from old to new pref. | 95 void UpdateReportingPref(); // Used for the transition from old to new pref. |
96 | 96 |
97 // Don't instantiate this class directly, use ShowBlockingPage instead. | 97 // Don't instantiate this class directly, use ShowBlockingPage instead. |
98 SafeBrowsingBlockingPage(SafeBrowsingUIManager* ui_manager, | 98 SafeBrowsingBlockingPage(SafeBrowsingUIManager* ui_manager, |
99 content::WebContents* web_contents, | 99 content::WebContents* web_contents, |
100 const UnsafeResourceList& unsafe_resources); | 100 const UnsafeResourceList& unsafe_resources); |
101 | 101 |
102 // SecurityInterstitialPage methods: | 102 // SecurityInterstitialPage methods: |
103 bool ShouldCreateNewNavigation() const override; | 103 bool ShouldCreateNewNavigation() const override; |
104 void PopulateInterstitialStrings( | 104 void PopulateInterstitialStrings( |
(...skipping 13 matching lines...) Expand all Loading... | |
118 // Checks if we should even show the malware details option. For example, we | 118 // Checks if we should even show the malware details option. For example, we |
119 // don't show it in incognito mode. | 119 // don't show it in incognito mode. |
120 bool CanShowMalwareDetailsOption(); | 120 bool CanShowMalwareDetailsOption(); |
121 | 121 |
122 // Called when the insterstitial is going away. If there is a | 122 // Called when the insterstitial is going away. If there is a |
123 // pending malware details object, we look at the user's | 123 // pending malware details object, we look at the user's |
124 // preferences, and if the option to send malware details is | 124 // preferences, and if the option to send malware details is |
125 // enabled, the report is scheduled to be sent on the |ui_manager_|. | 125 // enabled, the report is scheduled to be sent on the |ui_manager_|. |
126 void FinishMalwareDetails(int64 delay_ms); | 126 void FinishMalwareDetails(int64 delay_ms); |
127 | 127 |
128 // Returns the boolean value of the given |pref| from the PrefService of the | |
129 // Profile associated with |web_contents_|. | |
130 bool IsPrefEnabled(const char* pref); | |
131 | |
132 // A list of SafeBrowsingUIManager::UnsafeResource for a tab that the user | 128 // A list of SafeBrowsingUIManager::UnsafeResource for a tab that the user |
133 // should be warned about. They are queued when displaying more than one | 129 // should be warned about. They are queued when displaying more than one |
134 // interstitial at a time. | 130 // interstitial at a time. |
135 static UnsafeResourceMap* GetUnsafeResourcesMap(); | 131 static UnsafeResourceMap* GetUnsafeResourcesMap(); |
136 | 132 |
137 // Notifies the SafeBrowsingUIManager on the IO thread whether to proceed | 133 // Notifies the SafeBrowsingUIManager on the IO thread whether to proceed |
138 // or not for the |resources|. | 134 // or not for the |resources|. |
139 static void NotifySafeBrowsingUIManager( | 135 static void NotifySafeBrowsingUIManager( |
140 SafeBrowsingUIManager* ui_manager, | 136 SafeBrowsingUIManager* ui_manager, |
141 const UnsafeResourceList& resources, bool proceed); | 137 const UnsafeResourceList& resources, bool proceed); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 } interstitial_reason_; | 175 } interstitial_reason_; |
180 | 176 |
181 // The factory used to instantiate SafeBrowsingBlockingPage objects. | 177 // The factory used to instantiate SafeBrowsingBlockingPage objects. |
182 // Usefull for tests, so they can provide their own implementation of | 178 // Usefull for tests, so they can provide their own implementation of |
183 // SafeBrowsingBlockingPage. | 179 // SafeBrowsingBlockingPage. |
184 static SafeBrowsingBlockingPageFactory* factory_; | 180 static SafeBrowsingBlockingPageFactory* factory_; |
185 | 181 |
186 private: | 182 private: |
187 // Fills the passed dictionary with the values to be passed to the template | 183 // Fills the passed dictionary with the values to be passed to the template |
188 // when creating the HTML. | 184 // when creating the HTML. |
189 void PopulateExtendedReportingOption(base::DictionaryValue* load_time_data); | |
190 void PopulateMalwareLoadTimeData(base::DictionaryValue* load_time_data); | 185 void PopulateMalwareLoadTimeData(base::DictionaryValue* load_time_data); |
191 void PopulateHarmfulLoadTimeData(base::DictionaryValue* load_time_data); | 186 void PopulateHarmfulLoadTimeData(base::DictionaryValue* load_time_data); |
192 void PopulatePhishingLoadTimeData(base::DictionaryValue* load_time_data); | 187 void PopulatePhishingLoadTimeData(base::DictionaryValue* load_time_data); |
188 // SecurityInterstitialPageWithExtendedReporting implementation: | |
mattm
2015/03/04 02:58:41
I don't see a "SecurityInterstitialPageWithExtende
estark
2015/03/12 22:22:21
Fixed to SecurityInterstitialPage.
| |
189 void PopulateExtendedReportingOption( | |
190 base::DictionaryValue* load_time_data) override; | |
193 | 191 |
194 std::string GetMetricPrefix() const; | 192 std::string GetMetricPrefix() const; |
195 std::string GetSamplingEventName() const; | 193 std::string GetSamplingEventName() const; |
196 | 194 |
197 scoped_ptr<SecurityInterstitialMetricsHelper> metrics_helper_; | 195 scoped_ptr<SecurityInterstitialMetricsHelper> metrics_helper_; |
198 | 196 |
199 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPage); | 197 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPage); |
200 }; | 198 }; |
201 | 199 |
202 // Factory for creating SafeBrowsingBlockingPage. Useful for tests. | 200 // Factory for creating SafeBrowsingBlockingPage. Useful for tests. |
203 class SafeBrowsingBlockingPageFactory { | 201 class SafeBrowsingBlockingPageFactory { |
204 public: | 202 public: |
205 virtual ~SafeBrowsingBlockingPageFactory() { } | 203 virtual ~SafeBrowsingBlockingPageFactory() { } |
206 | 204 |
207 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( | 205 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( |
208 SafeBrowsingUIManager* ui_manager, | 206 SafeBrowsingUIManager* ui_manager, |
209 content::WebContents* web_contents, | 207 content::WebContents* web_contents, |
210 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0; | 208 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0; |
211 }; | 209 }; |
212 | 210 |
213 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ | 211 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ |
OLD | NEW |