Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3485)

Unified Diff: chrome/browser/android/offline_pages/recent_tab_helper.h

Issue 1936613002: Implementing recent pages snapshot capture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clang is my friend Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/android/offline_pages/recent_tab_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 00e1d24d2776485c4f71427d4b32c87714c8865b..57d252f9df6268b46c105093a4ade628855f7622 100644
--- a/chrome/browser/android/offline_pages/recent_tab_helper.h
+++ b/chrome/browser/android/offline_pages/recent_tab_helper.h
@@ -5,8 +5,20 @@
#ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_RECENT_TAB_HELPER_H_
#define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_RECENT_TAB_HELPER_H_
+#include <memory>
+#include <vector>
+
+#include "base/memory/weak_ptr.h"
+#include "components/offline_pages/offline_page_model.h"
+#include "components/offline_pages/snapshot_controller.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
+#include "url/gurl.h"
+
+namespace content {
+class NavigationEntry;
+class NavigationHandle;
+}
namespace offline_pages {
@@ -16,14 +28,65 @@ namespace offline_pages {
// snapshots of recent pages on the device.
class RecentTabHelper
: public content::WebContentsObserver,
- public content::WebContentsUserData<RecentTabHelper> {
+ public content::WebContentsUserData<RecentTabHelper>,
+ public SnapshotController::Client {
public:
~RecentTabHelper() override;
+ // content::WebContentsObserver
+ void DidFinishNavigation(
+ content::NavigationHandle* navigation_handle) override;
+ void DocumentAvailableInMainFrame() override;
+ void DocumentOnLoadCompletedInMainFrame() override;
+
+ // SnapshotController::Client
+ void StartSnapshot() override;
+
+ // Test support.
+ // A factory that supplies the instances of an OfflienPageArchiver.
+ // This is used for testing, where we want to use a specific mock.
+ class TestArchiveFactory {
+ public:
+ virtual ~TestArchiveFactory() {}
+ 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);
+
private:
explicit RecentTabHelper(content::WebContents* web_contents);
friend class content::WebContentsUserData<RecentTabHelper>;
+
+ void ContinueSnapshotWithIdsToPurge(const std::vector<int64_t>& page_ids);
+ void ContinueSnapshotAfterPurge(OfflinePageModel::DeletePageResult result);
+ void SavePageCallback(OfflinePageModel::SavePageResult result,
+ int64_t offline_id);
+
+ void ReportSnapshotCompleted();
+ bool IsSamePage() const;
+ ClientId client_id() const;
+
+ // Page model is a service, no ownership.
+ OfflinePageModel* page_model_;
+
+ // If true, never make snapshots off the attached WebContents.
+ bool never_do_snapshots_;
+
+ // 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_;
+
+ base::WeakPtrFactory<RecentTabHelper> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(RecentTabHelper);
};
« no previous file with comments | « no previous file | chrome/browser/android/offline_pages/recent_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698