OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_ANDROID_DOWNLOAD_UI_THUMBNAIL_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_ANDROID_DOWNLOAD_UI_THUMBNAIL_PROVIDER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/android/jni_android.h" |
| 11 #include "chrome/browser/image_decoder.h" |
| 12 |
| 13 // Kicks off asynchronous pipelines for creating thumbnails for local files. |
| 14 // The native-side ThumbnailProvider is owned by the Java-side and can be |
| 15 // safely destroyed while a request is being processed. |
| 16 class ThumbnailProvider { |
| 17 public: |
| 18 explicit ThumbnailProvider(const base::android::JavaParamRef<jobject>& jobj); |
| 19 |
| 20 // Destroys the ThumbnailProvider. Any currently running ImageRequest will |
| 21 // delete itself when it has completed. |
| 22 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& jobj); |
| 23 |
| 24 // Kicks off an asynchronous process to retrieve the thumbnail for the file |
| 25 // located at |file_path| with a max size of |icon_size| in each dimension. |
| 26 void RetrieveThumbnail(JNIEnv* env, |
| 27 const base::android::JavaParamRef<jobject>& jobj, |
| 28 jstring jfile_path, |
| 29 jint icon_size); |
| 30 |
| 31 // Called when the thumbnail is ready. |thumbnail| will be empty on failure. |
| 32 void OnThumbnailRetrieved(const std::string& file_path, |
| 33 const SkBitmap& thumbnail); |
| 34 |
| 35 // Registers the JNI bindings. |
| 36 static bool RegisterThumbnailProvider(JNIEnv* env); |
| 37 |
| 38 private: |
| 39 ~ThumbnailProvider(); |
| 40 |
| 41 base::android::ScopedJavaGlobalRef<jobject> java_delegate_; |
| 42 base::WeakPtrFactory<ThumbnailProvider> weak_factory_; |
| 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(ThumbnailProvider); |
| 45 }; |
| 46 |
| 47 #endif // CHROME_BROWSER_ANDROID_DOWNLOAD_UI_THUMBNAIL_PROVIDER_H_ |
OLD | NEW |