| Index: chrome/browser/android/offline_pages/offline_page_tab_helper.h
|
| diff --git a/chrome/browser/android/offline_pages/offline_page_tab_helper.h b/chrome/browser/android/offline_pages/offline_page_tab_helper.h
|
| index 7e3d35d7f5fade672db93b1b387bbe9139d4e776..af283e22b529c82a9280c3a39737383927bd13c7 100644
|
| --- a/chrome/browser/android/offline_pages/offline_page_tab_helper.h
|
| +++ b/chrome/browser/android/offline_pages/offline_page_tab_helper.h
|
| @@ -25,6 +25,15 @@ class OfflinePageTabHelper :
|
| public content::WebContentsObserver,
|
| public content::WebContentsUserData<OfflinePageTabHelper> {
|
| public:
|
| + // Delegate that is used to better handle external dependencies.
|
| + // Default implementation is in .cc file, while tests provide an override.
|
| + class Delegate {
|
| + public:
|
| + virtual ~Delegate() {}
|
| + virtual bool GetTabId(content::WebContents* web_contents,
|
| + std::string* tab_id) const = 0;
|
| + };
|
| +
|
| ~OfflinePageTabHelper() override;
|
|
|
| const OfflinePageItem* offline_page() { return offline_page_.get(); }
|
| @@ -43,6 +52,8 @@ class OfflinePageTabHelper :
|
|
|
| explicit OfflinePageTabHelper(content::WebContents* web_contents);
|
|
|
| + void SetDelegateForTesting(std::unique_ptr<Delegate> delegate);
|
| +
|
| // Overridden from content::WebContentsObserver:
|
| void DidStartNavigation(
|
| content::NavigationHandle* navigation_handle) override;
|
| @@ -51,9 +62,19 @@ class OfflinePageTabHelper :
|
|
|
| void RedirectToOnline(const GURL& from_url,
|
| const OfflinePageItem* offline_page);
|
| +
|
| + // 3 step redirection to the offline page. First getting all the pages, then
|
| + // selecting appropriate page to redirect to and finally attempting to
|
| + // redirect to that offline page, and caching metadata of that page locally.
|
| + void GetPagesForRedirectToOffline(const GURL& online_url,
|
| + RedirectReason reason);
|
| + void SelectBestPageForRedirectToOffline(
|
| + const GURL& online_url,
|
| + RedirectReason reason,
|
| + const MultipleOfflinePageItemResult& pages);
|
| void TryRedirectToOffline(RedirectReason redirect_reason,
|
| const GURL& from_url,
|
| - const OfflinePageItem* offline_page);
|
| + const OfflinePageItem& offline_page);
|
|
|
| void Redirect(const GURL& from_url, const GURL& to_url);
|
|
|
| @@ -61,6 +82,7 @@ class OfflinePageTabHelper :
|
| // |offline_page_| will be non-null. This can be used to synchronously ask
|
| // about the offline state of the current web contents.
|
| std::unique_ptr<OfflinePageItem> offline_page_;
|
| + std::unique_ptr<Delegate> delegate_;
|
| base::WeakPtrFactory<OfflinePageTabHelper> weak_ptr_factory_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(OfflinePageTabHelper);
|
|
|