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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 73 } |
74 | 74 |
75 // static | 75 // static |
76 DownloadManagerService* DownloadManagerService::GetInstance() { | 76 DownloadManagerService* DownloadManagerService::GetInstance() { |
77 return base::Singleton<DownloadManagerService>::get(); | 77 return base::Singleton<DownloadManagerService>::get(); |
78 } | 78 } |
79 | 79 |
80 // static | 80 // static |
81 ScopedJavaLocalRef<jobject> DownloadManagerService::CreateJavaDownloadInfo( | 81 ScopedJavaLocalRef<jobject> DownloadManagerService::CreateJavaDownloadInfo( |
82 JNIEnv* env, content::DownloadItem* item) { | 82 JNIEnv* env, content::DownloadItem* item) { |
83 ui::PageTransition base_transition = | |
84 ui::PageTransitionStripQualifier(item->GetTransitionType()); | |
85 bool user_initiated = | 83 bool user_initiated = |
86 (item->GetTransitionType() & ui::PAGE_TRANSITION_FROM_ADDRESS_BAR) || | 84 (item->GetTransitionType() & ui::PAGE_TRANSITION_FROM_ADDRESS_BAR) || |
87 base_transition == ui::PAGE_TRANSITION_TYPED || | 85 PageTransitionCoreTypeIs(item->GetTransitionType(), |
88 base_transition == ui::PAGE_TRANSITION_AUTO_BOOKMARK || | 86 ui::PAGE_TRANSITION_TYPED) || |
89 base_transition == ui::PAGE_TRANSITION_GENERATED || | 87 PageTransitionCoreTypeIs(item->GetTransitionType(), |
90 base_transition == ui::PAGE_TRANSITION_RELOAD || | 88 ui::PAGE_TRANSITION_AUTO_BOOKMARK) || |
91 base_transition == ui::PAGE_TRANSITION_KEYWORD; | 89 PageTransitionCoreTypeIs(item->GetTransitionType(), |
| 90 ui::PAGE_TRANSITION_GENERATED) || |
| 91 PageTransitionCoreTypeIs(item->GetTransitionType(), |
| 92 ui::PAGE_TRANSITION_RELOAD) || |
| 93 PageTransitionCoreTypeIs(item->GetTransitionType(), |
| 94 ui::PAGE_TRANSITION_KEYWORD); |
92 bool has_user_gesture = item->HasUserGesture() || user_initiated; | 95 bool has_user_gesture = item->HasUserGesture() || user_initiated; |
93 | 96 |
94 base::TimeDelta time_delta; | 97 base::TimeDelta time_delta; |
95 item->TimeRemaining(&time_delta); | 98 item->TimeRemaining(&time_delta); |
96 std::string original_url = item->GetOriginalUrl().SchemeIs(url::kDataScheme) | 99 std::string original_url = item->GetOriginalUrl().SchemeIs(url::kDataScheme) |
97 ? std::string() : item->GetOriginalUrl().spec(); | 100 ? std::string() : item->GetOriginalUrl().spec(); |
98 return Java_DownloadInfo_createDownloadInfo( | 101 return Java_DownloadInfo_createDownloadInfo( |
99 env, | 102 env, |
100 ConvertUTF8ToJavaString(env, item->GetGuid()), | 103 ConvertUTF8ToJavaString(env, item->GetGuid()), |
101 ConvertUTF8ToJavaString(env, | 104 ConvertUTF8ToJavaString(env, |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 } | 444 } |
442 | 445 |
443 // static | 446 // static |
444 jboolean IsSupportedMimeType( | 447 jboolean IsSupportedMimeType( |
445 JNIEnv* env, | 448 JNIEnv* env, |
446 const JavaParamRef<jclass>& clazz, | 449 const JavaParamRef<jclass>& clazz, |
447 const JavaParamRef<jstring>& jmime_type) { | 450 const JavaParamRef<jstring>& jmime_type) { |
448 std::string mime_type = ConvertJavaStringToUTF8(env, jmime_type); | 451 std::string mime_type = ConvertJavaStringToUTF8(env, jmime_type); |
449 return mime_util::IsSupportedMimeType(mime_type); | 452 return mime_util::IsSupportedMimeType(mime_type); |
450 } | 453 } |
OLD | NEW |