OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/net/spdyproxy/data_reduction_promo_infobar_delegate_and
roid.h" |
| 6 |
| 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/infobars/infobar_service.h" |
| 9 #include "components/infobars/core/infobar.h" |
| 10 #include "content/public/browser/web_contents.h" |
| 11 #include "jni/DataReductionPromoInfoBarDelegate_jni.h" |
| 12 #include "ui/base/l10n/l10n_util.h" |
| 13 |
| 14 // static |
| 15 void DataReductionPromoInfoBarDelegateAndroid::Create( |
| 16 content::WebContents* web_contents) { |
| 17 InfoBarService* infobar_service = |
| 18 InfoBarService::FromWebContents(web_contents); |
| 19 infobar_service->AddInfoBar( |
| 20 DataReductionPromoInfoBarDelegateAndroid::CreateInfoBar( |
| 21 infobar_service, |
| 22 base::MakeUnique<DataReductionPromoInfoBarDelegateAndroid>())); |
| 23 } |
| 24 |
| 25 DataReductionPromoInfoBarDelegateAndroid:: |
| 26 DataReductionPromoInfoBarDelegateAndroid() {} |
| 27 |
| 28 DataReductionPromoInfoBarDelegateAndroid:: |
| 29 ~DataReductionPromoInfoBarDelegateAndroid() { |
| 30 JNIEnv* env = base::android::AttachCurrentThread(); |
| 31 Java_DataReductionPromoInfoBarDelegate_onNativeDestroyed(env); |
| 32 } |
| 33 |
| 34 // static |
| 35 bool DataReductionPromoInfoBarDelegateAndroid::Register(JNIEnv* env) { |
| 36 return RegisterNativesImpl(env); |
| 37 } |
| 38 |
| 39 // static |
| 40 void DataReductionPromoInfoBarDelegateAndroid::Launch( |
| 41 JNIEnv* env, jclass, jobject jweb_contents) { |
| 42 content::WebContents* web_contents = |
| 43 content::WebContents::FromJavaWebContents(jweb_contents); |
| 44 DCHECK(web_contents); |
| 45 Create(web_contents); |
| 46 } |
| 47 |
| 48 base::android::ScopedJavaLocalRef<jobject> |
| 49 DataReductionPromoInfoBarDelegateAndroid::CreateRenderInfoBar(JNIEnv* env) { |
| 50 return Java_DataReductionPromoInfoBarDelegate_showPromoInfoBar(env); |
| 51 } |
| 52 |
| 53 infobars::InfoBarDelegate::InfoBarIdentifier |
| 54 DataReductionPromoInfoBarDelegateAndroid::GetIdentifier() const { |
| 55 return DATA_REDUCTION_PROMO_INFOBAR_DELEGATE_ANDROID; |
| 56 } |
| 57 |
| 58 base::string16 DataReductionPromoInfoBarDelegateAndroid::GetMessageText() |
| 59 const { |
| 60 // Message is set in DataReductionPromoInfoBar.java. |
| 61 return base::string16(); |
| 62 } |
| 63 |
| 64 bool DataReductionPromoInfoBarDelegateAndroid::Accept() { |
| 65 JNIEnv* env = base::android::AttachCurrentThread(); |
| 66 Java_DataReductionPromoInfoBarDelegate_accept(env); |
| 67 return true; |
| 68 } |
| 69 |
| 70 // JNI for DataReductionPromoInfoBarDelegate. |
| 71 void Launch(JNIEnv* env, |
| 72 const JavaParamRef<jclass>& clazz, |
| 73 const JavaParamRef<jobject>& jweb_contents) { |
| 74 DataReductionPromoInfoBarDelegateAndroid::Launch(env, clazz, jweb_contents); |
| 75 } |
OLD | NEW |