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

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

Issue 2763033002: [Doodle] Add an about:flags entry for the new Doodle API (Closed)
Patch Set: histograms Created 3 years, 9 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
« no previous file with comments | « chrome/browser/android/chrome_feature_list.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/android/logo_bridge.h" 5 #include "chrome/browser/android/logo_bridge.h"
6 6
7 #include <jni.h> 7 #include <jni.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
11 #include "base/android/jni_array.h" 11 #include "base/android/jni_array.h"
12 #include "base/android/jni_string.h" 12 #include "base/android/jni_string.h"
13 #include "base/android/scoped_java_ref.h" 13 #include "base/android/scoped_java_ref.h"
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/feature_list.h" 15 #include "base/feature_list.h"
16 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
17 #include "chrome/browser/android/chrome_feature_list.h"
17 #include "chrome/browser/android/logo_service.h" 18 #include "chrome/browser/android/logo_service.h"
18 #include "chrome/browser/doodle/doodle_service_factory.h" 19 #include "chrome/browser/doodle/doodle_service_factory.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/profiles/profile_android.h" 21 #include "chrome/browser/profiles/profile_android.h"
21 #include "chrome/browser/search/suggestions/image_decoder_impl.h" 22 #include "chrome/browser/search/suggestions/image_decoder_impl.h"
22 #include "components/image_fetcher/image_fetcher_impl.h" 23 #include "components/image_fetcher/image_fetcher_impl.h"
23 #include "components/search_provider_logos/logo_tracker.h" 24 #include "components/search_provider_logos/logo_tracker.h"
24 #include "jni/LogoBridge_jni.h" 25 #include "jni/LogoBridge_jni.h"
25 #include "net/url_request/url_fetcher.h" 26 #include "net/url_request/url_fetcher.h"
26 #include "net/url_request/url_fetcher_delegate.h" 27 #include "net/url_request/url_fetcher_delegate.h"
27 #include "net/url_request/url_request_context_getter.h" 28 #include "net/url_request/url_request_context_getter.h"
28 #include "net/url_request/url_request_status.h" 29 #include "net/url_request/url_request_status.h"
29 #include "third_party/skia/include/core/SkBitmap.h" 30 #include "third_party/skia/include/core/SkBitmap.h"
30 #include "ui/gfx/android/java_bitmap.h" 31 #include "ui/gfx/android/java_bitmap.h"
31 #include "ui/gfx/image/image.h" 32 #include "ui/gfx/image/image.h"
32 #include "url/gurl.h" 33 #include "url/gurl.h"
33 34
34 using base::android::ConvertJavaStringToUTF8; 35 using base::android::ConvertJavaStringToUTF8;
35 using base::android::ConvertUTF8ToJavaString; 36 using base::android::ConvertUTF8ToJavaString;
36 using base::android::JavaParamRef; 37 using base::android::JavaParamRef;
37 using base::android::ScopedJavaLocalRef; 38 using base::android::ScopedJavaLocalRef;
38 using base::android::ToJavaByteArray; 39 using base::android::ToJavaByteArray;
39 40
40 namespace { 41 namespace {
41 42
42 const base::Feature kUseNewDoodleApi{"UseNewDoodleApi",
43 base::FEATURE_DISABLED_BY_DEFAULT};
44
45 ScopedJavaLocalRef<jobject> MakeJavaLogo(JNIEnv* env, 43 ScopedJavaLocalRef<jobject> MakeJavaLogo(JNIEnv* env,
46 const SkBitmap* bitmap, 44 const SkBitmap* bitmap,
47 const GURL& on_click_url, 45 const GURL& on_click_url,
48 const std::string& alt_text, 46 const std::string& alt_text,
49 const GURL& animated_url) { 47 const GURL& animated_url) {
50 ScopedJavaLocalRef<jobject> j_bitmap = gfx::ConvertToJavaBitmap(bitmap); 48 ScopedJavaLocalRef<jobject> j_bitmap = gfx::ConvertToJavaBitmap(bitmap);
51 49
52 ScopedJavaLocalRef<jstring> j_on_click_url; 50 ScopedJavaLocalRef<jstring> j_on_click_url;
53 if (on_click_url.is_valid()) 51 if (on_click_url.is_valid())
54 j_on_click_url = ConvertUTF8ToJavaString(env, on_click_url.spec()); 52 j_on_click_url = ConvertUTF8ToJavaString(env, on_click_url.spec());
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 189 }
192 190
193 LogoBridge::LogoBridge(jobject j_profile) 191 LogoBridge::LogoBridge(jobject j_profile)
194 : logo_service_(nullptr), 192 : logo_service_(nullptr),
195 doodle_service_(nullptr), 193 doodle_service_(nullptr),
196 doodle_observer_(this), 194 doodle_observer_(this),
197 weak_ptr_factory_(this) { 195 weak_ptr_factory_(this) {
198 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile); 196 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile);
199 DCHECK(profile); 197 DCHECK(profile);
200 198
201 if (base::FeatureList::IsEnabled(kUseNewDoodleApi)) { 199 if (base::FeatureList::IsEnabled(chrome::android::kUseNewDoodleApi)) {
202 doodle_service_ = DoodleServiceFactory::GetForProfile(profile); 200 doodle_service_ = DoodleServiceFactory::GetForProfile(profile);
203 image_fetcher_ = base::MakeUnique<image_fetcher::ImageFetcherImpl>( 201 image_fetcher_ = base::MakeUnique<image_fetcher::ImageFetcherImpl>(
204 base::MakeUnique<suggestions::ImageDecoderImpl>(), 202 base::MakeUnique<suggestions::ImageDecoderImpl>(),
205 profile->GetRequestContext()); 203 profile->GetRequestContext());
206 204
207 doodle_observer_.Add(doodle_service_); 205 doodle_observer_.Add(doodle_service_);
208 } else { 206 } else {
209 logo_service_ = LogoServiceFactory::GetForProfile(profile); 207 logo_service_ = LogoServiceFactory::GetForProfile(profile);
210 } 208 }
211 209
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 ScopedJavaLocalRef<jobject> j_logo = MakeJavaLogo( 302 ScopedJavaLocalRef<jobject> j_logo = MakeJavaLogo(
305 env, image.ToSkBitmap(), on_click_url, alt_text, animated_image_url); 303 env, image.ToSkBitmap(), on_click_url, alt_text, animated_image_url);
306 Java_LogoObserver_onLogoAvailable(env, j_logo_observer_, j_logo, 304 Java_LogoObserver_onLogoAvailable(env, j_logo_observer_, j_logo,
307 config_from_cache); 305 config_from_cache);
308 } 306 }
309 307
310 // static 308 // static
311 bool RegisterLogoBridge(JNIEnv* env) { 309 bool RegisterLogoBridge(JNIEnv* env) {
312 return RegisterNativesImpl(env); 310 return RegisterNativesImpl(env);
313 } 311 }
OLDNEW
« no previous file with comments | « chrome/browser/android/chrome_feature_list.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698