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

Unified Diff: chrome/browser/android/offline_pages/downloads/offline_page_download_bridge.cc

Issue 2713013002: Track original URL when downloading a redirected page (Closed)
Patch Set: A little update Created 3 years, 10 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/downloads/offline_page_download_bridge.cc
diff --git a/chrome/browser/android/offline_pages/downloads/offline_page_download_bridge.cc b/chrome/browser/android/offline_pages/downloads/offline_page_download_bridge.cc
index d7ef68da8e7b52ea94767a452fff64b193746b81..8b41e031c5cd5c8bd1cee7b3b4736bbdbdab44ab 100644
--- a/chrome/browser/android/offline_pages/downloads/offline_page_download_bridge.cc
+++ b/chrome/browser/android/offline_pages/downloads/offline_page_download_bridge.cc
@@ -89,7 +89,8 @@ content::WebContents* GetWebContentsFromJavaTab(
return tab->web_contents();
}
-void SavePageIfNotNavigatedAway(const GURL& original_url,
+void SavePageIfNotNavigatedAway(const GURL& url,
+ const GURL& original_url,
const ScopedJavaGlobalRef<jobject>& j_tab_ref) {
content::WebContents* web_contents = GetWebContentsFromJavaTab(j_tab_ref);
if (!web_contents)
@@ -97,8 +98,8 @@ void SavePageIfNotNavigatedAway(const GURL& original_url,
// This ignores fragment differences in URLs, bails out only if tab has
// navigated away and not just scrolled to a fragment.
- GURL url = web_contents->GetLastCommittedURL();
- if (!OfflinePageUtils::EqualsIgnoringFragment(url, original_url))
+ GURL current_url = web_contents->GetLastCommittedURL();
+ if (!OfflinePageUtils::EqualsIgnoringFragment(current_url, url))
return;
offline_pages::ClientId client_id;
@@ -116,9 +117,14 @@ void SavePageIfNotNavigatedAway(const GURL& original_url,
offline_pages::RequestCoordinatorFactory::GetForBrowserContext(
web_contents->GetBrowserContext());
if (request_coordinator) {
- request_id = request_coordinator->SavePageLater(
- url, client_id, true,
- RequestCoordinator::RequestAvailability::DISABLED_FOR_OFFLINER);
+ offline_pages::RequestCoordinator::SavePageLaterParams params;
+ params.url = current_url;
+ params.client_id = client_id;
+ params.user_requested = true;
+ params.availability =
+ RequestCoordinator::RequestAvailability::DISABLED_FOR_OFFLINER;
+ params.original_url = original_url;
+ request_id = request_coordinator->SavePageLater(params);
} else {
DVLOG(1) << "SavePageIfNotNavigatedAway has no valid coordinator.";
}
@@ -149,6 +155,7 @@ void SavePageIfNotNavigatedAway(const GURL& original_url,
}
void RequestQueueDuplicateCheckDone(
+ const GURL& url,
const GURL& original_url,
const ScopedJavaGlobalRef<jobject>& j_tab_ref,
bool has_duplicates,
@@ -174,10 +181,11 @@ void RequestQueueDuplicateCheckDone(
return;
}
- SavePageIfNotNavigatedAway(original_url, j_tab_ref);
+ SavePageIfNotNavigatedAway(url, original_url, j_tab_ref);
}
-void ModelDuplicateCheckDone(const GURL& original_url,
+void ModelDuplicateCheckDone(const GURL& url,
+ const GURL& original_url,
const ScopedJavaGlobalRef<jobject>& j_tab_ref,
bool has_duplicates,
const base::Time& latest_saved_time) {
@@ -197,16 +205,16 @@ void ModelDuplicateCheckDone(const GURL& original_url,
base::TimeDelta::FromDays(7).InSeconds(), 50);
OfflinePageInfoBarDelegate::Create(
- base::Bind(&SavePageIfNotNavigatedAway, original_url, j_tab_ref),
- original_url, web_contents);
+ base::Bind(&SavePageIfNotNavigatedAway, url, original_url, j_tab_ref),
+ url, web_contents);
return;
}
OfflinePageUtils::CheckExistenceOfRequestsWithURL(
Profile::FromBrowserContext(web_contents->GetBrowserContext())
->GetOriginalProfile(),
- kDownloadNamespace, original_url,
- base::Bind(&RequestQueueDuplicateCheckDone, original_url, j_tab_ref));
+ kDownloadNamespace, url, base::Bind(&RequestQueueDuplicateCheckDone, url,
+ original_url, j_tab_ref));
}
void ToJavaOfflinePageDownloadItemList(
@@ -375,12 +383,15 @@ void OfflinePageDownloadBridge::StartDownload(
return;
GURL url = web_contents->GetLastCommittedURL();
+ GURL original_url =
+ offline_pages::OfflinePageUtils::GetOriginalURLFromWebContents(
+ web_contents);
ScopedJavaGlobalRef<jobject> j_tab_ref(env, j_tab);
OfflinePageUtils::CheckExistenceOfPagesWithURL(
tab->GetProfile()->GetOriginalProfile(), kDownloadNamespace, url,
- base::Bind(&ModelDuplicateCheckDone, url, j_tab_ref));
+ base::Bind(&ModelDuplicateCheckDone, url, original_url, j_tab_ref));
}
void OfflinePageDownloadBridge::CancelDownload(

Powered by Google App Engine
This is Rietveld 408576698