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

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

Issue 2310583002: Convert some NetError[Tab]Helper messages to mojom (Closed)
Patch Set: Created 4 years, 3 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"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "chrome/browser/net/dns_probe_service.h" 14 #include "chrome/browser/net/dns_probe_service.h"
15 #include "chrome/common/features.h" 15 #include "chrome/common/features.h"
16 #include "chrome/common/network_diagnostics.mojom.h"
16 #include "components/error_page/common/net_error_info.h" 17 #include "components/error_page/common/net_error_info.h"
17 #include "components/prefs/pref_member.h" 18 #include "components/prefs/pref_member.h"
19 #include "content/public/browser/remote_frame_interface.h"
18 #include "content/public/browser/web_contents_observer.h" 20 #include "content/public/browser/web_contents_observer.h"
19 #include "content/public/browser/web_contents_user_data.h" 21 #include "content/public/browser/web_contents_user_data.h"
20 22
23 namespace content {
24 class WebContentsInterfaceRegistry;
25 }
26
21 namespace chrome_browser_net { 27 namespace chrome_browser_net {
22 28
23 // A TabHelper that monitors loads for certain types of network errors and 29 // A TabHelper that monitors loads for certain types of network errors and
24 // does interesting things with them. Currently, starts DNS probes using the 30 // does interesting things with them. Currently, starts DNS probes using the
25 // DnsProbeService whenever a page fails to load with a DNS-related error. 31 // DnsProbeService whenever a page fails to load with a DNS-related error.
26 class NetErrorTabHelper 32 class NetErrorTabHelper
27 : public content::WebContentsObserver, 33 : public content::WebContentsObserver,
28 public content::WebContentsUserData<NetErrorTabHelper> { 34 public content::WebContentsUserData<NetErrorTabHelper>,
35 public mojom::NetworkDiagnostics {
29 public: 36 public:
30 enum TestingState { 37 enum TestingState {
31 TESTING_DEFAULT, 38 TESTING_DEFAULT,
32 TESTING_FORCE_DISABLED, 39 TESTING_FORCE_DISABLED,
33 TESTING_FORCE_ENABLED 40 TESTING_FORCE_ENABLED
34 }; 41 };
35 42
36 typedef base::Callback<void(error_page::DnsProbeStatus)> 43 typedef base::Callback<void(error_page::DnsProbeStatus)>
37 DnsProbeStatusSnoopCallback; 44 DnsProbeStatusSnoopCallback;
38 45
(...skipping 29 matching lines...) Expand all
68 75
69 void DidFailProvisionalLoad(content::RenderFrameHost* render_frame_host, 76 void DidFailProvisionalLoad(content::RenderFrameHost* render_frame_host,
70 const GURL& validated_url, 77 const GURL& validated_url,
71 int error_code, 78 int error_code,
72 const base::string16& error_description, 79 const base::string16& error_description,
73 bool was_ignored_by_handler) override; 80 bool was_ignored_by_handler) override;
74 81
75 bool OnMessageReceived(const IPC::Message& message, 82 bool OnMessageReceived(const IPC::Message& message,
76 content::RenderFrameHost* render_frame_host) override; 83 content::RenderFrameHost* render_frame_host) override;
77 84
85 content::WebContentsInterfaceRegistry* interfaces_for_testing() {
86 return interfaces_.get();
87 }
78 88
79 protected: 89 protected:
80 // |contents| is the WebContents of the tab this NetErrorTabHelper is 90 // |contents| is the WebContents of the tab this NetErrorTabHelper is
81 // attached to. 91 // attached to.
82 explicit NetErrorTabHelper(content::WebContents* contents); 92 explicit NetErrorTabHelper(content::WebContents* contents);
83 virtual void StartDnsProbe(); 93 virtual void StartDnsProbe();
84 virtual void SendInfo(); 94 virtual void SendInfo();
85 void OnDnsProbeFinished(error_page::DnsProbeStatus result); 95 void OnDnsProbeFinished(error_page::DnsProbeStatus result);
86 96
87 error_page::DnsProbeStatus dns_probe_status() const { 97 error_page::DnsProbeStatus dns_probe_status() const {
88 return dns_probe_status_; 98 return dns_probe_status_;
89 } 99 }
90 100
91 private: 101 private:
92 friend class content::WebContentsUserData<NetErrorTabHelper>; 102 friend class content::WebContentsUserData<NetErrorTabHelper>;
93 103
94 void OnMainFrameDnsError(); 104 void OnMainFrameDnsError();
95 105
96 void InitializePref(content::WebContents* contents); 106 void InitializePref(content::WebContents* contents);
97 bool ProbesAllowed() const; 107 bool ProbesAllowed() const;
98 108
99 // Sanitizes |url| and shows a dialog for it. 109 // mojom::NetworkDiagnostics:
100 void RunNetworkDiagnostics(const GURL& url); 110 void RunNetworkDiagnostics(const GURL& url) override;
101 111
102 // Shows the diagnostics dialog after its been sanitized, virtual for 112 // Shows the diagnostics dialog after its been sanitized, virtual for
103 // testing. 113 // testing.
104 virtual void RunNetworkDiagnosticsHelper(const std::string& sanitized_url); 114 virtual void RunNetworkDiagnosticsHelper(const std::string& sanitized_url);
105 115
106 // Relates to offline pages handling. 116 // Relates to offline pages handling.
107 #if BUILDFLAG(ANDROID_JAVA_UI) 117 #if BUILDFLAG(ANDROID_JAVA_UI)
108 void UpdateHasOfflinePages(content::RenderFrameHost* render_frame_host); 118 void UpdateHasOfflinePages(content::RenderFrameHost* render_frame_host);
109 void SetHasOfflinePages(int frame_tree_node_id, bool has_offline_pages); 119 void SetHasOfflinePages(int frame_tree_node_id, bool has_offline_pages);
110 void ShowOfflinePages(); 120 void ShowOfflinePages();
111 bool IsFromErrorPage() const; 121 bool IsFromErrorPage() const;
112 #endif // BUILDFLAG(ANDROID_JAVA_UI) 122 #endif // BUILDFLAG(ANDROID_JAVA_UI)
113 123
124 std::unique_ptr<content::WebContentsInterfaceRegistry> interfaces_;
125 content::RemoteFrameInterface<mojom::NetworkDiagnosticsClient>
126 remote_network_diagnostics_client_;
127
114 // True if the last provisional load that started was for an error page. 128 // True if the last provisional load that started was for an error page.
115 bool is_error_page_; 129 bool is_error_page_;
116 130
117 // True if the helper has seen a main frame page load fail with a DNS error, 131 // True if the helper has seen a main frame page load fail with a DNS error,
118 // but has not yet seen a new page commit successfully afterwards. 132 // but has not yet seen a new page commit successfully afterwards.
119 bool dns_error_active_; 133 bool dns_error_active_;
120 134
121 // True if the helper has seen an error page commit while |dns_error_active_| 135 // True if the helper has seen an error page commit while |dns_error_active_|
122 // is true. (This should never be true if |dns_error_active_| is false.) 136 // is true. (This should never be true if |dns_error_active_| is false.)
123 bool dns_error_page_committed_; 137 bool dns_error_page_committed_;
(...skipping 11 matching lines...) Expand all
135 BooleanPrefMember resolve_errors_with_web_service_; 149 BooleanPrefMember resolve_errors_with_web_service_;
136 150
137 base::WeakPtrFactory<NetErrorTabHelper> weak_factory_; 151 base::WeakPtrFactory<NetErrorTabHelper> weak_factory_;
138 152
139 DISALLOW_COPY_AND_ASSIGN(NetErrorTabHelper); 153 DISALLOW_COPY_AND_ASSIGN(NetErrorTabHelper);
140 }; 154 };
141 155
142 } // namespace chrome_browser_net 156 } // namespace chrome_browser_net
143 157
144 #endif // CHROME_BROWSER_NET_NET_ERROR_TAB_HELPER_H_ 158 #endif // CHROME_BROWSER_NET_NET_ERROR_TAB_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/net_error_tab_helper.cc » ('j') | chrome/browser/net/net_error_tab_helper.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698