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 <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/android/scoped_java_ref.h" | 12 #include "base/android/scoped_java_ref.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/optional.h" | 15 #include "base/optional.h" |
16 #include "base/scoped_observer.h" | 16 #include "base/scoped_observer.h" |
17 #include "components/doodle/doodle_service.h" | 17 #include "components/doodle/doodle_service.h" |
18 | 18 |
19 class LogoService; | 19 class LogoService; |
20 | 20 |
21 namespace doodle { | 21 namespace doodle { |
22 class DoodleService; | 22 class DoodleService; |
23 } // namespace doodle | 23 } // namespace doodle |
24 | 24 |
25 namespace gfx { | 25 namespace gfx { |
26 class Image; | 26 class Image; |
27 } // namespace gfx | 27 } // namespace gfx |
28 | 28 |
29 namespace image_fetcher { | |
30 class ImageFetcher; | |
31 struct RequestMetadata; | |
32 } // namespace image_fetcher | |
33 | |
34 // The C++ counterpart to LogoBridge.java. Enables Java code to access the | 29 // The C++ counterpart to LogoBridge.java. Enables Java code to access the |
35 // default search provider's logo. | 30 // default search provider's logo. |
36 class LogoBridge : public doodle::DoodleService::Observer { | 31 class LogoBridge : public doodle::DoodleService::Observer { |
37 public: | 32 public: |
38 explicit LogoBridge(jobject j_profile); | 33 explicit LogoBridge(jobject j_profile); |
39 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 34 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
40 | 35 |
41 // TODO(treib): Double-check the observer contract (esp. for LogoTracker). | 36 // TODO(treib): Double-check the observer contract (esp. for LogoTracker). |
42 // Gets the current non-animated logo (downloading it if necessary) and passes | 37 // Gets the current non-animated logo (downloading it if necessary) and passes |
43 // it to the observer. | 38 // it to the observer. |
(...skipping 25 matching lines...) Expand all Loading... |
69 void OnDoodleConfigUpdated( | 64 void OnDoodleConfigUpdated( |
70 const base::Optional<doodle::DoodleConfig>& maybe_doodle_config) override; | 65 const base::Optional<doodle::DoodleConfig>& maybe_doodle_config) override; |
71 | 66 |
72 void NotifyNoLogoAvailable(bool from_cache); | 67 void NotifyNoLogoAvailable(bool from_cache); |
73 void FetchDoodleImage(const doodle::DoodleConfig& doodle_config, | 68 void FetchDoodleImage(const doodle::DoodleConfig& doodle_config, |
74 bool from_cache); | 69 bool from_cache); |
75 void DoodleImageFetched(bool config_from_cache, | 70 void DoodleImageFetched(bool config_from_cache, |
76 const GURL& on_click_url, | 71 const GURL& on_click_url, |
77 const std::string& alt_text, | 72 const std::string& alt_text, |
78 const GURL& animated_image_url, | 73 const GURL& animated_image_url, |
79 const std::string& image_fetch_id, | 74 const gfx::Image& image); |
80 const gfx::Image& image, | |
81 const image_fetcher::RequestMetadata& metadata); | |
82 | 75 |
83 // Only valid if UseNewDoodleApi is disabled. | 76 // Only valid if UseNewDoodleApi is disabled. |
84 LogoService* logo_service_; | 77 LogoService* logo_service_; |
85 | 78 |
86 // Only valid if UseNewDoodleApi is enabled. | 79 // Only valid if UseNewDoodleApi is enabled. |
87 doodle::DoodleService* doodle_service_; | 80 doodle::DoodleService* doodle_service_; |
88 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher_; | |
89 base::android::ScopedJavaGlobalRef<jobject> j_logo_observer_; | 81 base::android::ScopedJavaGlobalRef<jobject> j_logo_observer_; |
90 ScopedObserver<doodle::DoodleService, doodle::DoodleService::Observer> | 82 ScopedObserver<doodle::DoodleService, doodle::DoodleService::Observer> |
91 doodle_observer_; | 83 doodle_observer_; |
92 | 84 |
93 std::unique_ptr<AnimatedLogoFetcher> animated_logo_fetcher_; | 85 std::unique_ptr<AnimatedLogoFetcher> animated_logo_fetcher_; |
94 | 86 |
95 base::WeakPtrFactory<LogoBridge> weak_ptr_factory_; | 87 base::WeakPtrFactory<LogoBridge> weak_ptr_factory_; |
96 | 88 |
97 DISALLOW_COPY_AND_ASSIGN(LogoBridge); | 89 DISALLOW_COPY_AND_ASSIGN(LogoBridge); |
98 }; | 90 }; |
99 | 91 |
100 bool RegisterLogoBridge(JNIEnv* env); | 92 bool RegisterLogoBridge(JNIEnv* env); |
101 | 93 |
102 #endif // CHROME_BROWSER_ANDROID_LOGO_BRIDGE_H_ | 94 #endif // CHROME_BROWSER_ANDROID_LOGO_BRIDGE_H_ |
OLD | NEW |