NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / chrome / renderer / net / net_error_helper.h
blobc61ed0f41aae8700189c92f7aae4f40b68aefffc
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 "chrome/common/net/net_error_info.h"
11 #include "chrome/renderer/net/net_error_helper_core.h"
12 #include "content/public/renderer/render_frame_observer.h"
13 #include "content/public/renderer/render_frame_observer_tracker.h"
15 class GURL;
17 namespace content {
18 class ResourceFetcher;
21 namespace blink {
22 class WebFrame;
23 class WebURLResponse;
24 struct WebURLError;
27 // Listens for NetErrorInfo messages from the NetErrorTabHelper on the
28 // browser side and updates the error page with more details (currently, just
29 // DNS probe results) if/when available.
30 class NetErrorHelper
31 : public content::RenderFrameObserver,
32 public content::RenderFrameObserverTracker<NetErrorHelper>,
33 public NetErrorHelperCore::Delegate {
34 public:
35 explicit NetErrorHelper(content::RenderFrame* render_view);
36 virtual ~NetErrorHelper();
38 // RenderFrameObserver implementation.
39 virtual void DidStartProvisionalLoad() OVERRIDE;
40 virtual void DidCommitProvisionalLoad(bool is_new_navigation) OVERRIDE;
41 virtual void DidFinishLoad() OVERRIDE;
42 virtual void OnStop() OVERRIDE;
44 // IPC::Listener implementation.
45 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
47 // Examines |frame| and |error| to see if this is an error worthy of a DNS
48 // probe. If it is, initializes |error_strings| based on |error|,
49 // |is_failed_post|, and |locale| with suitable strings and returns true.
50 // If not, returns false, in which case the caller should look up error
51 // strings directly using LocalizedError::GetNavigationErrorStrings.
53 // Updates the NetErrorHelper with the assumption the page will be loaded
54 // immediately.
55 void GetErrorHTML(blink::WebFrame* frame,
56 const blink::WebURLError& error,
57 bool is_failed_post,
58 std::string* error_html);
60 private:
61 // NetErrorHelperCore::Delegate implementation:
62 virtual void GenerateLocalizedErrorPage(const blink::WebURLError& error,
63 bool is_failed_post,
64 std::string* html) const OVERRIDE;
65 virtual void LoadErrorPageInMainFrame(const std::string& html,
66 const GURL& failed_url) OVERRIDE;
67 virtual void UpdateErrorPage(const blink::WebURLError& error,
68 bool is_failed_post) OVERRIDE;
69 virtual void FetchErrorPage(const GURL& url) OVERRIDE;
70 virtual void CancelFetchErrorPage() OVERRIDE;
72 void OnNetErrorInfo(int status);
73 void OnSetAltErrorPageURL(const GURL& alternate_error_page_url);
75 void OnAlternateErrorPageRetrieved(const blink::WebURLResponse& response,
76 const std::string& data);
78 scoped_ptr<content::ResourceFetcher> alt_error_page_fetcher_;
80 NetErrorHelperCore core_;
83 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_H_