OLD | NEW |
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/location.h" | 8 #include "base/location.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" | 14 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" |
15 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 15 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
16 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h" | 16 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h" |
17 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" | 17 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" |
18 #include "chrome/browser/android/tab_android.h" | 18 #include "chrome/browser/android/tab_android.h" |
| 19 #include "chrome/browser/net/net_error_tab_helper.h" |
19 #include "components/offline_pages/core/background/request_coordinator.h" | 20 #include "components/offline_pages/core/background/request_coordinator.h" |
20 #include "components/offline_pages/core/background/save_page_request.h" | 21 #include "components/offline_pages/core/background/save_page_request.h" |
21 #include "components/offline_pages/core/client_namespace_constants.h" | 22 #include "components/offline_pages/core/client_namespace_constants.h" |
22 #include "components/offline_pages/core/client_policy_controller.h" | 23 #include "components/offline_pages/core/client_policy_controller.h" |
23 #include "components/offline_pages/core/offline_page_feature.h" | 24 #include "components/offline_pages/core/offline_page_feature.h" |
24 #include "components/offline_pages/core/offline_page_item.h" | 25 #include "components/offline_pages/core/offline_page_item.h" |
25 #include "components/offline_pages/core/offline_page_model.h" | 26 #include "components/offline_pages/core/offline_page_model.h" |
26 #include "components/offline_pages/core/request_header/offline_page_header.h" | 27 #include "components/offline_pages/core/request_header/offline_page_header.h" |
27 #include "content/public/browser/browser_context.h" | 28 #include "content/public/browser/browser_context.h" |
28 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 131 |
131 // static | 132 // static |
132 bool OfflinePageUtils::IsShowingOfflinePreview( | 133 bool OfflinePageUtils::IsShowingOfflinePreview( |
133 content::WebContents* web_contents) { | 134 content::WebContents* web_contents) { |
134 OfflinePageTabHelper* tab_helper = | 135 OfflinePageTabHelper* tab_helper = |
135 OfflinePageTabHelper::FromWebContents(web_contents); | 136 OfflinePageTabHelper::FromWebContents(web_contents); |
136 return tab_helper && tab_helper->IsShowingOfflinePreview(); | 137 return tab_helper && tab_helper->IsShowingOfflinePreview(); |
137 } | 138 } |
138 | 139 |
139 // static | 140 // static |
| 141 bool OfflinePageUtils::IsShowingDownloadButtonInErrorPage( |
| 142 content::WebContents* web_contents) { |
| 143 chrome_browser_net::NetErrorTabHelper* tab_helper = |
| 144 chrome_browser_net::NetErrorTabHelper::FromWebContents(web_contents); |
| 145 return tab_helper && tab_helper->is_showing_download_button_in_error_page(); |
| 146 } |
| 147 |
| 148 // static |
140 bool OfflinePageUtils::GetTabId(content::WebContents* web_contents, | 149 bool OfflinePageUtils::GetTabId(content::WebContents* web_contents, |
141 int* tab_id) { | 150 int* tab_id) { |
142 TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents); | 151 TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents); |
143 if (!tab_android) | 152 if (!tab_android) |
144 return false; | 153 return false; |
145 *tab_id = tab_android->GetAndroidId(); | 154 *tab_id = tab_android->GetAndroidId(); |
146 return true; | 155 return true; |
147 } | 156 } |
148 | 157 |
149 // static | 158 // static |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 GURL::Replacements remove_params; | 223 GURL::Replacements remove_params; |
215 remove_params.ClearRef(); | 224 remove_params.ClearRef(); |
216 | 225 |
217 GURL lhs_stripped = lhs.ReplaceComponents(remove_params); | 226 GURL lhs_stripped = lhs.ReplaceComponents(remove_params); |
218 GURL rhs_stripped = rhs.ReplaceComponents(remove_params); | 227 GURL rhs_stripped = rhs.ReplaceComponents(remove_params); |
219 | 228 |
220 return lhs_stripped == rhs_stripped; | 229 return lhs_stripped == rhs_stripped; |
221 } | 230 } |
222 | 231 |
223 } // namespace offline_pages | 232 } // namespace offline_pages |
OLD | NEW |