OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_ANDROID_LOGO_BRIDGE_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_LOGO_BRIDGE_H_ |
6 #define CHROME_BROWSER_ANDROID_LOGO_BRIDGE_H_ | 6 #define CHROME_BROWSER_ANDROID_LOGO_BRIDGE_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
| 10 #include "base/android/scoped_java_ref.h" |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "net/url_request/url_fetcher_delegate.h" |
12 | 14 |
13 class LogoService; | 15 class LogoService; |
14 | 16 |
| 17 namespace net { |
| 18 class URLFetcher; |
| 19 class URLRequestContextGetter; |
| 20 } |
| 21 |
15 // The C++ counterpart to LogoBridge.java. Enables Java code to access the | 22 // The C++ counterpart to LogoBridge.java. Enables Java code to access the |
16 // default search provider's logo. | 23 // default search provider's logo. |
17 class LogoBridge { | 24 class LogoBridge : public net::URLFetcherDelegate { |
18 public: | 25 public: |
19 explicit LogoBridge(jobject j_profile); | 26 explicit LogoBridge(jobject j_profile); |
20 void Destroy(JNIEnv* env, jobject obj); | 27 void Destroy(JNIEnv* env, jobject obj); |
21 void GetCurrentLogo(JNIEnv* env, jobject obj, jobject j_logo_observer); | 28 void GetCurrentLogo(JNIEnv* env, jobject obj, jobject j_logo_observer); |
22 | 29 |
| 30 void GetAnimatedLogo(JNIEnv* env, |
| 31 jobject obj, |
| 32 jobject j_callback, |
| 33 jstring j_url); |
| 34 |
| 35 // net::URLFetcherDelegate: |
| 36 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 37 |
23 private: | 38 private: |
24 ~LogoBridge(); | 39 ~LogoBridge() override; |
| 40 |
| 41 // Clears and resets the URLFetcher for animated logo. |
| 42 void ClearFetcher(); |
25 | 43 |
26 LogoService* logo_service_; | 44 LogoService* logo_service_; |
| 45 |
| 46 // The URLFetcher currently fetching the animated logo. NULL when not |
| 47 // fetching. |
| 48 scoped_ptr<net::URLFetcher> fetcher_; |
| 49 |
| 50 // The URLRequestContextGetter used to download the animated logo. |
| 51 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
| 52 |
| 53 base::android::ScopedJavaGlobalRef<jobject> j_callback_; |
| 54 |
27 base::WeakPtrFactory<LogoBridge> weak_ptr_factory_; | 55 base::WeakPtrFactory<LogoBridge> weak_ptr_factory_; |
28 | 56 |
29 DISALLOW_COPY_AND_ASSIGN(LogoBridge); | 57 DISALLOW_COPY_AND_ASSIGN(LogoBridge); |
30 }; | 58 }; |
31 | 59 |
32 bool RegisterLogoBridge(JNIEnv* env); | 60 bool RegisterLogoBridge(JNIEnv* env); |
33 | 61 |
34 #endif // CHROME_BROWSER_ANDROID_LOGO_BRIDGE_H_ | 62 #endif // CHROME_BROWSER_ANDROID_LOGO_BRIDGE_H_ |
OLD | NEW |