| 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 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_RECENT_TAB_HELPER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_RECENT_TAB_HELPER_H_ |
| 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_RECENT_TAB_HELPER_H_ | 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_RECENT_TAB_HELPER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 public: | 48 public: |
| 49 virtual ~Delegate() {} | 49 virtual ~Delegate() {} |
| 50 virtual std::unique_ptr<OfflinePageArchiver> CreatePageArchiver( | 50 virtual std::unique_ptr<OfflinePageArchiver> CreatePageArchiver( |
| 51 content::WebContents* web_contents) = 0; | 51 content::WebContents* web_contents) = 0; |
| 52 virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() = 0; | 52 virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() = 0; |
| 53 // There is no expectations that tab_id is always present. | 53 // There is no expectations that tab_id is always present. |
| 54 virtual bool GetTabId(content::WebContents* web_contents, int* tab_id) = 0; | 54 virtual bool GetTabId(content::WebContents* web_contents, int* tab_id) = 0; |
| 55 }; | 55 }; |
| 56 void SetDelegate(std::unique_ptr<RecentTabHelper::Delegate> delegate); | 56 void SetDelegate(std::unique_ptr<RecentTabHelper::Delegate> delegate); |
| 57 | 57 |
| 58 bool is_page_ready_for_snapshot() const { |
| 59 return is_page_ready_for_snapshot_; |
| 60 } |
| 61 |
| 58 private: | 62 private: |
| 59 explicit RecentTabHelper(content::WebContents* web_contents); | 63 explicit RecentTabHelper(content::WebContents* web_contents); |
| 60 friend class content::WebContentsUserData<RecentTabHelper>; | 64 friend class content::WebContentsUserData<RecentTabHelper>; |
| 61 | 65 |
| 62 | 66 |
| 63 void LazyInitialize(); | 67 void EnsureInitialized(); |
| 64 void ContinueSnapshotWithIdsToPurge(const std::vector<int64_t>& page_ids); | 68 void ContinueSnapshotWithIdsToPurge(const std::vector<int64_t>& page_ids); |
| 65 void ContinueSnapshotAfterPurge(OfflinePageModel::DeletePageResult result); | 69 void ContinueSnapshotAfterPurge(OfflinePageModel::DeletePageResult result); |
| 66 void SavePageCallback(OfflinePageModel::SavePageResult result, | 70 void SavePageCallback(OfflinePageModel::SavePageResult result, |
| 67 int64_t offline_id); | 71 int64_t offline_id); |
| 68 | 72 |
| 69 void ReportSnapshotCompleted(); | 73 void ReportSnapshotCompleted(); |
| 70 bool IsSamePage() const; | 74 bool IsSamePage() const; |
| 71 ClientId client_id() const; | 75 ClientId client_id() const; |
| 72 | 76 |
| 73 // Page model is a service, no ownership. | 77 // Page model is a service, no ownership. Can be null - for example, in |
| 78 // case when tab is in incognito profile. |
| 74 OfflinePageModel* page_model_; | 79 OfflinePageModel* page_model_; |
| 75 // If false, never make snapshots off the attached WebContents. | 80 // If false, never make snapshots off the attached WebContents. |
| 81 // Not page-specific. |
| 76 bool snapshots_enabled_; | 82 bool snapshots_enabled_; |
| 83 // Becomes true during navigation if the page is ready for snapshot as |
| 84 // indicated by at least one callback from SnapshotController. |
| 85 bool is_page_ready_for_snapshot_; |
| 77 // If empty, the tab does not have AndroidId and can not capture pages. | 86 // If empty, the tab does not have AndroidId and can not capture pages. |
| 78 std::string tab_id_; | 87 std::string tab_id_; |
| 79 | 88 |
| 80 // The URL of the page that is currently being snapshotted. Used to check, | 89 // The URL of the page that is currently being snapshotted. Used to check, |
| 81 // during async operations, that WebContents still contains the same page. | 90 // during async operations, that WebContents still contains the same page. |
| 82 GURL snapshot_url_; | 91 GURL snapshot_url_; |
| 92 // This starts out null and used as a flag for EnsureInitialized() to do the |
| 93 // initialization only once. |
| 83 std::unique_ptr<SnapshotController> snapshot_controller_; | 94 std::unique_ptr<SnapshotController> snapshot_controller_; |
| 84 | 95 |
| 85 std::unique_ptr<Delegate> delegate_; | 96 std::unique_ptr<Delegate> delegate_; |
| 86 | 97 |
| 87 base::WeakPtrFactory<RecentTabHelper> weak_ptr_factory_; | 98 base::WeakPtrFactory<RecentTabHelper> weak_ptr_factory_; |
| 88 | 99 |
| 89 DISALLOW_COPY_AND_ASSIGN(RecentTabHelper); | 100 DISALLOW_COPY_AND_ASSIGN(RecentTabHelper); |
| 90 }; | 101 }; |
| 91 | 102 |
| 92 } // namespace offline_pages | 103 } // namespace offline_pages |
| 93 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_RECENT_TAB_HELPER_H_ | 104 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_RECENT_TAB_HELPER_H_ |
| OLD | NEW |