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

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

Issue 2833473002: Record NTP.LogoShownTime for timely refreshs only (Closed)
Patch Set: Fix compile errors and comments 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 20 matching lines...) Expand all
31 struct RequestMetadata; 31 struct RequestMetadata;
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 // TODO(treib): Double-check the observer contract (esp. for LogoTracker).
41 // Gets the current non-animated logo (downloading it if necessary) and passes 42 // Gets the current non-animated logo (downloading it if necessary) and passes
42 // it to the observer. 43 // it to the observer.
44 // The observer's |onLogoAvailable| will be called at least once:
45 // a) A cached doodle is available.
46 // b) A new doodle is available. This happens independent from a) or c).
47 // c) If no cached doodle is available and no doodle can be expected soon, it
48 // is called with an empty object.
Marc Treib 2017/04/27 11:56:09 s/empty/null/ ?
fhorschig 2017/04/27 12:12:20 Done.
43 void GetCurrentLogo( 49 void GetCurrentLogo(
44 JNIEnv* env, 50 JNIEnv* env,
45 const base::android::JavaParamRef<jobject>& obj, 51 const base::android::JavaParamRef<jobject>& obj,
46 const base::android::JavaParamRef<jobject>& j_logo_observer); 52 const base::android::JavaParamRef<jobject>& j_logo_observer);
47 53
48 // Downloads the animated logo from the given URL and returns it to the 54 // Downloads the animated logo from the given URL and returns it to the
49 // callback. Does not support multiple concurrent requests: A second request 55 // 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 56 // 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. 57 // any ongoing request. If downloading fails, the callback is not called.
52 void GetAnimatedLogo(JNIEnv* env, 58 void GetAnimatedLogo(JNIEnv* env,
53 const base::android::JavaParamRef<jobject>& obj, 59 const base::android::JavaParamRef<jobject>& obj,
54 const base::android::JavaParamRef<jobject>& j_callback, 60 const base::android::JavaParamRef<jobject>& j_callback,
55 const base::android::JavaParamRef<jstring>& j_url); 61 const base::android::JavaParamRef<jstring>& j_url);
56 62
57 private: 63 private:
58 class AnimatedLogoFetcher; 64 class AnimatedLogoFetcher;
59 65
60 virtual ~LogoBridge(); 66 virtual ~LogoBridge();
61 67
62 // doodle::DoodleService::Observer implementation. 68 // doodle::DoodleService::Observer implementation.
63 void OnDoodleConfigUpdated( 69 void OnDoodleConfigUpdated(
64 const base::Optional<doodle::DoodleConfig>& maybe_doodle_config) override; 70 const base::Optional<doodle::DoodleConfig>& maybe_doodle_config) override;
65 71
66 void DoodleConfigReceived( 72 void NotifyNoLogoAvailable(bool from_cache);
67 const base::Optional<doodle::DoodleConfig>& maybe_doodle_config, 73 void FetchDoodleImage(const doodle::DoodleConfig& doodle_config,
68 bool from_cache); 74 bool from_cache);
69
70 void DoodleImageFetched(bool config_from_cache, 75 void DoodleImageFetched(bool config_from_cache,
71 const GURL& on_click_url, 76 const GURL& on_click_url,
72 const std::string& alt_text, 77 const std::string& alt_text,
73 const GURL& animated_image_url, 78 const GURL& animated_image_url,
74 const std::string& image_fetch_id, 79 const std::string& image_fetch_id,
75 const gfx::Image& image, 80 const gfx::Image& image,
76 const image_fetcher::RequestMetadata& metadata); 81 const image_fetcher::RequestMetadata& metadata);
77 82
78 // Only valid if UseNewDoodleApi is disabled. 83 // Only valid if UseNewDoodleApi is disabled.
79 LogoService* logo_service_; 84 LogoService* logo_service_;
80 85
81 // Only valid if UseNewDoodleApi is enabled. 86 // Only valid if UseNewDoodleApi is enabled.
82 doodle::DoodleService* doodle_service_; 87 doodle::DoodleService* doodle_service_;
83 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher_; 88 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher_;
84 base::android::ScopedJavaGlobalRef<jobject> j_logo_observer_; 89 base::android::ScopedJavaGlobalRef<jobject> j_logo_observer_;
85 ScopedObserver<doodle::DoodleService, doodle::DoodleService::Observer> 90 ScopedObserver<doodle::DoodleService, doodle::DoodleService::Observer>
86 doodle_observer_; 91 doodle_observer_;
87 92
88 std::unique_ptr<AnimatedLogoFetcher> animated_logo_fetcher_; 93 std::unique_ptr<AnimatedLogoFetcher> animated_logo_fetcher_;
89 94
90 base::WeakPtrFactory<LogoBridge> weak_ptr_factory_; 95 base::WeakPtrFactory<LogoBridge> weak_ptr_factory_;
91 96
92 DISALLOW_COPY_AND_ASSIGN(LogoBridge); 97 DISALLOW_COPY_AND_ASSIGN(LogoBridge);
93 }; 98 };
94 99
95 bool RegisterLogoBridge(JNIEnv* env); 100 bool RegisterLogoBridge(JNIEnv* env);
96 101
97 #endif // CHROME_BROWSER_ANDROID_LOGO_BRIDGE_H_ 102 #endif // CHROME_BROWSER_ANDROID_LOGO_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698