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

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

Issue 2100043004: [Offline pages] Filter out pages cached by different tabs on tab helper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updating comment to address CR Created 4 years, 6 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/offline_page_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/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);
« no previous file with comments | « no previous file | chrome/browser/android/offline_pages/offline_page_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698