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

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

Issue 137623011: Switch to using the new Link Doctor API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Really fix ChromeOS Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
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/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "chrome/common/localized_error.h"
11 #include "chrome/common/net/net_error_info.h" 13 #include "chrome/common/net/net_error_info.h"
12 #include "url/gurl.h" 14 #include "url/gurl.h"
13 15
16 namespace base {
17 class ListValue;
18 }
19
14 namespace blink { 20 namespace blink {
15 struct WebURLError; 21 struct WebURLError;
16 } 22 }
17 23
18 // Class that contains the logic for how the NetErrorHelper. This allows for 24 // Class that contains the logic for how the NetErrorHelper. This allows for
19 // testing the logic without a RenderView or WebFrame, which are difficult to 25 // testing the logic without a RenderView or WebFrame, which are difficult to
20 // mock, and for testing races which are impossible to reliably reproduce 26 // mock, and for testing races which are impossible to reliably reproduce
21 // with real RenderViews or WebFrames. 27 // with real RenderViews or WebFrames.
22 class NetErrorHelperCore { 28 class NetErrorHelperCore {
23 public: 29 public:
24 enum FrameType { 30 enum FrameType {
25 MAIN_FRAME, 31 MAIN_FRAME,
26 SUB_FRAME, 32 SUB_FRAME,
27 }; 33 };
28 34
29 enum PageType { 35 enum PageType {
30 NON_ERROR_PAGE, 36 NON_ERROR_PAGE,
31 ERROR_PAGE, 37 ERROR_PAGE,
32 }; 38 };
33 39
34 // The Delegate handles all interaction with the RenderView, WebFrame, and 40 // The Delegate handles all interaction with the RenderView, WebFrame, and
35 // the network, as well as the generation of error pages. 41 // the network, as well as the generation of error pages.
36 class Delegate { 42 class Delegate {
37 public: 43 public:
38 // Generates an error page's HTML for the given error. 44 // Generates an error page's HTML for the given error.
39 virtual void GenerateLocalizedErrorPage(const blink::WebURLError& error, 45 virtual void GenerateLocalizedErrorPage(
40 bool is_failed_post, 46 const blink::WebURLError& error,
41 std::string* html) const = 0; 47 bool is_failed_post,
48 scoped_ptr<LocalizedError::ErrorPageParams> params,
49 std::string* html) const = 0;
42 50
43 // Loads the given HTML in the main frame for use as an error page. 51 // Loads the given HTML in the main frame for use as an error page.
44 virtual void LoadErrorPageInMainFrame(const std::string& html, 52 virtual void LoadErrorPageInMainFrame(const std::string& html,
45 const GURL& failed_url) = 0; 53 const GURL& failed_url) = 0;
46 54
47 // Updates the currently displayed error page with a new error code. The 55 // Updates the currently displayed error page with a new error code. The
48 // currently displayed error page must have finished loading, and must have 56 // currently displayed error page must have finished loading, and must have
49 // been generated by a call to GenerateLocalizedErrorPage. 57 // been generated by a call to GenerateLocalizedErrorPage.
50 virtual void UpdateErrorPage(const blink::WebURLError& error, 58 virtual void UpdateErrorPage(const blink::WebURLError& error,
51 bool is_failed_post) = 0; 59 bool is_failed_post) = 0;
52 60
53 // Fetches an error page and calls into OnErrorPageFetched when done. Any 61 // Fetches an error page and calls into OnErrorPageFetched when done. Any
54 // previous fetch must either be canceled or finished before calling. Can't 62 // previous fetch must either be canceled or finished before calling. Can't
55 // be called synchronously after a previous fetch completes. 63 // be called synchronously after a previous fetch completes.
56 virtual void FetchErrorPage(const GURL& url) = 0; 64 virtual void FetchErrorPage(const GURL& fix_url,
65 const std::string& fix_url_request_body) = 0;
57 66
58 // Cancels an error page fetch. Does nothing if no fetch is ongoing. 67 // Cancels an error page fetch. Does nothing if no fetch is ongoing.
59 virtual void CancelFetchErrorPage() = 0; 68 virtual void CancelFetchErrorPage() = 0;
60 69
61 protected: 70 protected:
62 virtual ~Delegate() {} 71 virtual ~Delegate() {}
63 }; 72 };
64 73
65 explicit NetErrorHelperCore(Delegate* delegate); 74 explicit NetErrorHelperCore(Delegate* delegate);
66 ~NetErrorHelperCore(); 75 ~NetErrorHelperCore();
(...skipping 12 matching lines...) Expand all
79 std::string* error_html); 88 std::string* error_html);
80 89
81 // These methods handle tracking the actual state of the page. 90 // These methods handle tracking the actual state of the page.
82 void OnStartLoad(FrameType frame_type, PageType page_type); 91 void OnStartLoad(FrameType frame_type, PageType page_type);
83 void OnCommitLoad(FrameType frame_type); 92 void OnCommitLoad(FrameType frame_type);
84 void OnFinishLoad(FrameType frame_type); 93 void OnFinishLoad(FrameType frame_type);
85 void OnStop(); 94 void OnStop();
86 95
87 // Called when an error page have has been retrieved over the network. |html| 96 // Called when an error page have has been retrieved over the network. |html|
88 // must be an empty string on error. 97 // must be an empty string on error.
89 void OnAlternateErrorPageFetched(const std::string& html); 98 void OnAlternateErrorPageFetched(const std::string& html,
99 const std::string& accept_languages,
100 bool is_rtl);
90 101
91 // Notifies |this| that network error information from the browser process 102 // Notifies |this| that network error information from the browser process
92 // has been received. 103 // has been received.
93 void OnNetErrorInfo(chrome_common_net::DnsProbeStatus status); 104 void OnNetErrorInfo(chrome_common_net::DnsProbeStatus status);
94 105
95 void set_alt_error_page_url(const GURL& alt_error_page_url) { 106 void OnSetLinkDoctorInfo(const GURL& link_doctor_url,
96 alt_error_page_url_ = alt_error_page_url; 107 const std::string& language,
97 } 108 const std::string& country_code,
109 const std::string& api_key,
110 const GURL& search_url);
98 111
99 private: 112 private:
100 struct ErrorPageInfo; 113 struct ErrorPageInfo;
101 114
102 // Updates the currently displayed error page with a new error based on the 115 // Updates the currently displayed error page with a new error based on the
103 // most recently received DNS probe result. The page must have finished 116 // most recently received DNS probe result. The page must have finished
104 // loading before this is called. 117 // loading before this is called.
105 void UpdateErrorPage(); 118 void UpdateErrorPage();
106 119
107 void GenerateLocalErrorPage( 120 void GenerateLocalErrorPage(
108 FrameType frame_type, 121 FrameType frame_type,
109 const blink::WebURLError& error, 122 const blink::WebURLError& error,
110 bool is_failed_post, 123 bool is_failed_post,
124 scoped_ptr<LocalizedError::ErrorPageParams> params,
111 std::string* error_html); 125 std::string* error_html);
112 126
113 blink::WebURLError GetUpdatedError(const blink::WebURLError& error) const; 127 blink::WebURLError GetUpdatedError(const blink::WebURLError& error) const;
114 128
115 Delegate* delegate_; 129 Delegate* delegate_;
116 130
117 // The last DnsProbeStatus received from the browser. 131 // The last DnsProbeStatus received from the browser.
118 chrome_common_net::DnsProbeStatus last_probe_status_; 132 chrome_common_net::DnsProbeStatus last_probe_status_;
119 133
120 // Information for the provisional / "pre-provisional" error page. NULL when 134 // Information for the provisional / "pre-provisional" error page. NULL when
121 // there's no page pending, or the pending page is not an error page. 135 // there's no page pending, or the pending page is not an error page.
122 scoped_ptr<ErrorPageInfo> pending_error_page_info_; 136 scoped_ptr<ErrorPageInfo> pending_error_page_info_;
123 137
124 // Information for the committed error page. NULL when the committed page is 138 // Information for the committed error page. NULL when the committed page is
125 // not an error page. 139 // not an error page.
126 scoped_ptr<ErrorPageInfo> committed_error_page_info_; 140 scoped_ptr<ErrorPageInfo> committed_error_page_info_;
127 141
128 GURL alt_error_page_url_; 142 GURL link_doctor_url_;
143 std::string language_;
144 std::string country_code_;
145 std::string api_key_;
146 GURL search_url_;
129 }; 147 };
130 148
131 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_CORE_H_ 149 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_CORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698