Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / chrome / renderer / net / net_error_helper.h
blob7701ba0c514abdcbfdd887519229683475878d90
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
3 // found in the LICENSE file.
5 #ifndef CHROME_RENDERER_NET_NET_ERROR_HELPER_H_
6 #define CHROME_RENDERER_NET_NET_ERROR_HELPER_H_
8 #include <string>
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "components/error_page/common/net_error_info.h"
13 #include "components/error_page/renderer/net_error_helper_core.h"
14 #include "content/public/renderer/render_frame_observer.h"
15 #include "content/public/renderer/render_frame_observer_tracker.h"
16 #include "content/public/renderer/render_process_observer.h"
18 class GURL;
20 namespace blink {
21 class WebFrame;
22 class WebURLResponse;
23 struct WebURLError;
26 namespace content {
27 class ResourceFetcher;
30 namespace error_page {
31 struct ErrorPageParams;
34 // Listens for NetErrorInfo messages from the NetErrorTabHelper on the
35 // browser side and updates the error page with more details (currently, just
36 // DNS probe results) if/when available.
37 class NetErrorHelper
38 : public content::RenderFrameObserver,
39 public content::RenderFrameObserverTracker<NetErrorHelper>,
40 public content::RenderProcessObserver,
41 public error_page::NetErrorHelperCore::Delegate {
42 public:
43 explicit NetErrorHelper(content::RenderFrame* render_view);
44 ~NetErrorHelper() override;
46 // Button press notification from error page.
47 void ReloadButtonPressed();
48 void ShowSavedCopyButtonPressed();
49 void MoreButtonPressed();
51 // RenderFrameObserver implementation.
52 void DidStartProvisionalLoad() override;
53 void DidCommitProvisionalLoad(bool is_new_navigation,
54 bool is_same_page_navigation) override;
55 void DidFinishLoad() override;
56 void OnStop() override;
57 void WasShown() override;
58 void WasHidden() override;
60 // IPC::Listener implementation.
61 bool OnMessageReceived(const IPC::Message& message) override;
63 // RenderProcessObserver implementation.
64 void NetworkStateChanged(bool online) override;
66 // Examines |frame| and |error| to see if this is an error worthy of a DNS
67 // probe. If it is, initializes |error_strings| based on |error|,
68 // |is_failed_post|, and |locale| with suitable strings and returns true.
69 // If not, returns false, in which case the caller should look up error
70 // strings directly using LocalizedError::GetNavigationErrorStrings.
72 // Updates the NetErrorHelper with the assumption the page will be loaded
73 // immediately.
74 void GetErrorHTML(blink::WebFrame* frame,
75 const blink::WebURLError& error,
76 bool is_failed_post,
77 std::string* error_html);
79 // Returns whether a load for |url| in |frame| should have its error page
80 // suppressed.
81 bool ShouldSuppressErrorPage(blink::WebFrame* frame, const GURL& url);
83 // Called when a link with the given tracking ID is pressed.
84 void TrackClick(int tracking_id);
86 // Tracks easter egg activations on the offline interstitial.
87 void TrackActivatedEasterEgg();
89 private:
90 // NetErrorHelperCore::Delegate implementation:
91 void GenerateLocalizedErrorPage(
92 const blink::WebURLError& error,
93 bool is_failed_post,
94 scoped_ptr<error_page::ErrorPageParams> params,
95 bool* reload_button_shown,
96 bool* show_saved_copy_button_shown,
97 std::string* html) const override;
98 void LoadErrorPageInMainFrame(const std::string& html,
99 const GURL& failed_url) override;
100 void EnablePageHelperFunctions() override;
101 void UpdateErrorPage(const blink::WebURLError& error,
102 bool is_failed_post) override;
103 void FetchNavigationCorrections(
104 const GURL& navigation_correction_url,
105 const std::string& navigation_correction_request_body) override;
106 void CancelFetchNavigationCorrections() override;
107 void SendTrackingRequest(const GURL& tracking_url,
108 const std::string& tracking_request_body) override;
109 void ReloadPage() override;
110 void LoadPageFromCache(const GURL& page_url) override;
112 void OnNetErrorInfo(int status);
113 void OnSetNavigationCorrectionInfo(const GURL& navigation_correction_url,
114 const std::string& language,
115 const std::string& country_code,
116 const std::string& api_key,
117 const GURL& search_url);
119 void OnNavigationCorrectionsFetched(const blink::WebURLResponse& response,
120 const std::string& data);
122 void OnTrackingRequestComplete(const blink::WebURLResponse& response,
123 const std::string& data);
125 scoped_ptr<content::ResourceFetcher> correction_fetcher_;
126 scoped_ptr<content::ResourceFetcher> tracking_fetcher_;
128 scoped_ptr<error_page::NetErrorHelperCore> core_;
130 DISALLOW_COPY_AND_ASSIGN(NetErrorHelper);
133 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_H_