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

Side by Side Diff: chrome/browser/android/offline_pages/offline_page_utils.cc

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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/android/offline_pages/offline_page_utils.h" 5 #include "chrome/browser/android/offline_pages/offline_page_utils.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/guid.h" 8 #include "base/guid.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_piece.h" 11 #include "base/strings/string_piece.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "chrome/browser/android/offline_pages/downloads/offline_page_notificati on_bridge.h" 15 #include "chrome/browser/android/offline_pages/downloads/offline_page_notificati on_bridge.h"
16 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" 16 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h"
17 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 17 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
18 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h" 18 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h"
19 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" 19 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h"
20 #include "chrome/browser/android/tab_android.h" 20 #include "chrome/browser/android/tab_android.h"
21 #include "chrome/browser/net/net_error_tab_helper.h"
21 #include "components/offline_pages/core/background/request_coordinator.h" 22 #include "components/offline_pages/core/background/request_coordinator.h"
22 #include "components/offline_pages/core/background/save_page_request.h" 23 #include "components/offline_pages/core/background/save_page_request.h"
23 #include "components/offline_pages/core/client_namespace_constants.h" 24 #include "components/offline_pages/core/client_namespace_constants.h"
24 #include "components/offline_pages/core/client_policy_controller.h" 25 #include "components/offline_pages/core/client_policy_controller.h"
25 #include "components/offline_pages/core/offline_page_feature.h" 26 #include "components/offline_pages/core/offline_page_feature.h"
26 #include "components/offline_pages/core/offline_page_item.h" 27 #include "components/offline_pages/core/offline_page_item.h"
27 #include "components/offline_pages/core/offline_page_model.h" 28 #include "components/offline_pages/core/offline_page_model.h"
28 #include "components/offline_pages/core/request_header/offline_page_header.h" 29 #include "components/offline_pages/core/request_header/offline_page_header.h"
29 #include "content/public/browser/browser_context.h" 30 #include "content/public/browser/browser_context.h"
30 #include "content/public/browser/web_contents.h" 31 #include "content/public/browser/web_contents.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 133
133 // static 134 // static
134 bool OfflinePageUtils::IsShowingOfflinePreview( 135 bool OfflinePageUtils::IsShowingOfflinePreview(
135 content::WebContents* web_contents) { 136 content::WebContents* web_contents) {
136 OfflinePageTabHelper* tab_helper = 137 OfflinePageTabHelper* tab_helper =
137 OfflinePageTabHelper::FromWebContents(web_contents); 138 OfflinePageTabHelper::FromWebContents(web_contents);
138 return tab_helper && tab_helper->IsShowingOfflinePreview(); 139 return tab_helper && tab_helper->IsShowingOfflinePreview();
139 } 140 }
140 141
141 // static 142 // static
143 bool OfflinePageUtils::IsShowingDownloadButtonInErrorPage(
144 content::WebContents* web_contents) {
145 chrome_browser_net::NetErrorTabHelper* tab_helper =
146 chrome_browser_net::NetErrorTabHelper::FromWebContents(web_contents);
147 return tab_helper && tab_helper->is_showing_download_button_in_error_page();
148 }
149
150 // static
142 bool OfflinePageUtils::GetTabId(content::WebContents* web_contents, 151 bool OfflinePageUtils::GetTabId(content::WebContents* web_contents,
143 int* tab_id) { 152 int* tab_id) {
144 TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents); 153 TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents);
145 if (!tab_android) 154 if (!tab_android)
146 return false; 155 return false;
147 *tab_id = tab_android->GetAndroidId(); 156 *tab_id = tab_android->GetAndroidId();
148 return true; 157 return true;
149 } 158 }
150 159
151 // static 160 // static
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 ClientId client_id(kDownloadNamespace, base::GenerateGUID()); 246 ClientId client_id(kDownloadNamespace, base::GenerateGUID());
238 request_coordinator->SavePageLater( 247 request_coordinator->SavePageLater(
239 url, client_id, true, 248 url, client_id, true,
240 RequestCoordinator::RequestAvailability::ENABLED_FOR_OFFLINER); 249 RequestCoordinator::RequestAvailability::ENABLED_FOR_OFFLINER);
241 250
242 android::OfflinePageNotificationBridge notification_bridge; 251 android::OfflinePageNotificationBridge notification_bridge;
243 notification_bridge.ShowDownloadingToast(); 252 notification_bridge.ShowDownloadingToast();
244 } 253 }
245 254
246 } // namespace offline_pages 255 } // namespace offline_pages
OLDNEW
« no previous file with comments | « chrome/browser/android/offline_pages/offline_page_utils.h ('k') | chrome/browser/net/net_error_tab_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698