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

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: fix nit. 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 b63505107fe6f63bfd09cec8fcb4f18ddc09fc8c..7e3d35d7f5fade672db93b1b387bbe9139d4e776 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"
@@ -17,6 +18,8 @@ class WebContents;
namespace offline_pages {
+struct OfflinePageItem;
+
// Per-tab class to manage switch between online version and offline version.
class OfflinePageTabHelper :
public content::WebContentsObserver,
@@ -24,7 +27,15 @@ class OfflinePageTabHelper :
public:
~OfflinePageTabHelper() override;
+ const OfflinePageItem* offline_page() { return offline_page_.get(); }
+
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,14 +49,18 @@ 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);
+ // Iff the tab we are associated with is redirected to an offline page,
+ // |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_;
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