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/guid.h" |
8 #include "base/location.h" | 9 #include "base/location.h" |
9 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
11 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
12 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
13 #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" |
14 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" | 16 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" |
15 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 17 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
16 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h" | 18 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h" |
17 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" | 19 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" |
18 #include "chrome/browser/android/tab_android.h" | 20 #include "chrome/browser/android/tab_android.h" |
19 #include "components/offline_pages/core/background/request_coordinator.h" | 21 #include "components/offline_pages/core/background/request_coordinator.h" |
20 #include "components/offline_pages/core/background/save_page_request.h" | 22 #include "components/offline_pages/core/background/save_page_request.h" |
21 #include "components/offline_pages/core/client_namespace_constants.h" | 23 #include "components/offline_pages/core/client_namespace_constants.h" |
22 #include "components/offline_pages/core/client_policy_controller.h" | 24 #include "components/offline_pages/core/client_policy_controller.h" |
23 #include "components/offline_pages/core/offline_page_feature.h" | 25 #include "components/offline_pages/core/offline_page_feature.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 const GURL& rhs) { | 215 const GURL& rhs) { |
214 GURL::Replacements remove_params; | 216 GURL::Replacements remove_params; |
215 remove_params.ClearRef(); | 217 remove_params.ClearRef(); |
216 | 218 |
217 GURL lhs_stripped = lhs.ReplaceComponents(remove_params); | 219 GURL lhs_stripped = lhs.ReplaceComponents(remove_params); |
218 GURL rhs_stripped = rhs.ReplaceComponents(remove_params); | 220 GURL rhs_stripped = rhs.ReplaceComponents(remove_params); |
219 | 221 |
220 return lhs_stripped == rhs_stripped; | 222 return lhs_stripped == rhs_stripped; |
221 } | 223 } |
222 | 224 |
| 225 // static |
| 226 void OfflinePageUtils::StartOfflinePageDownload( |
| 227 content::BrowserContext* context, |
| 228 const GURL& url) { |
| 229 RequestCoordinator* request_coordinator = |
| 230 RequestCoordinatorFactory::GetForBrowserContext(context); |
| 231 |
| 232 // TODO(dimich): Enable in Incognito when Android Downloads implement |
| 233 // Incognito story. |
| 234 if (!request_coordinator) |
| 235 return; |
| 236 |
| 237 ClientId client_id(kDownloadNamespace, base::GenerateGUID()); |
| 238 request_coordinator->SavePageLater( |
| 239 url, client_id, true, |
| 240 RequestCoordinator::RequestAvailability::ENABLED_FOR_OFFLINER); |
| 241 |
| 242 android::OfflinePageNotificationBridge notification_bridge; |
| 243 notification_bridge.ShowDownloadingToast(); |
| 244 } |
| 245 |
223 } // namespace offline_pages | 246 } // namespace offline_pages |
OLD | NEW |