| 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" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // Listens for NetErrorInfo messages from the NetErrorTabHelper on the | 34 // Listens for NetErrorInfo messages from the NetErrorTabHelper on the |
| 35 // browser side and updates the error page with more details (currently, just | 35 // browser side and updates the error page with more details (currently, just |
| 36 // DNS probe results) if/when available. | 36 // DNS probe results) if/when available. |
| 37 class NetErrorHelper | 37 class NetErrorHelper |
| 38 : public content::RenderFrameObserver, | 38 : public content::RenderFrameObserver, |
| 39 public content::RenderFrameObserverTracker<NetErrorHelper>, | 39 public content::RenderFrameObserverTracker<NetErrorHelper>, |
| 40 public content::RenderProcessObserver, | 40 public content::RenderProcessObserver, |
| 41 public error_page::NetErrorHelperCore::Delegate { | 41 public error_page::NetErrorHelperCore::Delegate { |
| 42 public: | 42 public: |
| 43 explicit NetErrorHelper(content::RenderFrame* render_view); | 43 explicit NetErrorHelper(content::RenderFrame* render_view); |
| 44 virtual ~NetErrorHelper(); | 44 ~NetErrorHelper() override; |
| 45 | 45 |
| 46 // Button press notification from error page. | 46 // Button press notification from error page. |
| 47 void ReloadButtonPressed(); | 47 void ReloadButtonPressed(); |
| 48 void LoadStaleButtonPressed(); | 48 void LoadStaleButtonPressed(); |
| 49 void MoreButtonPressed(); | 49 void MoreButtonPressed(); |
| 50 | 50 |
| 51 // RenderFrameObserver implementation. | 51 // RenderFrameObserver implementation. |
| 52 virtual void DidStartProvisionalLoad() override; | 52 void DidStartProvisionalLoad() override; |
| 53 virtual void DidCommitProvisionalLoad(bool is_new_navigation) override; | 53 void DidCommitProvisionalLoad(bool is_new_navigation) override; |
| 54 virtual void DidFinishLoad() override; | 54 void DidFinishLoad() override; |
| 55 virtual void OnStop() override; | 55 void OnStop() override; |
| 56 virtual void WasShown() override; | 56 void WasShown() override; |
| 57 virtual void WasHidden() override; | 57 void WasHidden() override; |
| 58 | 58 |
| 59 // IPC::Listener implementation. | 59 // IPC::Listener implementation. |
| 60 virtual bool OnMessageReceived(const IPC::Message& message) override; | 60 bool OnMessageReceived(const IPC::Message& message) override; |
| 61 | 61 |
| 62 // RenderProcessObserver implementation. | 62 // RenderProcessObserver implementation. |
| 63 virtual void NetworkStateChanged(bool online) override; | 63 void NetworkStateChanged(bool online) override; |
| 64 | 64 |
| 65 // Examines |frame| and |error| to see if this is an error worthy of a DNS | 65 // Examines |frame| and |error| to see if this is an error worthy of a DNS |
| 66 // probe. If it is, initializes |error_strings| based on |error|, | 66 // probe. If it is, initializes |error_strings| based on |error|, |
| 67 // |is_failed_post|, and |locale| with suitable strings and returns true. | 67 // |is_failed_post|, and |locale| with suitable strings and returns true. |
| 68 // If not, returns false, in which case the caller should look up error | 68 // If not, returns false, in which case the caller should look up error |
| 69 // strings directly using LocalizedError::GetNavigationErrorStrings. | 69 // strings directly using LocalizedError::GetNavigationErrorStrings. |
| 70 // | 70 // |
| 71 // Updates the NetErrorHelper with the assumption the page will be loaded | 71 // Updates the NetErrorHelper with the assumption the page will be loaded |
| 72 // immediately. | 72 // immediately. |
| 73 void GetErrorHTML(blink::WebFrame* frame, | 73 void GetErrorHTML(blink::WebFrame* frame, |
| 74 const blink::WebURLError& error, | 74 const blink::WebURLError& error, |
| 75 bool is_failed_post, | 75 bool is_failed_post, |
| 76 std::string* error_html); | 76 std::string* error_html); |
| 77 | 77 |
| 78 // Returns whether a load for |url| in |frame| should have its error page | 78 // Returns whether a load for |url| in |frame| should have its error page |
| 79 // suppressed. | 79 // suppressed. |
| 80 bool ShouldSuppressErrorPage(blink::WebFrame* frame, const GURL& url); | 80 bool ShouldSuppressErrorPage(blink::WebFrame* frame, const GURL& url); |
| 81 | 81 |
| 82 // Called when a link with the given tracking ID is pressed. | 82 // Called when a link with the given tracking ID is pressed. |
| 83 void TrackClick(int tracking_id); | 83 void TrackClick(int tracking_id); |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 // NetErrorHelperCore::Delegate implementation: | 86 // NetErrorHelperCore::Delegate implementation: |
| 87 virtual void GenerateLocalizedErrorPage( | 87 void GenerateLocalizedErrorPage( |
| 88 const blink::WebURLError& error, | 88 const blink::WebURLError& error, |
| 89 bool is_failed_post, | 89 bool is_failed_post, |
| 90 scoped_ptr<error_page::ErrorPageParams> params, | 90 scoped_ptr<error_page::ErrorPageParams> params, |
| 91 bool* reload_button_shown, | 91 bool* reload_button_shown, |
| 92 bool* load_stale_button_shown, | 92 bool* load_stale_button_shown, |
| 93 std::string* html) const override; | 93 std::string* html) const override; |
| 94 virtual void LoadErrorPageInMainFrame(const std::string& html, | 94 void LoadErrorPageInMainFrame(const std::string& html, |
| 95 const GURL& failed_url) override; | 95 const GURL& failed_url) override; |
| 96 virtual void EnablePageHelperFunctions() override; | 96 void EnablePageHelperFunctions() override; |
| 97 virtual void UpdateErrorPage(const blink::WebURLError& error, | 97 void UpdateErrorPage(const blink::WebURLError& error, |
| 98 bool is_failed_post) override; | 98 bool is_failed_post) override; |
| 99 virtual void FetchNavigationCorrections( | 99 void FetchNavigationCorrections( |
| 100 const GURL& navigation_correction_url, | 100 const GURL& navigation_correction_url, |
| 101 const std::string& navigation_correction_request_body) override; | 101 const std::string& navigation_correction_request_body) override; |
| 102 virtual void CancelFetchNavigationCorrections() override; | 102 void CancelFetchNavigationCorrections() override; |
| 103 virtual void SendTrackingRequest( | 103 void SendTrackingRequest(const GURL& tracking_url, |
| 104 const GURL& tracking_url, | 104 const std::string& tracking_request_body) override; |
| 105 const std::string& tracking_request_body) override; | 105 void ReloadPage() override; |
| 106 virtual void ReloadPage() override; | 106 void LoadPageFromCache(const GURL& page_url) override; |
| 107 virtual void LoadPageFromCache(const GURL& page_url) override; | |
| 108 | 107 |
| 109 void OnNetErrorInfo(int status); | 108 void OnNetErrorInfo(int status); |
| 110 void OnSetNavigationCorrectionInfo(const GURL& navigation_correction_url, | 109 void OnSetNavigationCorrectionInfo(const GURL& navigation_correction_url, |
| 111 const std::string& language, | 110 const std::string& language, |
| 112 const std::string& country_code, | 111 const std::string& country_code, |
| 113 const std::string& api_key, | 112 const std::string& api_key, |
| 114 const GURL& search_url); | 113 const GURL& search_url); |
| 115 | 114 |
| 116 void OnNavigationCorrectionsFetched(const blink::WebURLResponse& response, | 115 void OnNavigationCorrectionsFetched(const blink::WebURLResponse& response, |
| 117 const std::string& data); | 116 const std::string& data); |
| 118 | 117 |
| 119 void OnTrackingRequestComplete(const blink::WebURLResponse& response, | 118 void OnTrackingRequestComplete(const blink::WebURLResponse& response, |
| 120 const std::string& data); | 119 const std::string& data); |
| 121 | 120 |
| 122 scoped_ptr<content::ResourceFetcher> correction_fetcher_; | 121 scoped_ptr<content::ResourceFetcher> correction_fetcher_; |
| 123 scoped_ptr<content::ResourceFetcher> tracking_fetcher_; | 122 scoped_ptr<content::ResourceFetcher> tracking_fetcher_; |
| 124 | 123 |
| 125 scoped_ptr<error_page::NetErrorHelperCore> core_; | 124 scoped_ptr<error_page::NetErrorHelperCore> core_; |
| 126 | 125 |
| 127 DISALLOW_COPY_AND_ASSIGN(NetErrorHelper); | 126 DISALLOW_COPY_AND_ASSIGN(NetErrorHelper); |
| 128 }; | 127 }; |
| 129 | 128 |
| 130 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_H_ | 129 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_H_ |
| OLD | NEW |