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