Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(376)

Side by Side Diff: chrome/browser/net/net_error_tab_helper.h

Issue 2588253002: Enable download page action for error page (Closed)
Patch Set: Address download feedback Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_BROWSER_NET_NET_ERROR_TAB_HELPER_H_ 5 #ifndef CHROME_BROWSER_NET_NET_ERROR_TAB_HELPER_H_
6 #define CHROME_BROWSER_NET_NET_ERROR_TAB_HELPER_H_ 6 #define CHROME_BROWSER_NET_NET_ERROR_TAB_HELPER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 static void set_state_for_testing(TestingState testing_state); 44 static void set_state_for_testing(TestingState testing_state);
45 45
46 // Sets a callback that will be called immediately after the helper sends 46 // Sets a callback that will be called immediately after the helper sends
47 // a NetErrorHelper IPC. (Used by the DNS probe browser test to know when to 47 // a NetErrorHelper IPC. (Used by the DNS probe browser test to know when to
48 // check the error page for updates, instead of polling.) 48 // check the error page for updates, instead of polling.)
49 void set_dns_probe_status_snoop_callback_for_testing( 49 void set_dns_probe_status_snoop_callback_for_testing(
50 const DnsProbeStatusSnoopCallback& dns_probe_status_snoop_callback) { 50 const DnsProbeStatusSnoopCallback& dns_probe_status_snoop_callback) {
51 dns_probe_status_snoop_callback_ = dns_probe_status_snoop_callback; 51 dns_probe_status_snoop_callback_ = dns_probe_status_snoop_callback;
52 } 52 }
53 53
54 #if defined(OS_ANDROID)
55 bool is_showing_download_button_in_error_page() const {
56 return is_showing_download_button_in_error_page_;
57 }
58 #endif // defined(OS_ANDROID)
59
54 // content::WebContentsObserver implementation. 60 // content::WebContentsObserver implementation.
55 void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; 61 void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
56 void DidStartNavigation( 62 void DidStartNavigation(
57 content::NavigationHandle* navigation_handle) override; 63 content::NavigationHandle* navigation_handle) override;
58 void DidFinishNavigation( 64 void DidFinishNavigation(
59 content::NavigationHandle* navigation_handle) override; 65 content::NavigationHandle* navigation_handle) override;
60 bool OnMessageReceived(const IPC::Message& message, 66 bool OnMessageReceived(const IPC::Message& message,
61 content::RenderFrameHost* render_frame_host) override; 67 content::RenderFrameHost* render_frame_host) override;
62 68
63 protected: 69 protected:
64 // |contents| is the WebContents of the tab this NetErrorTabHelper is 70 // |contents| is the WebContents of the tab this NetErrorTabHelper is
65 // attached to. 71 // attached to.
66 explicit NetErrorTabHelper(content::WebContents* contents); 72 explicit NetErrorTabHelper(content::WebContents* contents);
67 virtual void StartDnsProbe(); 73 virtual void StartDnsProbe();
68 virtual void SendInfo(); 74 virtual void SendInfo();
69 void OnDnsProbeFinished(error_page::DnsProbeStatus result); 75 void OnDnsProbeFinished(error_page::DnsProbeStatus result);
70 76
71 error_page::DnsProbeStatus dns_probe_status() const { 77 error_page::DnsProbeStatus dns_probe_status() const {
72 return dns_probe_status_; 78 return dns_probe_status_;
73 } 79 }
74 80
75 content::WebContentsFrameBindingSet<chrome::mojom::NetworkDiagnostics>& 81 content::WebContentsFrameBindingSet<chrome::mojom::NetworkDiagnostics>&
76 network_diagnostics_bindings_for_testing() { 82 network_diagnostics_bindings_for_testing() {
77 return network_diagnostics_bindings_; 83 return network_diagnostics_bindings_;
78 } 84 }
79 85
80 #if defined(OS_ANDROID) 86 #if defined(OS_ANDROID)
81 void DownloadPageLater(); 87 void OnDownloadPageLater();
88 void OnSetIsShowingDownloadButtonInErrorPage(bool is_showing_download_button);
82 #endif // defined(OS_ANDROID) 89 #endif // defined(OS_ANDROID)
83 90
84 private: 91 private:
85 friend class content::WebContentsUserData<NetErrorTabHelper>; 92 friend class content::WebContentsUserData<NetErrorTabHelper>;
86 93
87 void OnMainFrameDnsError(); 94 void OnMainFrameDnsError();
88 95
89 void InitializePref(content::WebContents* contents); 96 void InitializePref(content::WebContents* contents);
90 bool ProbesAllowed() const; 97 bool ProbesAllowed() const;
91 98
(...skipping 16 matching lines...) Expand all
108 bool is_error_page_; 115 bool is_error_page_;
109 116
110 // True if the helper has seen a main frame page load fail with a DNS error, 117 // True if the helper has seen a main frame page load fail with a DNS error,
111 // but has not yet seen a new page commit successfully afterwards. 118 // but has not yet seen a new page commit successfully afterwards.
112 bool dns_error_active_; 119 bool dns_error_active_;
113 120
114 // True if the helper has seen an error page commit while |dns_error_active_| 121 // True if the helper has seen an error page commit while |dns_error_active_|
115 // is true. (This should never be true if |dns_error_active_| is false.) 122 // is true. (This should never be true if |dns_error_active_| is false.)
116 bool dns_error_page_committed_; 123 bool dns_error_page_committed_;
117 124
125 #if defined(OS_ANDROID)
126 // True if download button is being shown when the error page commits.
127 bool is_showing_download_button_in_error_page_;
128 #endif // defined(OS_ANDROID)
129
118 // The status of a DNS probe that may or may not have started or finished. 130 // The status of a DNS probe that may or may not have started or finished.
119 // Since the renderer can change out from under the helper (in cross-process 131 // Since the renderer can change out from under the helper (in cross-process
120 // navigations), it re-sends the status whenever an error page commits. 132 // navigations), it re-sends the status whenever an error page commits.
121 error_page::DnsProbeStatus dns_probe_status_; 133 error_page::DnsProbeStatus dns_probe_status_;
122 134
123 // Optional callback for browser test to snoop on outgoing NetErrorInfo IPCs. 135 // Optional callback for browser test to snoop on outgoing NetErrorInfo IPCs.
124 DnsProbeStatusSnoopCallback dns_probe_status_snoop_callback_; 136 DnsProbeStatusSnoopCallback dns_probe_status_snoop_callback_;
125 137
126 // "Use a web service to resolve navigation errors" preference is required 138 // "Use a web service to resolve navigation errors" preference is required
127 // to allow probes. 139 // to allow probes.
128 BooleanPrefMember resolve_errors_with_web_service_; 140 BooleanPrefMember resolve_errors_with_web_service_;
129 141
130 base::WeakPtrFactory<NetErrorTabHelper> weak_factory_; 142 base::WeakPtrFactory<NetErrorTabHelper> weak_factory_;
131 143
132 DISALLOW_COPY_AND_ASSIGN(NetErrorTabHelper); 144 DISALLOW_COPY_AND_ASSIGN(NetErrorTabHelper);
133 }; 145 };
134 146
135 } // namespace chrome_browser_net 147 } // namespace chrome_browser_net
136 148
137 #endif // CHROME_BROWSER_NET_NET_ERROR_TAB_HELPER_H_ 149 #endif // CHROME_BROWSER_NET_NET_ERROR_TAB_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/offline_pages/offline_page_utils.cc ('k') | chrome/browser/net/net_error_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698