Chromium Code Reviews| 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" |
| 14 #include "chrome/browser/android/offline_pages/downloads/offline_page_notificati on_bridge.h" | |
| 13 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" | 15 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" |
| 14 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 16 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
| 15 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h" | 17 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h" |
| 16 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" | 18 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" |
| 17 #include "chrome/browser/android/tab_android.h" | 19 #include "chrome/browser/android/tab_android.h" |
| 18 #include "components/offline_pages/background/request_coordinator.h" | 20 #include "components/offline_pages/background/request_coordinator.h" |
| 19 #include "components/offline_pages/background/save_page_request.h" | 21 #include "components/offline_pages/background/save_page_request.h" |
| 20 #include "components/offline_pages/client_namespace_constants.h" | 22 #include "components/offline_pages/client_namespace_constants.h" |
| 21 #include "components/offline_pages/client_policy_controller.h" | 23 #include "components/offline_pages/client_policy_controller.h" |
| 22 #include "components/offline_pages/offline_page_feature.h" | 24 #include "components/offline_pages/offline_page_feature.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 const GURL& rhs) { | 207 const GURL& rhs) { |
| 206 GURL::Replacements remove_params; | 208 GURL::Replacements remove_params; |
| 207 remove_params.ClearRef(); | 209 remove_params.ClearRef(); |
| 208 | 210 |
| 209 GURL lhs_stripped = lhs.ReplaceComponents(remove_params); | 211 GURL lhs_stripped = lhs.ReplaceComponents(remove_params); |
| 210 GURL rhs_stripped = lhs.ReplaceComponents(remove_params); | 212 GURL rhs_stripped = lhs.ReplaceComponents(remove_params); |
| 211 | 213 |
| 212 return lhs_stripped == rhs_stripped; | 214 return lhs_stripped == rhs_stripped; |
| 213 } | 215 } |
| 214 | 216 |
| 217 void OfflinePageUtils::CreateOfflinePageDownload( | |
| 218 content::BrowserContext* context, | |
| 219 const GURL& url) { | |
| 220 RequestCoordinator* request_coordinator = | |
|
jianli
2016/11/23 01:27:32
RequestCoordinator instance will be null (per http
Pete Williamson
2016/11/23 01:42:40
Drive-by: May I suggest returning early if the re
Dmitry Titov
2016/11/23 20:18:00
Done.
| |
| 221 RequestCoordinatorFactory::GetForBrowserContext(context); | |
| 222 | |
| 223 ClientId client_id; | |
|
jianli
2016/11/23 01:27:32
Probably better to say:
ClientId client_id(kDown
Dmitry Titov
2016/11/23 20:18:00
Done.
| |
| 224 client_id.name_space = kDownloadNamespace; | |
| 225 client_id.id = base::GenerateGUID(); | |
| 226 | |
| 227 request_coordinator->SavePageLater( | |
| 228 url, client_id, true, | |
| 229 RequestCoordinator::RequestAvailability::ENABLED_FOR_OFFLINER); | |
| 230 | |
| 231 android::OfflinePageNotificationBridge notification_bridge; | |
| 232 notification_bridge.ShowDownloadingToast(); | |
| 233 } | |
| 234 | |
| 215 } // namespace offline_pages | 235 } // namespace offline_pages |
| OLD | NEW |