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

Side by Side Diff: chrome/browser/android/download/download_manager_service.cc

Issue 2258553003: [Downloads] Handle externally deleted items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dfalcantara@ review 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/android/download/download_manager_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/download/download_manager_service.h" 5 #include "chrome/browser/android/download/download_manager_service.h"
6 6
7 #include "base/android/jni_string.h" 7 #include "base/android/jni_string.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 if (!ShouldShowDownloadItem(item)) 143 if (!ShouldShowDownloadItem(item))
144 continue; 144 continue;
145 145
146 Java_DownloadManagerService_addDownloadItemToList( 146 Java_DownloadManagerService_addDownloadItemToList(
147 env, java_ref_, j_download_item_list, 147 env, java_ref_, j_download_item_list,
148 ConvertUTF8ToJavaString(env, item->GetGuid()), 148 ConvertUTF8ToJavaString(env, item->GetGuid()),
149 ConvertUTF8ToJavaString(env, item->GetFileNameToReportUser().value()), 149 ConvertUTF8ToJavaString(env, item->GetFileNameToReportUser().value()),
150 ConvertUTF8ToJavaString(env, item->GetTargetFilePath().value()), 150 ConvertUTF8ToJavaString(env, item->GetTargetFilePath().value()),
151 ConvertUTF8ToJavaString(env, item->GetTabUrl().spec()), 151 ConvertUTF8ToJavaString(env, item->GetTabUrl().spec()),
152 ConvertUTF8ToJavaString(env, item->GetMimeType()), 152 ConvertUTF8ToJavaString(env, item->GetMimeType()),
153 item->GetStartTime().ToJavaTime(), item->GetTotalBytes()); 153 item->GetStartTime().ToJavaTime(), item->GetTotalBytes(),
154 item->GetFileExternallyRemoved());
154 } 155 }
155 156
156 Java_DownloadManagerService_onAllDownloadsRetrieved( 157 Java_DownloadManagerService_onAllDownloadsRetrieved(
157 env, java_ref_, j_download_item_list, is_off_the_record); 158 env, java_ref_, j_download_item_list, is_off_the_record);
158 } 159 }
159 160
161 void DownloadManagerService::CheckForExternallyRemovedDownloads(
162 JNIEnv* env,
163 const JavaParamRef<jobject>& obj,
164 bool is_off_the_record) {
165 content::DownloadManager* manager = GetDownloadManager(is_off_the_record);
166 if (!manager)
167 return;
168 manager->CheckForHistoryFilesRemoval();
169 }
160 170
161 void DownloadManagerService::CancelDownload( 171 void DownloadManagerService::CancelDownload(
162 JNIEnv* env, 172 JNIEnv* env,
163 jobject obj, 173 jobject obj,
164 const JavaParamRef<jstring>& jdownload_guid, 174 const JavaParamRef<jstring>& jdownload_guid,
165 bool is_off_the_record, 175 bool is_off_the_record,
166 bool is_notification_dismissed) { 176 bool is_notification_dismissed) {
167 std::string download_guid = ConvertJavaStringToUTF8(env, jdownload_guid); 177 std::string download_guid = ConvertJavaStringToUTF8(env, jdownload_guid);
168 DownloadController::RecordDownloadCancelReason( 178 DownloadController::RecordDownloadCancelReason(
169 is_notification_dismissed ? 179 is_notification_dismissed ?
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 java_ref_.obj(), 238 java_ref_.obj(),
229 ConvertUTF8ToJavaString(env, item->GetGuid()).obj(), 239 ConvertUTF8ToJavaString(env, item->GetGuid()).obj(),
230 ConvertUTF8ToJavaString( 240 ConvertUTF8ToJavaString(
231 env, item->GetFileNameToReportUser().value()).obj(), 241 env, item->GetFileNameToReportUser().value()).obj(),
232 ConvertUTF8ToJavaString( 242 ConvertUTF8ToJavaString(
233 env, item->GetTargetFilePath().value()).obj(), 243 env, item->GetTargetFilePath().value()).obj(),
234 ConvertUTF8ToJavaString(env, item->GetTabUrl().spec()).obj(), 244 ConvertUTF8ToJavaString(env, item->GetTabUrl().spec()).obj(),
235 ConvertUTF8ToJavaString(env, item->GetMimeType()).obj(), 245 ConvertUTF8ToJavaString(env, item->GetMimeType()).obj(),
236 item->GetStartTime().ToJavaTime(), 246 item->GetStartTime().ToJavaTime(),
237 item->GetTotalBytes(), 247 item->GetTotalBytes(),
238 item->GetBrowserContext()->IsOffTheRecord()); 248 item->GetBrowserContext()->IsOffTheRecord(),
249 item->GetFileExternallyRemoved());
239 } 250 }
240 251
241 void DownloadManagerService::OnDownloadRemoved( 252 void DownloadManagerService::OnDownloadRemoved(
242 content::DownloadManager* manager, content::DownloadItem* item) { 253 content::DownloadManager* manager, content::DownloadItem* item) {
243 if (java_ref_.is_null()) 254 if (java_ref_.is_null())
244 return; 255 return;
245 256
246 JNIEnv* env = base::android::AttachCurrentThread(); 257 JNIEnv* env = base::android::AttachCurrentThread();
247 Java_DownloadManagerService_onDownloadItemRemoved( 258 Java_DownloadManagerService_onDownloadItemRemoved(
248 env, 259 env,
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 resume_callback_for_testing_.Run(false); 371 resume_callback_for_testing_.Run(false);
361 } 372 }
362 373
363 content::DownloadManager* DownloadManagerService::GetDownloadManager( 374 content::DownloadManager* DownloadManagerService::GetDownloadManager(
364 bool is_off_the_record) { 375 bool is_off_the_record) {
365 Profile* profile = ProfileManager::GetActiveUserProfile(); 376 Profile* profile = ProfileManager::GetActiveUserProfile();
366 if (is_off_the_record) 377 if (is_off_the_record)
367 profile = profile->GetOffTheRecordProfile(); 378 profile = profile->GetOffTheRecordProfile();
368 return content::BrowserContext::GetDownloadManager(profile); 379 return content::BrowserContext::GetDownloadManager(profile);
369 } 380 }
OLDNEW
« no previous file with comments | « chrome/browser/android/download/download_manager_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698