Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: chrome/renderer/net/net_error_helper.h

Issue 136203009: Support auto-reload on errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Add MockableOneShotTimer tests. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_H_ 5 #ifndef CHROME_RENDERER_NET_NET_ERROR_HELPER_H_
6 #define CHROME_RENDERER_NET_NET_ERROR_HELPER_H_ 6 #define CHROME_RENDERER_NET_NET_ERROR_HELPER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "chrome/common/net/net_error_info.h" 10 #include "chrome/common/net/net_error_info.h"
11 #include "chrome/renderer/net/net_error_helper_core.h" 11 #include "chrome/renderer/net/net_error_helper_core.h"
12 #include "content/public/renderer/render_frame_observer.h" 12 #include "content/public/renderer/render_frame_observer.h"
13 #include "content/public/renderer/render_frame_observer_tracker.h" 13 #include "content/public/renderer/render_frame_observer_tracker.h"
14 #include "content/public/renderer/render_process_observer.h"
14 15
15 class GURL; 16 class GURL;
17 class MockableOneShotTimer;
16 18
17 namespace content { 19 namespace content {
18 class ResourceFetcher; 20 class ResourceFetcher;
19 } 21 }
20 22
21 namespace blink { 23 namespace blink {
22 class WebFrame; 24 class WebFrame;
23 class WebURLResponse; 25 class WebURLResponse;
24 struct WebURLError; 26 struct WebURLError;
25 } 27 }
26 28
27 // Listens for NetErrorInfo messages from the NetErrorTabHelper on the 29 // Listens for NetErrorInfo messages from the NetErrorTabHelper on the
28 // browser side and updates the error page with more details (currently, just 30 // browser side and updates the error page with more details (currently, just
29 // DNS probe results) if/when available. 31 // DNS probe results) if/when available.
30 class NetErrorHelper 32 class NetErrorHelper
31 : public content::RenderFrameObserver, 33 : public content::RenderFrameObserver,
32 public content::RenderFrameObserverTracker<NetErrorHelper>, 34 public content::RenderFrameObserverTracker<NetErrorHelper>,
35 public content::RenderProcessObserver,
33 public NetErrorHelperCore::Delegate { 36 public NetErrorHelperCore::Delegate {
34 public: 37 public:
35 explicit NetErrorHelper(content::RenderFrame* render_view); 38 explicit NetErrorHelper(content::RenderFrame* render_view);
36 virtual ~NetErrorHelper(); 39 virtual ~NetErrorHelper();
37 40
38 // RenderFrameObserver implementation. 41 // RenderFrameObserver implementation.
39 virtual void DidStartProvisionalLoad() OVERRIDE; 42 virtual void DidStartProvisionalLoad() OVERRIDE;
40 virtual void DidCommitProvisionalLoad(bool is_new_navigation) OVERRIDE; 43 virtual void DidCommitProvisionalLoad(bool is_new_navigation) OVERRIDE;
41 virtual void DidFinishLoad() OVERRIDE; 44 virtual void DidFinishLoad() OVERRIDE;
42 virtual void OnStop() OVERRIDE; 45 virtual void OnStop() OVERRIDE;
43 46
44 // IPC::Listener implementation. 47 // IPC::Listener implementation.
45 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 48 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
46 49
50 // RenderProcessObserver implementation.
51 virtual void NetworkStateChanged(bool online) OVERRIDE;
52
47 // Examines |frame| and |error| to see if this is an error worthy of a DNS 53 // Examines |frame| and |error| to see if this is an error worthy of a DNS
48 // probe. If it is, initializes |error_strings| based on |error|, 54 // probe. If it is, initializes |error_strings| based on |error|,
49 // |is_failed_post|, and |locale| with suitable strings and returns true. 55 // |is_failed_post|, and |locale| with suitable strings and returns true.
50 // If not, returns false, in which case the caller should look up error 56 // If not, returns false, in which case the caller should look up error
51 // strings directly using LocalizedError::GetNavigationErrorStrings. 57 // strings directly using LocalizedError::GetNavigationErrorStrings.
52 // 58 //
53 // Updates the NetErrorHelper with the assumption the page will be loaded 59 // Updates the NetErrorHelper with the assumption the page will be loaded
54 // immediately. 60 // immediately.
55 void GetErrorHTML(blink::WebFrame* frame, 61 void GetErrorHTML(blink::WebFrame* frame,
56 const blink::WebURLError& error, 62 const blink::WebURLError& error,
57 bool is_failed_post, 63 bool is_failed_post,
58 std::string* error_html); 64 std::string* error_html);
59 65
66 // Returns whether a load for |url| in |frame| should have its error page
67 // suppressed.
68 bool ShouldSuppressErrorPage(blink::WebFrame*frame, const GURL& url);
mmenke 2014/03/11 20:07:54 nit: Space after *
Elly Fong-Jones 2014/03/12 15:08:58 Done.
69
60 private: 70 private:
61 // NetErrorHelperCore::Delegate implementation: 71 // NetErrorHelperCore::Delegate implementation:
62 virtual void GenerateLocalizedErrorPage(const blink::WebURLError& error, 72 virtual void GenerateLocalizedErrorPage(const blink::WebURLError& error,
63 bool is_failed_post, 73 bool is_failed_post,
64 std::string* html) const OVERRIDE; 74 std::string* html) const OVERRIDE;
65 virtual void LoadErrorPageInMainFrame(const std::string& html, 75 virtual void LoadErrorPageInMainFrame(const std::string& html,
66 const GURL& failed_url) OVERRIDE; 76 const GURL& failed_url) OVERRIDE;
67 virtual void UpdateErrorPage(const blink::WebURLError& error, 77 virtual void UpdateErrorPage(const blink::WebURLError& error,
68 bool is_failed_post) OVERRIDE; 78 bool is_failed_post) OVERRIDE;
69 virtual void FetchErrorPage(const GURL& url) OVERRIDE; 79 virtual void FetchErrorPage(const GURL& url) OVERRIDE;
70 virtual void CancelFetchErrorPage() OVERRIDE; 80 virtual void CancelFetchErrorPage() OVERRIDE;
81 virtual void ReloadPage() OVERRIDE;
71 82
72 void OnNetErrorInfo(int status); 83 void OnNetErrorInfo(int status);
73 void OnSetAltErrorPageURL(const GURL& alternate_error_page_url); 84 void OnSetAltErrorPageURL(const GURL& alternate_error_page_url);
74 85
75 void OnAlternateErrorPageRetrieved(const blink::WebURLResponse& response, 86 void OnAlternateErrorPageRetrieved(const blink::WebURLResponse& response,
76 const std::string& data); 87 const std::string& data);
77 88
78 scoped_ptr<content::ResourceFetcher> alt_error_page_fetcher_; 89 scoped_ptr<content::ResourceFetcher> alt_error_page_fetcher_;
79 90
80 NetErrorHelperCore core_; 91 NetErrorHelperCore core_;
81 }; 92 };
82 93
83 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_H_ 94 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698