| Index: chrome/browser/android/offline_pages/recent_tab_helper.h
|
| diff --git a/chrome/browser/android/offline_pages/recent_tab_helper.h b/chrome/browser/android/offline_pages/recent_tab_helper.h
|
| index 025f52b8fbce9d61a67d79cb7270e2b931dd1321..8d65fa9e9ab4c2539aa1a78ff3e07a6defe7f0c6 100644
|
| --- a/chrome/browser/android/offline_pages/recent_tab_helper.h
|
| +++ b/chrome/browser/android/offline_pages/recent_tab_helper.h
|
| @@ -51,19 +51,27 @@ class RecentTabHelper
|
| virtual std::unique_ptr<OfflinePageArchiver> CreateArchiver(
|
| content::WebContents* web_contents) = 0;
|
| };
|
| - // Test method, overrides the normally used MHTML Archivers with a test
|
| - // mocks created by specified function.
|
| - void SetArchiveFactoryForTest(
|
| - std::unique_ptr<TestArchiveFactory> test_archive_factory);
|
| - // Test method, overrides the task_runner_ so FastForwardBy() can be used.
|
| - void SetTaskRunnerForTest(
|
| - const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
|
| +
|
| +
|
| + // Delegate that is used by RecentTabHelper to get external dependencies.
|
| + // Default implementation lives in .cc file, while tests provide an override.
|
| + class Delegate {
|
| + public:
|
| + virtual ~Delegate() {}
|
| + virtual std::unique_ptr<OfflinePageArchiver> CreatePageArchiver(
|
| + content::WebContents* web_contents) = 0;
|
| + virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() = 0;
|
| + // There is no expectations that tab_id is always present.
|
| + virtual bool GetTabId(content::WebContents* web_contents, int* tab_id) = 0;
|
| + };
|
| + void SetDelegate(std::unique_ptr<RecentTabHelper::Delegate> delegate);
|
|
|
| private:
|
| explicit RecentTabHelper(content::WebContents* web_contents);
|
| friend class content::WebContentsUserData<RecentTabHelper>;
|
|
|
|
|
| + void LazyInitialize();
|
| void ContinueSnapshotWithIdsToPurge(const std::vector<int64_t>& page_ids);
|
| void ContinueSnapshotAfterPurge(OfflinePageModel::DeletePageResult result);
|
| void SavePageCallback(OfflinePageModel::SavePageResult result,
|
| @@ -75,15 +83,17 @@ class RecentTabHelper
|
|
|
| // Page model is a service, no ownership.
|
| OfflinePageModel* page_model_;
|
| -
|
| // If true, never make snapshots off the attached WebContents.
|
| bool never_do_snapshots_;
|
| + // If empty, the tab does not have AndroidId and can not capture pages.
|
| + std::string tab_id_;
|
|
|
| // The URL of the page that is currently being snapshotted. Used to check,
|
| // during async operations, that WebContents still contains the same page.
|
| GURL snapshot_url_;
|
| std::unique_ptr<SnapshotController> snapshot_controller_;
|
| - std::unique_ptr<TestArchiveFactory> test_archive_factory_;
|
| +
|
| + std::unique_ptr<Delegate> delegate_;
|
|
|
| base::WeakPtrFactory<RecentTabHelper> weak_ptr_factory_;
|
|
|
|
|