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

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

Issue 1459793002: Android: Allow compiling browser without Java UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years 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 #include "chrome/browser/net/net_error_tab_helper.h" 5 #include "chrome/browser/net/net_error_tab_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/io_thread.h" 11 #include "chrome/browser/io_thread.h"
12 #include "chrome/browser/net/dns_probe_service.h" 12 #include "chrome/browser/net/dns_probe_service.h"
13 #include "chrome/browser/net/net_error_diagnostics_dialog.h" 13 #include "chrome/browser/net/net_error_diagnostics_dialog.h"
14 #include "chrome/browser/platform_util.h" 14 #include "chrome/browser/platform_util.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/common/features.h"
16 #include "chrome/common/localized_error.h" 17 #include "chrome/common/localized_error.h"
17 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
18 #include "chrome/common/render_messages.h" 19 #include "chrome/common/render_messages.h"
19 #include "components/error_page/common/net_error_info.h" 20 #include "components/error_page/common/net_error_info.h"
20 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/navigation_entry.h" 22 #include "content/public/browser/navigation_entry.h"
22 #include "content/public/browser/navigation_handle.h" 23 #include "content/public/browser/navigation_handle.h"
23 #include "content/public/browser/render_frame_host.h" 24 #include "content/public/browser/render_frame_host.h"
24 #include "ipc/ipc_message_macros.h" 25 #include "ipc/ipc_message_macros.h"
25 #include "net/base/net_errors.h" 26 #include "net/base/net_errors.h"
26 #include "url/gurl.h" 27 #include "url/gurl.h"
27 28
28 #if defined(OS_ANDROID) 29 #if BUILDFLAG(ANDROID_JAVA_UI)
29 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 30 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
30 #include "chrome/browser/android/tab_android.h" 31 #include "chrome/browser/android/tab_android.h"
31 #include "components/offline_pages/offline_page_feature.h" 32 #include "components/offline_pages/offline_page_feature.h"
32 #include "components/offline_pages/offline_page_item.h" 33 #include "components/offline_pages/offline_page_item.h"
33 #include "components/offline_pages/offline_page_model.h" 34 #include "components/offline_pages/offline_page_model.h"
34 #endif // defined(OS_ANDROID) 35 #endif // BUILDFLAG(ANDROID_JAVA_UI)
35 36
36 using content::BrowserContext; 37 using content::BrowserContext;
37 using content::BrowserThread; 38 using content::BrowserThread;
38 using content::WebContents; 39 using content::WebContents;
39 using content::WebContentsObserver; 40 using content::WebContentsObserver;
40 using error_page::DnsProbeStatus; 41 using error_page::DnsProbeStatus;
41 using error_page::DnsProbeStatusToString; 42 using error_page::DnsProbeStatusToString;
42 using error_page::OfflinePageStatus; 43 using error_page::OfflinePageStatus;
43 using ui::PageTransition; 44 using ui::PageTransition;
44 45
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 const GURL& validated_url, 125 const GURL& validated_url,
125 bool is_error_page, 126 bool is_error_page,
126 bool is_iframe_srcdoc) { 127 bool is_iframe_srcdoc) {
127 DCHECK_CURRENTLY_ON(BrowserThread::UI); 128 DCHECK_CURRENTLY_ON(BrowserThread::UI);
128 129
129 if (render_frame_host->GetParent()) 130 if (render_frame_host->GetParent())
130 return; 131 return;
131 132
132 is_error_page_ = is_error_page; 133 is_error_page_ = is_error_page;
133 134
134 #if defined(OS_ANDROID) 135 #if BUILDFLAG(ANDROID_JAVA_UI)
135 SetOfflinePageInfo(render_frame_host, validated_url); 136 SetOfflinePageInfo(render_frame_host, validated_url);
136 #endif // defined(OS_ANDROID) 137 #endif // BUILDFLAG(ANDROID_JAVA_UI)
137 } 138 }
138 139
139 void NetErrorTabHelper::DidCommitProvisionalLoadForFrame( 140 void NetErrorTabHelper::DidCommitProvisionalLoadForFrame(
140 content::RenderFrameHost* render_frame_host, 141 content::RenderFrameHost* render_frame_host,
141 const GURL& url, 142 const GURL& url,
142 PageTransition transition_type) { 143 PageTransition transition_type) {
143 DCHECK_CURRENTLY_ON(BrowserThread::UI); 144 DCHECK_CURRENTLY_ON(BrowserThread::UI);
144 145
145 if (render_frame_host->GetParent()) 146 if (render_frame_host->GetParent())
146 return; 147 return;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 179
179 bool NetErrorTabHelper::OnMessageReceived( 180 bool NetErrorTabHelper::OnMessageReceived(
180 const IPC::Message& message, 181 const IPC::Message& message,
181 content::RenderFrameHost* render_frame_host) { 182 content::RenderFrameHost* render_frame_host) {
182 if (render_frame_host != web_contents()->GetMainFrame()) 183 if (render_frame_host != web_contents()->GetMainFrame())
183 return false; 184 return false;
184 bool handled = true; 185 bool handled = true;
185 IPC_BEGIN_MESSAGE_MAP(NetErrorTabHelper, message) 186 IPC_BEGIN_MESSAGE_MAP(NetErrorTabHelper, message)
186 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RunNetworkDiagnostics, 187 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RunNetworkDiagnostics,
187 RunNetworkDiagnostics) 188 RunNetworkDiagnostics)
188 #if defined(OS_ANDROID) 189 #if BUILDFLAG(ANDROID_JAVA_UI)
189 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowOfflinePages, ShowOfflinePages) 190 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowOfflinePages, ShowOfflinePages)
190 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_LoadOfflineCopy, LoadOfflineCopy) 191 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_LoadOfflineCopy, LoadOfflineCopy)
191 #endif // defined(OS_ANDROID) 192 #endif // BUILDFLAG(ANDROID_JAVA_UI)
192 IPC_MESSAGE_UNHANDLED(handled = false) 193 IPC_MESSAGE_UNHANDLED(handled = false)
193 IPC_END_MESSAGE_MAP() 194 IPC_END_MESSAGE_MAP()
194 195
195 return handled; 196 return handled;
196 } 197 }
197 198
198 NetErrorTabHelper::NetErrorTabHelper(WebContents* contents) 199 NetErrorTabHelper::NetErrorTabHelper(WebContents* contents)
199 : WebContentsObserver(contents), 200 : WebContentsObserver(contents),
200 is_error_page_(false), 201 is_error_page_(false),
201 dns_error_active_(false), 202 dns_error_active_(false),
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 return; 290 return;
290 // Sanitize URL prior to running diagnostics on it. 291 // Sanitize URL prior to running diagnostics on it.
291 RunNetworkDiagnosticsHelper(url.GetOrigin().spec()); 292 RunNetworkDiagnosticsHelper(url.GetOrigin().spec());
292 } 293 }
293 294
294 void NetErrorTabHelper::RunNetworkDiagnosticsHelper( 295 void NetErrorTabHelper::RunNetworkDiagnosticsHelper(
295 const std::string& sanitized_url) { 296 const std::string& sanitized_url) {
296 ShowNetworkDiagnosticsDialog(web_contents(), sanitized_url); 297 ShowNetworkDiagnosticsDialog(web_contents(), sanitized_url);
297 } 298 }
298 299
299 #if defined(OS_ANDROID) 300 #if BUILDFLAG(ANDROID_JAVA_UI)
300 void NetErrorTabHelper::SetOfflinePageInfo( 301 void NetErrorTabHelper::SetOfflinePageInfo(
301 content::RenderFrameHost* render_frame_host, 302 content::RenderFrameHost* render_frame_host,
302 const GURL& url) { 303 const GURL& url) {
303 // Bails out if offline pages not supported. 304 // Bails out if offline pages not supported.
304 if (!offline_pages::IsOfflinePagesEnabled()) 305 if (!offline_pages::IsOfflinePagesEnabled())
305 return; 306 return;
306 307
307 offline_pages::OfflinePageModel* offline_page_model = 308 offline_pages::OfflinePageModel* offline_page_model =
308 offline_pages::OfflinePageModelFactory::GetForBrowserContext( 309 offline_pages::OfflinePageModelFactory::GetForBrowserContext(
309 web_contents()->GetBrowserContext()); 310 web_contents()->GetBrowserContext());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 if (tab) 348 if (tab)
348 tab->LoadOfflineCopy(url); 349 tab->LoadOfflineCopy(url);
349 } 350 }
350 351
351 bool NetErrorTabHelper::IsFromErrorPage() const { 352 bool NetErrorTabHelper::IsFromErrorPage() const {
352 content::NavigationEntry* entry = 353 content::NavigationEntry* entry =
353 web_contents()->GetController().GetLastCommittedEntry(); 354 web_contents()->GetController().GetLastCommittedEntry();
354 return entry && (entry->GetPageType() == content::PAGE_TYPE_ERROR); 355 return entry && (entry->GetPageType() == content::PAGE_TYPE_ERROR);
355 } 356 }
356 357
357 #endif // defined(OS_ANDROID) 358 #endif // BUILDFLAG(ANDROID_JAVA_UI)
358 359
359 } // namespace chrome_browser_net 360 } // namespace chrome_browser_net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698