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 #include "chrome/browser/android/banners/app_banner_manager.h" | 5 #include "chrome/browser/android/banners/app_banner_manager.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 jobject obj, | 127 jobject obj, |
128 jstring jimage_url) { | 128 jstring jimage_url) { |
129 std::string image_url = ConvertJavaStringToUTF8(env, jimage_url); | 129 std::string image_url = ConvertJavaStringToUTF8(env, jimage_url); |
130 if (!web_contents()) | 130 if (!web_contents()) |
131 return false; | 131 return false; |
132 | 132 |
133 // Begin asynchronously fetching the app icon. | 133 // Begin asynchronously fetching the app icon. |
134 Profile* profile = | 134 Profile* profile = |
135 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 135 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
136 fetcher_.reset(new chrome::BitmapFetcher(GURL(image_url), this)); | 136 fetcher_.reset(new chrome::BitmapFetcher(GURL(image_url), this)); |
137 fetcher_.get()->Start(profile); | 137 fetcher_.get()->Start(profile->GetRequestContext()); |
138 return true; | 138 return true; |
139 } | 139 } |
140 | 140 |
141 void RecordDismissEvent(JNIEnv* env, jclass clazz, jint metric) { | 141 void RecordDismissEvent(JNIEnv* env, jclass clazz, jint metric) { |
142 banners::TrackDismissEvent(metric); | 142 banners::TrackDismissEvent(metric); |
143 } | 143 } |
144 | 144 |
145 void RecordInstallEvent(JNIEnv* env, jclass clazz, jint metric) { | 145 void RecordInstallEvent(JNIEnv* env, jclass clazz, jint metric) { |
146 banners::TrackInstallEvent(metric); | 146 banners::TrackInstallEvent(metric); |
147 } | 147 } |
148 | 148 |
149 jlong Init(JNIEnv* env, jobject obj) { | 149 jlong Init(JNIEnv* env, jobject obj) { |
150 AppBannerManager* manager = new AppBannerManager(env, obj); | 150 AppBannerManager* manager = new AppBannerManager(env, obj); |
151 return reinterpret_cast<intptr_t>(manager); | 151 return reinterpret_cast<intptr_t>(manager); |
152 } | 152 } |
153 | 153 |
154 jboolean IsEnabled(JNIEnv* env, jclass clazz) { | 154 jboolean IsEnabled(JNIEnv* env, jclass clazz) { |
155 return !CommandLine::ForCurrentProcess()->HasSwitch( | 155 return !CommandLine::ForCurrentProcess()->HasSwitch( |
156 switches::kDisableAppBanners); | 156 switches::kDisableAppBanners); |
157 } | 157 } |
158 | 158 |
159 // Register native methods | 159 // Register native methods |
160 bool RegisterAppBannerManager(JNIEnv* env) { | 160 bool RegisterAppBannerManager(JNIEnv* env) { |
161 return RegisterNativesImpl(env); | 161 return RegisterNativesImpl(env); |
162 } | 162 } |
163 | 163 |
164 } // namespace banners | 164 } // namespace banners |
OLD | NEW |