| OLD | NEW |
| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 jobject obj, | 142 jobject obj, |
| 143 const JavaParamRef<jstring>& jdownload_guid, | 143 const JavaParamRef<jstring>& jdownload_guid, |
| 144 bool is_off_the_record) { | 144 bool is_off_the_record) { |
| 145 std::string download_guid = ConvertJavaStringToUTF8(env, jdownload_guid); | 145 std::string download_guid = ConvertJavaStringToUTF8(env, jdownload_guid); |
| 146 if (is_history_query_complete_ || is_off_the_record) | 146 if (is_history_query_complete_ || is_off_the_record) |
| 147 RemoveDownloadInternal(download_guid, is_off_the_record); | 147 RemoveDownloadInternal(download_guid, is_off_the_record); |
| 148 else | 148 else |
| 149 EnqueueDownloadAction(download_guid, REMOVE); | 149 EnqueueDownloadAction(download_guid, REMOVE); |
| 150 } | 150 } |
| 151 | 151 |
| 152 bool DownloadManagerService::IsDownloadOpenableInBrowser( | |
| 153 JNIEnv* env, | |
| 154 jobject obj, | |
| 155 const JavaParamRef<jstring>& jdownload_guid, | |
| 156 bool is_off_the_record) { | |
| 157 std::string download_guid = ConvertJavaStringToUTF8(env, jdownload_guid); | |
| 158 content::DownloadManager* manager = GetDownloadManager(is_off_the_record); | |
| 159 if (!manager) | |
| 160 return false; | |
| 161 | |
| 162 content::DownloadItem* item = manager->GetDownloadByGuid(download_guid); | |
| 163 if (!item) | |
| 164 return false; | |
| 165 | |
| 166 return mime_util::IsSupportedMimeType(item->GetMimeType()); | |
| 167 } | |
| 168 | |
| 169 void DownloadManagerService::GetAllDownloads(JNIEnv* env, | 152 void DownloadManagerService::GetAllDownloads(JNIEnv* env, |
| 170 const JavaParamRef<jobject>& obj, | 153 const JavaParamRef<jobject>& obj, |
| 171 bool is_off_the_record) { | 154 bool is_off_the_record) { |
| 172 if (is_history_query_complete_) | 155 if (is_history_query_complete_) |
| 173 GetAllDownloadsInternal(is_off_the_record); | 156 GetAllDownloadsInternal(is_off_the_record); |
| 174 else if (is_off_the_record) | 157 else if (is_off_the_record) |
| 175 pending_get_downloads_actions_ |= OFF_THE_RECORD; | 158 pending_get_downloads_actions_ |= OFF_THE_RECORD; |
| 176 else | 159 else |
| 177 pending_get_downloads_actions_ |= REGULAR; | 160 pending_get_downloads_actions_ |= REGULAR; |
| 178 } | 161 } |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 } | 428 } |
| 446 | 429 |
| 447 // static | 430 // static |
| 448 jboolean IsSupportedMimeType( | 431 jboolean IsSupportedMimeType( |
| 449 JNIEnv* env, | 432 JNIEnv* env, |
| 450 const JavaParamRef<jclass>& clazz, | 433 const JavaParamRef<jclass>& clazz, |
| 451 const JavaParamRef<jstring>& jmime_type) { | 434 const JavaParamRef<jstring>& jmime_type) { |
| 452 std::string mime_type = ConvertJavaStringToUTF8(env, jmime_type); | 435 std::string mime_type = ConvertJavaStringToUTF8(env, jmime_type); |
| 453 return mime_util::IsSupportedMimeType(mime_type); | 436 return mime_util::IsSupportedMimeType(mime_type); |
| 454 } | 437 } |
| OLD | NEW |