| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/recent_tab_helper.h" | 5 #include "chrome/browser/android/offline_pages/recent_tab_helper.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 return base::ThreadTaskRunnerHandle::Get(); | 47 return base::ThreadTaskRunnerHandle::Get(); |
| 48 } | 48 } |
| 49 bool GetTabId(content::WebContents* web_contents, int* tab_id) override { | 49 bool GetTabId(content::WebContents* web_contents, int* tab_id) override { |
| 50 return offline_pages::OfflinePageUtils::GetTabId(web_contents, tab_id); | 50 return offline_pages::OfflinePageUtils::GetTabId(web_contents, tab_id); |
| 51 } | 51 } |
| 52 }; | 52 }; |
| 53 } // namespace | 53 } // namespace |
| 54 | 54 |
| 55 namespace offline_pages { | 55 namespace offline_pages { |
| 56 | 56 |
| 57 using PageQuality = SnapshotController::PageQuality; |
| 58 |
| 57 bool RecentTabHelper::SnapshotProgressInfo::IsForLastN() { | 59 bool RecentTabHelper::SnapshotProgressInfo::IsForLastN() { |
| 58 // A last_n snapshot always has an invalid request id. | 60 // A last_n snapshot always has an invalid request id. |
| 59 return request_id == OfflinePageModel::kInvalidOfflineId; | 61 return request_id == OfflinePageModel::kInvalidOfflineId; |
| 60 } | 62 } |
| 61 | 63 |
| 62 RecentTabHelper::RecentTabHelper(content::WebContents* web_contents) | 64 RecentTabHelper::RecentTabHelper(content::WebContents* web_contents) |
| 63 : content::WebContentsObserver(web_contents), | 65 : content::WebContentsObserver(web_contents), |
| 64 delegate_(new DefaultDelegate()), | 66 delegate_(new DefaultDelegate()), |
| 65 weak_ptr_factory_(this) { | 67 weak_ptr_factory_(this) { |
| 66 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 68 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 if (snapshots_enabled_) { | 130 if (snapshots_enabled_) { |
| 129 page_model_ = OfflinePageModelFactory::GetForBrowserContext( | 131 page_model_ = OfflinePageModelFactory::GetForBrowserContext( |
| 130 web_contents()->GetBrowserContext()); | 132 web_contents()->GetBrowserContext()); |
| 131 } | 133 } |
| 132 | 134 |
| 133 return snapshots_enabled_; | 135 return snapshots_enabled_; |
| 134 } | 136 } |
| 135 | 137 |
| 136 void RecentTabHelper::DidFinishNavigation( | 138 void RecentTabHelper::DidFinishNavigation( |
| 137 content::NavigationHandle* navigation_handle) { | 139 content::NavigationHandle* navigation_handle) { |
| 138 if (!navigation_handle->IsInMainFrame() || navigation_handle->IsSamePage() || | 140 if (!navigation_handle->IsInMainFrame() || |
| 139 !navigation_handle->HasCommitted()) { | 141 !navigation_handle->HasCommitted()) { |
| 140 return; | 142 return; |
| 141 } | 143 } |
| 142 | 144 |
| 143 if (!EnsureInitialized()) | 145 if (!EnsureInitialized()) |
| 144 return; | 146 return; |
| 145 | 147 |
| 146 // We navigated to a different page, lets report progress to Background | 148 // We navigated to a different page, lets report progress to Background |
| 147 // Offliner. | 149 // Offliner. |
| 148 if (downloads_latest_snapshot_info_) | 150 if (downloads_latest_snapshot_info_) |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 else | 345 else |
| 344 request_coordinator->EnableForOffliner(snapshot_info->request_id, | 346 request_coordinator->EnableForOffliner(snapshot_info->request_id, |
| 345 snapshot_info->client_id); | 347 snapshot_info->client_id); |
| 346 } | 348 } |
| 347 | 349 |
| 348 ClientId RecentTabHelper::GetRecentPagesClientId() const { | 350 ClientId RecentTabHelper::GetRecentPagesClientId() const { |
| 349 return ClientId(kLastNNamespace, tab_id_); | 351 return ClientId(kLastNNamespace, tab_id_); |
| 350 } | 352 } |
| 351 | 353 |
| 352 } // namespace offline_pages | 354 } // namespace offline_pages |
| OLD | NEW |