Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: chrome/browser/android/logo_bridge.h

Issue 2833473002: Record NTP.LogoShownTime for timely refreshs only (Closed)
Patch Set: Remove skippedCallback and call onLogoAvailable more explicitly Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
(...skipping 21 matching lines...) Expand all
32 } // namespace image_fetcher 32 } // namespace image_fetcher
33 33
34 // The C++ counterpart to LogoBridge.java. Enables Java code to access the 34 // The C++ counterpart to LogoBridge.java. Enables Java code to access the
35 // default search provider's logo. 35 // default search provider's logo.
36 class LogoBridge : public doodle::DoodleService::Observer { 36 class LogoBridge : public doodle::DoodleService::Observer {
37 public: 37 public:
38 explicit LogoBridge(jobject j_profile); 38 explicit LogoBridge(jobject j_profile);
39 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); 39 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
40 40
41 // Gets the current non-animated logo (downloading it if necessary) and passes 41 // Gets the current non-animated logo (downloading it if necessary) and passes
42 // it to the observer. 42 // it to the observer.
tschumann 2017/04/27 10:59:32 Can you better describe the details of this method
Marc Treib 2017/04/27 11:15:50 Indeed, this needs a better comment. Since it's or
fhorschig 2017/04/27 11:49:21 Added that and a few lines.
43 void GetCurrentLogo( 43 void GetCurrentLogo(
44 JNIEnv* env, 44 JNIEnv* env,
45 const base::android::JavaParamRef<jobject>& obj, 45 const base::android::JavaParamRef<jobject>& obj,
46 const base::android::JavaParamRef<jobject>& j_logo_observer); 46 const base::android::JavaParamRef<jobject>& j_logo_observer);
47 47
48 // Downloads the animated logo from the given URL and returns it to the 48 // Downloads the animated logo from the given URL and returns it to the
49 // callback. Does not support multiple concurrent requests: A second request 49 // callback. Does not support multiple concurrent requests: A second request
50 // for the same URL will be ignored; a request for a different URL will cancel 50 // for the same URL will be ignored; a request for a different URL will cancel
51 // any ongoing request. If downloading fails, the callback is not called. 51 // any ongoing request. If downloading fails, the callback is not called.
52 void GetAnimatedLogo(JNIEnv* env, 52 void GetAnimatedLogo(JNIEnv* env,
53 const base::android::JavaParamRef<jobject>& obj, 53 const base::android::JavaParamRef<jobject>& obj,
54 const base::android::JavaParamRef<jobject>& j_callback, 54 const base::android::JavaParamRef<jobject>& j_callback,
55 const base::android::JavaParamRef<jstring>& j_url); 55 const base::android::JavaParamRef<jstring>& j_url);
56 56
57 private: 57 private:
58 class AnimatedLogoFetcher; 58 class AnimatedLogoFetcher;
59 59
60 virtual ~LogoBridge(); 60 virtual ~LogoBridge();
61 61
62 // doodle::DoodleService::Observer implementation. 62 // doodle::DoodleService::Observer implementation.
63 void OnDoodleConfigUpdated( 63 void OnDoodleConfigUpdated(
64 const base::Optional<doodle::DoodleConfig>& maybe_doodle_config) override; 64 const base::Optional<doodle::DoodleConfig>& maybe_doodle_config) override;
65 65
66 void DoodleConfigReceived( 66 void NotifyNoLogoAvailable(bool from_cache);
67 const base::Optional<doodle::DoodleConfig>& maybe_doodle_config, 67 void FetchDoodleImage(const doodle::DoodleConfig& doodle_config);
68 bool from_cache);
69
70 void DoodleImageFetched(bool config_from_cache, 68 void DoodleImageFetched(bool config_from_cache,
71 const GURL& on_click_url, 69 const GURL& on_click_url,
72 const std::string& alt_text, 70 const std::string& alt_text,
73 const GURL& animated_image_url, 71 const GURL& animated_image_url,
74 const std::string& image_fetch_id, 72 const std::string& image_fetch_id,
75 const gfx::Image& image, 73 const gfx::Image& image,
76 const image_fetcher::RequestMetadata& metadata); 74 const image_fetcher::RequestMetadata& metadata);
77 75
78 // Only valid if UseNewDoodleApi is disabled. 76 // Only valid if UseNewDoodleApi is disabled.
79 LogoService* logo_service_; 77 LogoService* logo_service_;
80 78
81 // Only valid if UseNewDoodleApi is enabled. 79 // Only valid if UseNewDoodleApi is enabled.
82 doodle::DoodleService* doodle_service_; 80 doodle::DoodleService* doodle_service_;
83 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher_; 81 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher_;
84 base::android::ScopedJavaGlobalRef<jobject> j_logo_observer_; 82 base::android::ScopedJavaGlobalRef<jobject> j_logo_observer_;
85 ScopedObserver<doodle::DoodleService, doodle::DoodleService::Observer> 83 ScopedObserver<doodle::DoodleService, doodle::DoodleService::Observer>
86 doodle_observer_; 84 doodle_observer_;
87 85
88 std::unique_ptr<AnimatedLogoFetcher> animated_logo_fetcher_; 86 std::unique_ptr<AnimatedLogoFetcher> animated_logo_fetcher_;
89 87
90 base::WeakPtrFactory<LogoBridge> weak_ptr_factory_; 88 base::WeakPtrFactory<LogoBridge> weak_ptr_factory_;
91 89
92 DISALLOW_COPY_AND_ASSIGN(LogoBridge); 90 DISALLOW_COPY_AND_ASSIGN(LogoBridge);
93 }; 91 };
94 92
95 bool RegisterLogoBridge(JNIEnv* env); 93 bool RegisterLogoBridge(JNIEnv* env);
96 94
97 #endif // CHROME_BROWSER_ANDROID_LOGO_BRIDGE_H_ 95 #endif // CHROME_BROWSER_ANDROID_LOGO_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698