| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/downloads/offline_page_download_b
ridge.h" | 5 #include "chrome/browser/android/offline_pages/downloads/offline_page_download_b
ridge.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 RecentTabHelper::FromWebContents(web_contents); | 227 RecentTabHelper::FromWebContents(web_contents); |
| 228 if (tab_helper && | 228 if (tab_helper && |
| 229 !tab_helper->is_page_ready_for_snapshot() && | 229 !tab_helper->is_page_ready_for_snapshot() && |
| 230 offline_pages::IsBackgroundLoaderForDownloadsEnabled()) { | 230 offline_pages::IsBackgroundLoaderForDownloadsEnabled()) { |
| 231 // TODO(dimich): Improve this to wait for the page load if it is still going | 231 // TODO(dimich): Improve this to wait for the page load if it is still going |
| 232 // on. Pre-submit the request and if the load finishes and capture happens, | 232 // on. Pre-submit the request and if the load finishes and capture happens, |
| 233 // remove request. | 233 // remove request. |
| 234 offline_pages::RequestCoordinator* request_coordinator = | 234 offline_pages::RequestCoordinator* request_coordinator = |
| 235 offline_pages::RequestCoordinatorFactory::GetForBrowserContext( | 235 offline_pages::RequestCoordinatorFactory::GetForBrowserContext( |
| 236 tab->GetProfile()->GetOriginalProfile()); | 236 tab->GetProfile()->GetOriginalProfile()); |
| 237 request_coordinator->SavePageLater(url, client_id, true); | 237 request_coordinator->SavePageLater( |
| 238 url, client_id, true, |
| 239 RequestCoordinator::RequestAvailability::AVAILABLE_TO_OFFLINER); |
| 238 return; | 240 return; |
| 239 } | 241 } |
| 240 | 242 |
| 241 // Page is ready, capture it right from the tab. | 243 // Page is ready, capture it right from the tab. |
| 242 offline_pages::OfflinePageModel* offline_page_model = | 244 offline_pages::OfflinePageModel* offline_page_model = |
| 243 OfflinePageModelFactory::GetForBrowserContext( | 245 OfflinePageModelFactory::GetForBrowserContext( |
| 244 tab->GetProfile()->GetOriginalProfile()); | 246 tab->GetProfile()->GetOriginalProfile()); |
| 245 if (!offline_page_model) | 247 if (!offline_page_model) |
| 246 return; | 248 return; |
| 247 | 249 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 | 356 |
| 355 DownloadUIAdapter* adapter = | 357 DownloadUIAdapter* adapter = |
| 356 DownloadUIAdapter::FromOfflinePageModel(offline_page_model); | 358 DownloadUIAdapter::FromOfflinePageModel(offline_page_model); |
| 357 | 359 |
| 358 return reinterpret_cast<jlong>( | 360 return reinterpret_cast<jlong>( |
| 359 new OfflinePageDownloadBridge(env, obj, adapter, browser_context)); | 361 new OfflinePageDownloadBridge(env, obj, adapter, browser_context)); |
| 360 } | 362 } |
| 361 | 363 |
| 362 } // namespace android | 364 } // namespace android |
| 363 } // namespace offline_pages | 365 } // namespace offline_pages |
| OLD | NEW |