OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef COMPONENTS_ERROR_PAGE_RENDERER_NET_ERROR_HELPER_CORE_H_ | 5 #ifndef COMPONENTS_ERROR_PAGE_RENDERER_NET_ERROR_HELPER_CORE_H_ |
6 #define COMPONENTS_ERROR_PAGE_RENDERER_NET_ERROR_HELPER_CORE_H_ | 6 #define COMPONENTS_ERROR_PAGE_RENDERER_NET_ERROR_HELPER_CORE_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/callback.h" | 11 #include "base/callback.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 #include "components/error_page/common/net_error_info.h" | 15 #include "components/error_page/common/net_error_info.h" |
16 #include "url/gurl.h" | 16 #include "url/gurl.h" |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 class ListValue; | 19 class ListValue; |
20 } | 20 } |
21 | 21 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // The Delegate handles all interaction with the RenderView, WebFrame, and | 57 // The Delegate handles all interaction with the RenderView, WebFrame, and |
58 // the network, as well as the generation of error pages. | 58 // the network, as well as the generation of error pages. |
59 class Delegate { | 59 class Delegate { |
60 public: | 60 public: |
61 // Generates an error page's HTML for the given error. | 61 // Generates an error page's HTML for the given error. |
62 virtual void GenerateLocalizedErrorPage( | 62 virtual void GenerateLocalizedErrorPage( |
63 const blink::WebURLError& error, | 63 const blink::WebURLError& error, |
64 bool is_failed_post, | 64 bool is_failed_post, |
65 bool can_show_network_diagnostics_dialog, | 65 bool can_show_network_diagnostics_dialog, |
66 bool has_offline_pages, | 66 bool has_offline_pages, |
67 scoped_ptr<ErrorPageParams> params, | 67 std::unique_ptr<ErrorPageParams> params, |
68 bool* reload_button_shown, | 68 bool* reload_button_shown, |
69 bool* show_saved_copy_button_shown, | 69 bool* show_saved_copy_button_shown, |
70 bool* show_cached_copy_button_shown, | 70 bool* show_cached_copy_button_shown, |
71 bool* show_offline_pages_button_shown, | 71 bool* show_offline_pages_button_shown, |
72 std::string* html) const = 0; | 72 std::string* html) const = 0; |
73 | 73 |
74 // Loads the given HTML in the frame for use as an error page. | 74 // Loads the given HTML in the frame for use as an error page. |
75 virtual void LoadErrorPage(const std::string& html, | 75 virtual void LoadErrorPage(const std::string& html, |
76 const GURL& failed_url) = 0; | 76 const GURL& failed_url) = 0; |
77 | 77 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 // cause many requests to be started at the same time. There's no current | 193 // cause many requests to be started at the same time. There's no current |
194 // protection against this kind of "reload storm". | 194 // protection against this kind of "reload storm". |
195 // | 195 // |
196 // TODO(rdsmith): prevent the reload storm. | 196 // TODO(rdsmith): prevent the reload storm. |
197 void NetworkStateChanged(bool online); | 197 void NetworkStateChanged(bool online); |
198 | 198 |
199 int auto_reload_count() const { return auto_reload_count_; } | 199 int auto_reload_count() const { return auto_reload_count_; } |
200 | 200 |
201 bool ShouldSuppressErrorPage(FrameType frame_type, const GURL& url); | 201 bool ShouldSuppressErrorPage(FrameType frame_type, const GURL& url); |
202 | 202 |
203 void set_timer_for_testing(scoped_ptr<base::Timer> timer) { | 203 void set_timer_for_testing(std::unique_ptr<base::Timer> timer) { |
204 auto_reload_timer_.reset(timer.release()); | 204 auto_reload_timer_.reset(timer.release()); |
205 } | 205 } |
206 | 206 |
207 // Execute the effect of pressing the specified button. | 207 // Execute the effect of pressing the specified button. |
208 // Note that the visual effects of the 'MORE' button are taken | 208 // Note that the visual effects of the 'MORE' button are taken |
209 // care of in JavaScript. | 209 // care of in JavaScript. |
210 void ExecuteButtonPress(Button button); | 210 void ExecuteButtonPress(Button button); |
211 | 211 |
212 // Reports to the correction service that the link with the given tracking | 212 // Reports to the correction service that the link with the given tracking |
213 // ID was clicked. Only pages generated with information from the service | 213 // ID was clicked. Only pages generated with information from the service |
(...skipping 27 matching lines...) Expand all Loading... |
241 | 241 |
242 static bool IsReloadableError(const ErrorPageInfo& info); | 242 static bool IsReloadableError(const ErrorPageInfo& info); |
243 | 243 |
244 Delegate* delegate_; | 244 Delegate* delegate_; |
245 | 245 |
246 // The last DnsProbeStatus received from the browser. | 246 // The last DnsProbeStatus received from the browser. |
247 DnsProbeStatus last_probe_status_; | 247 DnsProbeStatus last_probe_status_; |
248 | 248 |
249 // Information for the provisional / "pre-provisional" error page. NULL when | 249 // Information for the provisional / "pre-provisional" error page. NULL when |
250 // there's no page pending, or the pending page is not an error page. | 250 // there's no page pending, or the pending page is not an error page. |
251 scoped_ptr<ErrorPageInfo> pending_error_page_info_; | 251 std::unique_ptr<ErrorPageInfo> pending_error_page_info_; |
252 | 252 |
253 // Information for the committed error page. NULL when the committed page is | 253 // Information for the committed error page. NULL when the committed page is |
254 // not an error page. | 254 // not an error page. |
255 scoped_ptr<ErrorPageInfo> committed_error_page_info_; | 255 std::unique_ptr<ErrorPageInfo> committed_error_page_info_; |
256 | 256 |
257 bool can_show_network_diagnostics_dialog_; | 257 bool can_show_network_diagnostics_dialog_; |
258 | 258 |
259 NavigationCorrectionParams navigation_correction_params_; | 259 NavigationCorrectionParams navigation_correction_params_; |
260 | 260 |
261 // True if auto-reload is enabled at all. | 261 // True if auto-reload is enabled at all. |
262 const bool auto_reload_enabled_; | 262 const bool auto_reload_enabled_; |
263 | 263 |
264 // True if auto-reload should only run when the observed frame is visible. | 264 // True if auto-reload should only run when the observed frame is visible. |
265 const bool auto_reload_visible_only_; | 265 const bool auto_reload_visible_only_; |
266 | 266 |
267 // Timer used to wait for auto-reload attempts. | 267 // Timer used to wait for auto-reload attempts. |
268 scoped_ptr<base::Timer> auto_reload_timer_; | 268 std::unique_ptr<base::Timer> auto_reload_timer_; |
269 | 269 |
270 // True if the auto-reload timer would be running but is waiting for an | 270 // True if the auto-reload timer would be running but is waiting for an |
271 // offline->online network transition. | 271 // offline->online network transition. |
272 bool auto_reload_paused_; | 272 bool auto_reload_paused_; |
273 | 273 |
274 // Whether an auto-reload-initiated Reload() attempt is in flight. | 274 // Whether an auto-reload-initiated Reload() attempt is in flight. |
275 bool auto_reload_in_flight_; | 275 bool auto_reload_in_flight_; |
276 | 276 |
277 // True if there is an uncommitted-but-started load, error page or not. This | 277 // True if there is an uncommitted-but-started load, error page or not. This |
278 // is used to inhibit starting auto-reload when an error page finishes, in | 278 // is used to inhibit starting auto-reload when an error page finishes, in |
(...skipping 20 matching lines...) Expand all Loading... |
299 | 299 |
300 // This value is set only when a navigation has been initiated from | 300 // This value is set only when a navigation has been initiated from |
301 // the error page. It is used to detect when such navigations result | 301 // the error page. It is used to detect when such navigations result |
302 // in errors. | 302 // in errors. |
303 Button navigation_from_button_; | 303 Button navigation_from_button_; |
304 }; | 304 }; |
305 | 305 |
306 } // namespace error_page | 306 } // namespace error_page |
307 | 307 |
308 #endif // COMPONENTS_ERROR_PAGE_RENDERER_NET_ERROR_HELPER_CORE_H_ | 308 #endif // COMPONENTS_ERROR_PAGE_RENDERER_NET_ERROR_HELPER_CORE_H_ |
OLD | NEW |