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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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); | 184 void PopulateExtendedReportingOption(base::DictionaryValue* load_time_data); |
189 void PopulateMalwareLoadTimeData(base::DictionaryValue* load_time_data); | 185 void PopulateMalwareLoadTimeData(base::DictionaryValue* load_time_data); |
190 void PopulateHarmfulLoadTimeData(base::DictionaryValue* load_time_data); | 186 void PopulateHarmfulLoadTimeData(base::DictionaryValue* load_time_data); |
191 void PopulatePhishingLoadTimeData(base::DictionaryValue* load_time_data); | 187 void PopulatePhishingLoadTimeData(base::DictionaryValue* load_time_data); |
192 | 188 |
193 std::string GetMetricPrefix() const; | 189 std::string GetMetricPrefix() const; |
194 std::string GetSamplingEventName() const; | 190 std::string GetSamplingEventName() const; |
195 | 191 |
196 scoped_ptr<SecurityInterstitialMetricsHelper> metrics_helper_; | |
197 | |
198 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPage); | 192 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPage); |
199 }; | 193 }; |
200 | 194 |
201 // Factory for creating SafeBrowsingBlockingPage. Useful for tests. | 195 // Factory for creating SafeBrowsingBlockingPage. Useful for tests. |
202 class SafeBrowsingBlockingPageFactory { | 196 class SafeBrowsingBlockingPageFactory { |
203 public: | 197 public: |
204 virtual ~SafeBrowsingBlockingPageFactory() { } | 198 virtual ~SafeBrowsingBlockingPageFactory() { } |
205 | 199 |
206 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( | 200 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( |
207 SafeBrowsingUIManager* ui_manager, | 201 SafeBrowsingUIManager* ui_manager, |
208 content::WebContents* web_contents, | 202 content::WebContents* web_contents, |
209 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0; | 203 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0; |
210 }; | 204 }; |
211 | 205 |
212 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ | 206 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ |
OLD | NEW |