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

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

Issue 2040163003: Refactors offline page tab helper to stash the offline page item on redirect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@single-result
Patch Set: Add a dedicated test. 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
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 b63505107fe6f63bfd09cec8fcb4f18ddc09fc8c..055dc3d72930d2195dc96ece19f4ba8300937bf7 100644
--- a/chrome/browser/android/offline_pages/offline_page_tab_helper.h
+++ b/chrome/browser/android/offline_pages/offline_page_tab_helper.h
@@ -7,6 +7,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
+#include "components/offline_pages/offline_page_types.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
#include "url/gurl.h"
@@ -16,6 +17,7 @@ class WebContents;
}
namespace offline_pages {
+struct OfflinePageItem;
// Per-tab class to manage switch between online version and offline version.
class OfflinePageTabHelper :
@@ -25,6 +27,12 @@ class OfflinePageTabHelper :
~OfflinePageTabHelper() override;
private:
+ enum class RedirectReason {
+ DISCONNECTED_NETWORK,
+ FLAKY_NETWORK,
+ FLAKY_NETWORK_FORWARD_BACK
+ };
+
friend class content::WebContentsUserData<OfflinePageTabHelper>;
friend class OfflinePageTabHelperTest;
FRIEND_TEST_ALL_PREFIXES(OfflinePageTabHelperTest,
@@ -38,13 +46,15 @@ class OfflinePageTabHelper :
void DidFinishNavigation(
content::NavigationHandle* navigation_handle) override;
- void GotRedirectURLForSupportedErrorCode(ui::PageTransition transition,
- const GURL& from_url,
- const GURL& redirect_url);
- void GotRedirectURLForStartedNavigation(const GURL& from_url,
- const GURL& redirect_url);
+ void RedirectToOnline(const GURL& from_url,
+ const OfflinePageItem* offline_page);
+ void TryRedirectToOffline(RedirectReason redirect_reason,
+ const GURL& from_url,
+ const OfflinePageItem* offline_page);
- void Redirect(const GURL& from_url, const GURL& to_url);
+ void Redirect(const GURL& from_url,
+ const GURL& to_url,
+ const OfflinePageItem* offline_page);
base::WeakPtrFactory<OfflinePageTabHelper> weak_ptr_factory_;

Powered by Google App Engine
This is Rietveld 408576698