Chromium Code Reviews| 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 CHROME_RENDERER_NET_NET_ERROR_HELPER_CORE_H_ | 5 #ifndef CHROME_RENDERER_NET_NET_ERROR_HELPER_CORE_H_ |
| 6 #define CHROME_RENDERER_NET_NET_ERROR_HELPER_CORE_H_ | 6 #define CHROME_RENDERER_NET_NET_ERROR_HELPER_CORE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 enum FrameType { | 32 enum FrameType { |
| 33 MAIN_FRAME, | 33 MAIN_FRAME, |
| 34 SUB_FRAME, | 34 SUB_FRAME, |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 enum PageType { | 37 enum PageType { |
| 38 NON_ERROR_PAGE, | 38 NON_ERROR_PAGE, |
| 39 ERROR_PAGE, | 39 ERROR_PAGE, |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 enum Button { | |
| 43 NO_BUTTON, | |
| 44 RELOAD_BUTTON, | |
| 45 LOAD_STALE_BUTTON, | |
| 46 MORE_BUTTON, | |
| 47 }; | |
| 48 | |
| 42 // The Delegate handles all interaction with the RenderView, WebFrame, and | 49 // The Delegate handles all interaction with the RenderView, WebFrame, and |
| 43 // the network, as well as the generation of error pages. | 50 // the network, as well as the generation of error pages. |
| 44 class Delegate { | 51 class Delegate { |
| 45 public: | 52 public: |
| 46 // Generates an error page's HTML for the given error. | 53 // Generates an error page's HTML for the given error. |
| 47 virtual void GenerateLocalizedErrorPage( | 54 virtual void GenerateLocalizedErrorPage( |
| 48 const blink::WebURLError& error, | 55 const blink::WebURLError& error, |
| 49 bool is_failed_post, | 56 bool is_failed_post, |
| 50 scoped_ptr<LocalizedError::ErrorPageParams> params, | 57 scoped_ptr<LocalizedError::ErrorPageParams> params, |
| 58 bool* reload_button_shown, | |
| 59 bool* load_stale_button_shown, | |
| 51 std::string* html) const = 0; | 60 std::string* html) const = 0; |
| 52 | 61 |
| 53 // Loads the given HTML in the main frame for use as an error page. | 62 // Loads the given HTML in the main frame for use as an error page. |
| 54 virtual void LoadErrorPageInMainFrame(const std::string& html, | 63 virtual void LoadErrorPageInMainFrame(const std::string& html, |
| 55 const GURL& failed_url) = 0; | 64 const GURL& failed_url) = 0; |
| 56 | 65 |
| 57 // Create extra Javascript bindings in the error page. | 66 // Create extra Javascript bindings in the error page. |
| 58 virtual void EnableStaleLoadBindings(const GURL& page_url) = 0; | 67 virtual void EnablePageHelperFunctions() = 0; |
| 59 | 68 |
| 60 // Updates the currently displayed error page with a new error code. The | 69 // Updates the currently displayed error page with a new error code. The |
| 61 // currently displayed error page must have finished loading, and must have | 70 // currently displayed error page must have finished loading, and must have |
| 62 // been generated by a call to GenerateLocalizedErrorPage. | 71 // been generated by a call to GenerateLocalizedErrorPage. |
| 63 virtual void UpdateErrorPage(const blink::WebURLError& error, | 72 virtual void UpdateErrorPage(const blink::WebURLError& error, |
| 64 bool is_failed_post) = 0; | 73 bool is_failed_post) = 0; |
| 65 | 74 |
| 66 // Fetches an error page and calls into OnErrorPageFetched when done. Any | 75 // Fetches an error page and calls into OnErrorPageFetched when done. Any |
| 67 // previous fetch must either be canceled or finished before calling. Can't | 76 // previous fetch must either be canceled or finished before calling. Can't |
| 68 // be called synchronously after a previous fetch completes. | 77 // be called synchronously after a previous fetch completes. |
| 69 virtual void FetchNavigationCorrections( | 78 virtual void FetchNavigationCorrections( |
| 70 const GURL& navigation_correction_url, | 79 const GURL& navigation_correction_url, |
| 71 const std::string& navigation_correction_request_body) = 0; | 80 const std::string& navigation_correction_request_body) = 0; |
| 72 | 81 |
| 73 // Cancels fetching navigation corrections. Does nothing if no fetch is | 82 // Cancels fetching navigation corrections. Does nothing if no fetch is |
| 74 // ongoing. | 83 // ongoing. |
| 75 virtual void CancelFetchNavigationCorrections() = 0; | 84 virtual void CancelFetchNavigationCorrections() = 0; |
| 76 | 85 |
| 77 // Starts a reload of the page in the observed frame. | 86 // Starts a reload of the page in the observed frame. |
| 78 virtual void ReloadPage() = 0; | 87 virtual void ReloadPage() = 0; |
| 79 | 88 |
| 89 // Load the original page from cache. | |
| 90 virtual void LoadPageFromCache(const GURL& page_url) = 0; | |
| 91 | |
| 80 protected: | 92 protected: |
| 81 virtual ~Delegate() {} | 93 virtual ~Delegate() {} |
| 82 }; | 94 }; |
| 83 | 95 |
| 84 explicit NetErrorHelperCore(Delegate* delegate); | 96 explicit NetErrorHelperCore(Delegate* delegate); |
| 85 ~NetErrorHelperCore(); | 97 ~NetErrorHelperCore(); |
| 86 | 98 |
| 87 // Examines |frame| and |error| to see if this is an error worthy of a DNS | 99 // Examines |frame| and |error| to see if this is an error worthy of a DNS |
| 88 // probe. If it is, initializes |error_strings| based on |error|, | 100 // probe. If it is, initializes |error_strings| based on |error|, |
| 89 // |is_failed_post|, and |locale| with suitable strings and returns true. | 101 // |is_failed_post|, and |locale| with suitable strings and returns true. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 } | 150 } |
| 139 | 151 |
| 140 int auto_reload_count() const { return auto_reload_count_; } | 152 int auto_reload_count() const { return auto_reload_count_; } |
| 141 | 153 |
| 142 bool ShouldSuppressErrorPage(FrameType frame_type, const GURL& url); | 154 bool ShouldSuppressErrorPage(FrameType frame_type, const GURL& url); |
| 143 | 155 |
| 144 void set_timer_for_testing(scoped_ptr<base::Timer> timer) { | 156 void set_timer_for_testing(scoped_ptr<base::Timer> timer) { |
| 145 auto_reload_timer_.reset(timer.release()); | 157 auto_reload_timer_.reset(timer.release()); |
| 146 } | 158 } |
| 147 | 159 |
| 160 // Execute the effect of pressing the specified button. | |
| 161 // Note that the visual effects of the 'MORE' button are taken | |
| 162 // care of in JavaScript. | |
| 163 void ExecuteButtonPress(Button button); | |
| 164 | |
| 148 private: | 165 private: |
| 149 struct ErrorPageInfo; | 166 struct ErrorPageInfo; |
| 150 | 167 |
| 151 // Updates the currently displayed error page with a new error based on the | 168 // Updates the currently displayed error page with a new error based on the |
| 152 // most recently received DNS probe result. The page must have finished | 169 // most recently received DNS probe result. The page must have finished |
| 153 // loading before this is called. | 170 // loading before this is called. |
| 154 void UpdateErrorPage(); | 171 void UpdateErrorPage(); |
| 155 | 172 |
| 156 void GenerateLocalErrorPage( | 173 void GenerateLocalErrorPage( |
| 157 FrameType frame_type, | 174 FrameType frame_type, |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 188 GURL search_url_; | 205 GURL search_url_; |
| 189 | 206 |
| 190 bool auto_reload_enabled_; | 207 bool auto_reload_enabled_; |
| 191 scoped_ptr<base::Timer> auto_reload_timer_; | 208 scoped_ptr<base::Timer> auto_reload_timer_; |
| 192 | 209 |
| 193 // Is the browser online? | 210 // Is the browser online? |
| 194 bool online_; | 211 bool online_; |
| 195 | 212 |
| 196 int auto_reload_count_; | 213 int auto_reload_count_; |
| 197 bool can_auto_reload_page_; | 214 bool can_auto_reload_page_; |
| 215 | |
| 216 // Non-NO_BUTTON only when a navigation has been initiated from the error | |
|
jar (doing other things)
2014/04/21 23:48:19
nit: I couldn't parse the comment without working
Randy Smith (Not in Mondays)
2014/04/22 20:40:02
That doesn't quite capture what I'm going for, but
| |
| 217 // page. Used to detect when such navigations result in errors. | |
| 218 Button navigation_from_button_; | |
| 198 }; | 219 }; |
| 199 | 220 |
| 200 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_CORE_H_ | 221 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_CORE_H_ |
| OLD | NEW |