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

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

Issue 2246143003: Allow opening an offline download file as offline page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | no next file » | 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.cc
diff --git a/chrome/browser/android/offline_pages/offline_page_tab_helper.cc b/chrome/browser/android/offline_pages/offline_page_tab_helper.cc
index 506124a20286639e4b5c638a5326c42e15f10d81..2e1715be706a4b5f5594e146cb664df4352bf17f 100644
--- a/chrome/browser/android/offline_pages/offline_page_tab_helper.cc
+++ b/chrome/browser/android/offline_pages/offline_page_tab_helper.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/net/nqe/ui_network_quality_estimator_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "components/offline_pages/client_namespace_constants.h"
+#include "components/offline_pages/offline_page_item.h"
#include "components/offline_pages/offline_page_model.h"
#include "components/previews/previews_experiments.h"
#include "content/public/browser/browser_thread.h"
@@ -102,6 +103,24 @@ void OfflinePageTabHelper::DidStartNavigation(
if (offline_page_ && navigated_url != offline_page_->GetOfflineURL())
offline_page_ = nullptr;
+ // If an offline download file is opened, don't do redirect per network
+ // conditions. Also store a cached copy here such that Tab knows that
+ // the offline page is opened.
+ if (OfflinePageUtils::MightBeOfflineURL(navigated_url)) {
+ OfflinePageModel* offline_page_model =
+ OfflinePageModelFactory::GetForBrowserContext(
+ web_contents()->GetBrowserContext());
+ if (offline_page_model) {
+ const OfflinePageItem* offline_page =
+ offline_page_model->MaybeGetPageByOfflineURL(navigated_url);
+ if (offline_page &&
+ offline_page->client_id.name_space == kDownloadNamespace) {
+ offline_page_ = base::MakeUnique<OfflinePageItem>(*offline_page);
+ return;
+ }
+ }
+ }
+
// Ignore navigations that are forward or back transitions in the nav stack
// which are not at the head of the stack.
// TODO(dimich): Not sure this is needed. Clarify and remove. Bug 624216.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698