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

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: Fix CCRC unit test crash 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 "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/common/localized_error.h" 11 #include "chrome/common/localized_error.h"
12 #include "chrome/common/net/net_error_info.h" 12 #include "chrome/common/net/net_error_info.h"
13 #include "chrome/renderer/net/net_error_helper_core.h" 13 #include "chrome/renderer/net/net_error_helper_core.h"
14 #include "content/public/renderer/render_frame_observer.h" 14 #include "content/public/renderer/render_frame_observer.h"
15 #include "content/public/renderer/render_frame_observer_tracker.h" 15 #include "content/public/renderer/render_frame_observer_tracker.h"
16 #include "content/public/renderer/render_process_observer.h"
16 17
17 class GURL; 18 class GURL;
18 19
19 namespace content { 20 namespace content {
20 class ResourceFetcher; 21 class ResourceFetcher;
21 } 22 }
22 23
23 namespace blink { 24 namespace blink {
24 class WebFrame; 25 class WebFrame;
25 class WebURLResponse; 26 class WebURLResponse;
26 struct WebURLError; 27 struct WebURLError;
27 } 28 }
28 29
29 // Listens for NetErrorInfo messages from the NetErrorTabHelper on the 30 // Listens for NetErrorInfo messages from the NetErrorTabHelper on the
30 // browser side and updates the error page with more details (currently, just 31 // browser side and updates the error page with more details (currently, just
31 // DNS probe results) if/when available. 32 // DNS probe results) if/when available.
32 class NetErrorHelper 33 class NetErrorHelper
33 : public content::RenderFrameObserver, 34 : public content::RenderFrameObserver,
34 public content::RenderFrameObserverTracker<NetErrorHelper>, 35 public content::RenderFrameObserverTracker<NetErrorHelper>,
36 public content::RenderProcessObserver,
35 public NetErrorHelperCore::Delegate { 37 public NetErrorHelperCore::Delegate {
36 public: 38 public:
37 explicit NetErrorHelper(content::RenderFrame* render_view); 39 explicit NetErrorHelper(content::RenderFrame* render_view);
38 virtual ~NetErrorHelper(); 40 virtual ~NetErrorHelper();
39 41
40 // RenderFrameObserver implementation. 42 // RenderFrameObserver implementation.
41 virtual void DidStartProvisionalLoad() OVERRIDE; 43 virtual void DidStartProvisionalLoad() OVERRIDE;
42 virtual void DidCommitProvisionalLoad(bool is_new_navigation) OVERRIDE; 44 virtual void DidCommitProvisionalLoad(bool is_new_navigation) OVERRIDE;
43 virtual void DidFinishLoad() OVERRIDE; 45 virtual void DidFinishLoad() OVERRIDE;
44 virtual void OnStop() OVERRIDE; 46 virtual void OnStop() OVERRIDE;
45 47
46 // IPC::Listener implementation. 48 // IPC::Listener implementation.
47 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 49 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
48 50
51 // RenderProcessObserver implementation.
52 virtual void NetworkStateChanged(bool online) OVERRIDE;
53
49 // Examines |frame| and |error| to see if this is an error worthy of a DNS 54 // Examines |frame| and |error| to see if this is an error worthy of a DNS
50 // probe. If it is, initializes |error_strings| based on |error|, 55 // probe. If it is, initializes |error_strings| based on |error|,
51 // |is_failed_post|, and |locale| with suitable strings and returns true. 56 // |is_failed_post|, and |locale| with suitable strings and returns true.
52 // If not, returns false, in which case the caller should look up error 57 // If not, returns false, in which case the caller should look up error
53 // strings directly using LocalizedError::GetNavigationErrorStrings. 58 // strings directly using LocalizedError::GetNavigationErrorStrings.
54 // 59 //
55 // Updates the NetErrorHelper with the assumption the page will be loaded 60 // Updates the NetErrorHelper with the assumption the page will be loaded
56 // immediately. 61 // immediately.
57 void GetErrorHTML(blink::WebFrame* frame, 62 void GetErrorHTML(blink::WebFrame* frame,
58 const blink::WebURLError& error, 63 const blink::WebURLError& error,
59 bool is_failed_post, 64 bool is_failed_post,
60 std::string* error_html); 65 std::string* error_html);
61 66
67 // Returns whether a load for |url| in |frame| should have its error page
68 // suppressed.
69 bool ShouldSuppressErrorPage(blink::WebFrame* frame, const GURL& url);
70
62 private: 71 private:
63 // NetErrorHelperCore::Delegate implementation: 72 // NetErrorHelperCore::Delegate implementation:
64 virtual void GenerateLocalizedErrorPage( 73 virtual void GenerateLocalizedErrorPage(
65 const blink::WebURLError& error, 74 const blink::WebURLError& error,
66 bool is_failed_post, 75 bool is_failed_post,
67 scoped_ptr<LocalizedError::ErrorPageParams> params, 76 scoped_ptr<LocalizedError::ErrorPageParams> params,
68 std::string* html) const OVERRIDE; 77 std::string* html) const OVERRIDE;
69 virtual void LoadErrorPageInMainFrame(const std::string& html, 78 virtual void LoadErrorPageInMainFrame(const std::string& html,
70 const GURL& failed_url) OVERRIDE; 79 const GURL& failed_url) OVERRIDE;
71 virtual void UpdateErrorPage(const blink::WebURLError& error, 80 virtual void UpdateErrorPage(const blink::WebURLError& error,
72 bool is_failed_post) OVERRIDE; 81 bool is_failed_post) OVERRIDE;
73 virtual void FetchNavigationCorrections( 82 virtual void FetchNavigationCorrections(
74 const GURL& navigation_correction_url, 83 const GURL& navigation_correction_url,
75 const std::string& navigation_correction_request_body) OVERRIDE; 84 const std::string& navigation_correction_request_body) OVERRIDE;
76 virtual void CancelFetchNavigationCorrections() OVERRIDE; 85 virtual void CancelFetchNavigationCorrections() OVERRIDE;
86 virtual void ReloadPage() OVERRIDE;
77 87
78 void OnNetErrorInfo(int status); 88 void OnNetErrorInfo(int status);
79 void OnSetNavigationCorrectionInfo(const GURL& navigation_correction_url, 89 void OnSetNavigationCorrectionInfo(const GURL& navigation_correction_url,
80 const std::string& language, 90 const std::string& language,
81 const std::string& country_code, 91 const std::string& country_code,
82 const std::string& api_key, 92 const std::string& api_key,
83 const GURL& search_url); 93 const GURL& search_url);
84 94
85 void OnNavigationCorrectionsFetched(const blink::WebURLResponse& response, 95 void OnNavigationCorrectionsFetched(const blink::WebURLResponse& response,
86 const std::string& data); 96 const std::string& data);
87 97
88 scoped_ptr<content::ResourceFetcher> correction_fetcher_; 98 scoped_ptr<content::ResourceFetcher> correction_fetcher_;
89 99
90 NetErrorHelperCore core_; 100 NetErrorHelperCore core_;
91 }; 101 };
92 102
93 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_H_ 103 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698