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 jboolean GetAnimatedLogo(JNIEnv* env, | |
31 jobject obj, | |
newt (away)
2015/09/23 20:38:44
indentation
Ian Wen
2015/09/23 21:59:52
Done.
| |
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 logo. NULL when not fetching. | |
newt (away)
2015/09/23 20:38:44
s/logo/animated logo/
Ian Wen
2015/09/23 21:59:52
Done.
| |
47 scoped_ptr<net::URLFetcher> fetcher_; | |
48 | |
49 // The URLRequestContextGetter used for network requests. | |
newt (away)
2015/09/23 20:38:43
"... used to download the animated logo."
Ian Wen
2015/09/23 21:59:52
Done.
| |
50 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | |
51 | |
52 base::android::ScopedJavaGlobalRef<jobject> j_callback_; | |
53 | |
27 base::WeakPtrFactory<LogoBridge> weak_ptr_factory_; | 54 base::WeakPtrFactory<LogoBridge> weak_ptr_factory_; |
28 | 55 |
29 DISALLOW_COPY_AND_ASSIGN(LogoBridge); | 56 DISALLOW_COPY_AND_ASSIGN(LogoBridge); |
30 }; | 57 }; |
31 | 58 |
32 bool RegisterLogoBridge(JNIEnv* env); | 59 bool RegisterLogoBridge(JNIEnv* env); |
33 | 60 |
34 #endif // CHROME_BROWSER_ANDROID_LOGO_BRIDGE_H_ | 61 #endif // CHROME_BROWSER_ANDROID_LOGO_BRIDGE_H_ |
OLD | NEW |