Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / renderer / net / net_error_helper.h
blob2af13da79c02cc88a8ff6db76cc2edcbbb72789e
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_view_observer.h"
13 #include "content/public/renderer/render_view_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::RenderViewObserver,
32 public content::RenderViewObserverTracker<NetErrorHelper>,
33 public NetErrorHelperCore::Delegate {
34 public:
35 explicit NetErrorHelper(content::RenderView* render_view);
36 virtual ~NetErrorHelper();
38 // RenderViewObserver implementation.
39 virtual void DidStartProvisionalLoad(blink::WebFrame* frame) OVERRIDE;
40 virtual void DidCommitProvisionalLoad(blink::WebFrame* frame,
41 bool is_new_navigation) OVERRIDE;
42 virtual void DidFinishLoad(blink::WebFrame* frame) OVERRIDE;
43 virtual void OnStop() OVERRIDE;
45 // IPC::Listener implementation.
46 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
48 // Examines |frame| and |error| to see if this is an error worthy of a DNS
49 // probe. If it is, initializes |error_strings| based on |error|,
50 // |is_failed_post|, and |locale| with suitable strings and returns true.
51 // If not, returns false, in which case the caller should look up error
52 // strings directly using LocalizedError::GetNavigationErrorStrings.
54 // Updates the NetErrorHelper with the assumption the page will be loaded
55 // immediately.
56 void GetErrorHTML(blink::WebFrame* frame,
57 const blink::WebURLError& error,
58 bool is_failed_post,
59 std::string* error_html);
61 private:
62 // NetErrorHelperCore::Delegate implementation:
63 virtual void GenerateLocalizedErrorPage(const blink::WebURLError& error,
64 bool is_failed_post,
65 std::string* html) const OVERRIDE;
66 virtual void LoadErrorPageInMainFrame(const std::string& html,
67 const GURL& failed_url) OVERRIDE;
68 virtual void UpdateErrorPage(const blink::WebURLError& error,
69 bool is_failed_post) OVERRIDE;
70 virtual void FetchErrorPage(const GURL& url) OVERRIDE;
71 virtual void CancelFetchErrorPage() OVERRIDE;
73 void OnNetErrorInfo(int status);
74 void OnSetAltErrorPageURL(const GURL& alternate_error_page_url);
76 void OnAlternateErrorPageRetrieved(const blink::WebURLResponse& response,
77 const std::string& data);
79 scoped_ptr<content::ResourceFetcher> alt_error_page_fetcher_;
81 NetErrorHelperCore core_;
84 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_H_