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

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

Issue 2478583004: implementation for new duplicate download UI (Closed)
Patch Set: do null check on webcontents Created 4 years, 1 month 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 582ad34b98cbf49572f97938ec85041ceab03f25..361140c33515fe138e1327cb7c9a07918536b62a 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
@@ -57,20 +57,6 @@ content::WebContents* GetWebContentsFromJavaTab(
return tab->web_contents();
}
-// TODO(dewittj): Move to Download UI Adapter.
-OfflinePageModel* GetOfflinePageModelFromJavaTab(
- const ScopedJavaGlobalRef<jobject>& j_tab_ref) {
- content::WebContents* web_contents = GetWebContentsFromJavaTab(j_tab_ref);
- if (!web_contents)
- return nullptr;
-
- Profile* profile =
- Profile::FromBrowserContext(web_contents->GetBrowserContext())
- ->GetOriginalProfile();
-
- return OfflinePageModelFactory::GetForBrowserContext(profile);
-}
-
void SavePageIfNotNavigatedAway(const GURL& original_url,
const ScopedJavaGlobalRef<jobject>& j_tab_ref) {
content::WebContents* web_contents = GetWebContentsFromJavaTab(j_tab_ref);
@@ -123,52 +109,6 @@ void SavePageIfNotNavigatedAway(const GURL& original_url,
notification_bridge.ShowDownloadingToast();
}
-void OnDeletePagesForInfoBar(const GURL& original_url,
- const ScopedJavaGlobalRef<jobject>& j_tab_ref,
- DeletePageResult result) {
- SavePageIfNotNavigatedAway(original_url, j_tab_ref);
-}
-
-void DeletePagesForOverwrite(const GURL& original_url,
- const ScopedJavaGlobalRef<jobject>& j_tab_ref,
- const MultipleOfflinePageItemResult& pages) {
- OfflinePageModel* model = GetOfflinePageModelFromJavaTab(j_tab_ref);
- if (!model)
- return;
-
- std::vector<int64_t> offline_ids;
- for (auto& page : pages) {
- if (page.client_id.name_space == kDownloadNamespace ||
- page.client_id.name_space == kAsyncNamespace) {
- offline_ids.emplace_back(page.offline_id);
- }
- }
-
- model->DeletePagesByOfflineId(
- offline_ids, base::Bind(
- &OnDeletePagesForInfoBar, original_url, j_tab_ref));
-}
-
-void OnInfoBarAction(const GURL& original_url,
- const ScopedJavaGlobalRef<jobject>& j_tab_ref,
- OfflinePageInfoBarDelegate::Action action) {
- switch (action) {
- case OfflinePageInfoBarDelegate::Action::CREATE_NEW:
- SavePageIfNotNavigatedAway(original_url, j_tab_ref);
- break;
- case OfflinePageInfoBarDelegate::Action::OVERWRITE:
- OfflinePageModel* offline_page_model =
- GetOfflinePageModelFromJavaTab(j_tab_ref);
- if (!offline_page_model)
- return;
-
- offline_page_model->GetPagesByOnlineURL(
- original_url,
- base::Bind(&DeletePagesForOverwrite, original_url, j_tab_ref));
- break;
- }
-}
-
void RequestQueueDuplicateCheckDone(
const GURL& original_url,
const ScopedJavaGlobalRef<jobject>& j_tab_ref,
@@ -189,7 +129,6 @@ void RequestQueueDuplicateCheckDone(
void ModelDuplicateCheckDone(const GURL& original_url,
const ScopedJavaGlobalRef<jobject>& j_tab_ref,
- const std::string& downloads_label,
bool has_duplicates) {
content::WebContents* web_contents = GetWebContentsFromJavaTab(j_tab_ref);
if (!web_contents)
@@ -197,7 +136,7 @@ void ModelDuplicateCheckDone(const GURL& original_url,
if (has_duplicates) {
OfflinePageInfoBarDelegate::Create(
- base::Bind(&OnInfoBarAction, original_url, j_tab_ref), downloads_label,
+ base::Bind(&SavePageIfNotNavigatedAway, original_url, j_tab_ref),
original_url, web_contents);
return;
}
@@ -363,9 +302,7 @@ jlong OfflinePageDownloadBridge::GetOfflineIdByGuid(
void OfflinePageDownloadBridge::StartDownload(
JNIEnv* env,
const JavaParamRef<jobject>& obj,
- const JavaParamRef<jobject>& j_tab,
- const JavaParamRef<jstring>& j_downloads_label) {
- std::string downloads_label = ConvertJavaStringToUTF8(env, j_downloads_label);
+ const JavaParamRef<jobject>& j_tab) {
TabAndroid* tab = TabAndroid::GetNativeTab(env, j_tab);
if (!tab)
return;
@@ -380,7 +317,7 @@ void OfflinePageDownloadBridge::StartDownload(
OfflinePageUtils::CheckExistenceOfPagesWithURL(
tab->GetProfile()->GetOriginalProfile(), kDownloadNamespace, url,
- base::Bind(&ModelDuplicateCheckDone, url, j_tab_ref, downloads_label));
+ base::Bind(&ModelDuplicateCheckDone, url, j_tab_ref));
}
void OfflinePageDownloadBridge::CancelDownload(

Powered by Google App Engine
This is Rietveld 408576698