OLD | NEW |
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/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "chrome/renderer/net/net_error_page_controller.h" | 13 #include "chrome/renderer/net/net_error_page_controller.h" |
14 #include "components/error_page/common/net_error_info.h" | 14 #include "components/error_page/common/net_error_info.h" |
| 15 #include "components/error_page/common/offline_page_types.h" |
15 #include "components/error_page/renderer/net_error_helper_core.h" | 16 #include "components/error_page/renderer/net_error_helper_core.h" |
16 #include "content/public/renderer/render_frame_observer.h" | 17 #include "content/public/renderer/render_frame_observer.h" |
17 #include "content/public/renderer/render_frame_observer_tracker.h" | 18 #include "content/public/renderer/render_frame_observer_tracker.h" |
18 #include "content/public/renderer/render_process_observer.h" | 19 #include "content/public/renderer/render_process_observer.h" |
19 | 20 |
20 class GURL; | 21 class GURL; |
21 | 22 |
22 namespace blink { | 23 namespace blink { |
23 class WebFrame; | 24 class WebFrame; |
24 class WebURLResponse; | 25 class WebURLResponse; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // Returns whether a load for |url| in the |frame| the NetErrorHelper is | 77 // Returns whether a load for |url| in the |frame| the NetErrorHelper is |
77 // attached to should have its error page suppressed. | 78 // attached to should have its error page suppressed. |
78 bool ShouldSuppressErrorPage(const GURL& url); | 79 bool ShouldSuppressErrorPage(const GURL& url); |
79 | 80 |
80 private: | 81 private: |
81 // NetErrorHelperCore::Delegate implementation: | 82 // NetErrorHelperCore::Delegate implementation: |
82 void GenerateLocalizedErrorPage( | 83 void GenerateLocalizedErrorPage( |
83 const blink::WebURLError& error, | 84 const blink::WebURLError& error, |
84 bool is_failed_post, | 85 bool is_failed_post, |
85 bool can_use_local_diagnostics_service, | 86 bool can_use_local_diagnostics_service, |
86 bool has_offline_pages, | 87 error_page::OfflinePageStatus offline_page_status, |
87 scoped_ptr<error_page::ErrorPageParams> params, | 88 scoped_ptr<error_page::ErrorPageParams> params, |
88 bool* reload_button_shown, | 89 bool* reload_button_shown, |
89 bool* show_saved_copy_button_shown, | 90 bool* show_saved_copy_button_shown, |
90 bool* show_cached_copy_button_shown, | 91 bool* show_cached_copy_button_shown, |
91 bool* show_saved_pages_button_shown, | 92 bool* show_offline_pages_button_shown, |
| 93 bool* show_offline_copy_button_shown, |
92 std::string* html) const override; | 94 std::string* html) const override; |
93 void LoadErrorPage(const std::string& html, const GURL& failed_url) override; | 95 void LoadErrorPage(const std::string& html, const GURL& failed_url) override; |
94 void EnablePageHelperFunctions() override; | 96 void EnablePageHelperFunctions() override; |
95 void UpdateErrorPage(const blink::WebURLError& error, | 97 void UpdateErrorPage( |
96 bool is_failed_post, | 98 const blink::WebURLError& error, |
97 bool can_use_local_diagnostics_service, | 99 bool is_failed_post, |
98 bool has_offline_pages) override; | 100 bool can_use_local_diagnostics_service, |
| 101 error_page::OfflinePageStatus offline_page_status) override; |
99 void FetchNavigationCorrections( | 102 void FetchNavigationCorrections( |
100 const GURL& navigation_correction_url, | 103 const GURL& navigation_correction_url, |
101 const std::string& navigation_correction_request_body) override; | 104 const std::string& navigation_correction_request_body) override; |
102 void CancelFetchNavigationCorrections() override; | 105 void CancelFetchNavigationCorrections() override; |
103 void SendTrackingRequest(const GURL& tracking_url, | 106 void SendTrackingRequest(const GURL& tracking_url, |
104 const std::string& tracking_request_body) override; | 107 const std::string& tracking_request_body) override; |
105 void ReloadPage(bool ignore_cache) override; | 108 void ReloadPage(bool ignore_cache) override; |
106 void LoadPageFromCache(const GURL& page_url) override; | 109 void LoadPageFromCache(const GURL& page_url) override; |
107 void DiagnoseError(const GURL& page_url) override; | 110 void DiagnoseError(const GURL& page_url) override; |
108 void ShowOfflinePages() override; | 111 void ShowOfflinePages() override; |
| 112 void LoadOfflineCopy(const GURL& page_url) override; |
109 | 113 |
110 void OnNetErrorInfo(int status); | 114 void OnNetErrorInfo(int status); |
111 void OnSetCanShowNetworkDiagnosticsDialog( | 115 void OnSetCanShowNetworkDiagnosticsDialog( |
112 bool can_use_local_diagnostics_service); | 116 bool can_use_local_diagnostics_service); |
113 void OnSetNavigationCorrectionInfo(const GURL& navigation_correction_url, | 117 void OnSetNavigationCorrectionInfo(const GURL& navigation_correction_url, |
114 const std::string& language, | 118 const std::string& language, |
115 const std::string& country_code, | 119 const std::string& country_code, |
116 const std::string& api_key, | 120 const std::string& api_key, |
117 const GURL& search_url); | 121 const GURL& search_url); |
118 | 122 |
119 void OnNavigationCorrectionsFetched(const blink::WebURLResponse& response, | 123 void OnNavigationCorrectionsFetched(const blink::WebURLResponse& response, |
120 const std::string& data); | 124 const std::string& data); |
121 | 125 |
122 void OnTrackingRequestComplete(const blink::WebURLResponse& response, | 126 void OnTrackingRequestComplete(const blink::WebURLResponse& response, |
123 const std::string& data); | 127 const std::string& data); |
| 128 |
124 #if defined(OS_ANDROID) | 129 #if defined(OS_ANDROID) |
125 void OnSetHasOfflinePages(bool has_offline_pages); | 130 // Called to set the status of the offline pages that will be used to decide |
| 131 // if offline related button will be provided in the error page. |
| 132 void OnSetOfflinePageInfo(error_page::OfflinePageStatus offline_page_status); |
126 #endif | 133 #endif |
127 | 134 |
128 scoped_ptr<content::ResourceFetcher> correction_fetcher_; | 135 scoped_ptr<content::ResourceFetcher> correction_fetcher_; |
129 scoped_ptr<content::ResourceFetcher> tracking_fetcher_; | 136 scoped_ptr<content::ResourceFetcher> tracking_fetcher_; |
130 | 137 |
131 scoped_ptr<error_page::NetErrorHelperCore> core_; | 138 scoped_ptr<error_page::NetErrorHelperCore> core_; |
132 | 139 |
133 // Weak factory for vending a weak pointer to a NetErrorPageController. Weak | 140 // Weak factory for vending a weak pointer to a NetErrorPageController. Weak |
134 // pointers are invalidated on each commit, to prevent getting messages from | 141 // pointers are invalidated on each commit, to prevent getting messages from |
135 // Controllers used for the previous commit that haven't yet been cleaned up. | 142 // Controllers used for the previous commit that haven't yet been cleaned up. |
136 base::WeakPtrFactory<NetErrorPageController::Delegate> | 143 base::WeakPtrFactory<NetErrorPageController::Delegate> |
137 weak_controller_delegate_factory_; | 144 weak_controller_delegate_factory_; |
138 | 145 |
139 DISALLOW_COPY_AND_ASSIGN(NetErrorHelper); | 146 DISALLOW_COPY_AND_ASSIGN(NetErrorHelper); |
140 }; | 147 }; |
141 | 148 |
142 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_H_ | 149 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_H_ |
OLD | NEW |