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/android/android_theme_resources.h" | |
tbansal1
2016/06/30 19:00:41
Is this include necessary?
megjablon
2016/06/30 19:56:09
Done.
| |
9 #include "chrome/browser/infobars/infobar_service.h" | |
10 #include "components/infobars/core/infobar.h" | |
11 #include "components/infobars/core/infobar_delegate.h" | |
tbansal1
2016/06/30 19:00:41
components/infobars/core/infobar_delegate.h is alr
megjablon
2016/06/30 19:56:09
Done.
| |
12 #include "content/public/browser/web_contents.h" | |
13 #include "grit/components_strings.h" | |
14 #include "jni/DataReductionPromoInfoBarDelegate_jni.h" | |
15 #include "ui/base/l10n/l10n_util.h" | |
16 | |
17 // static | |
18 void DataReductionPromoInfoBarDelegateAndroid::Create( | |
19 content::WebContents* web_contents) { | |
20 InfoBarService* infobar_service = | |
21 InfoBarService::FromWebContents(web_contents); | |
22 infobar_service->AddInfoBar( | |
23 DataReductionPromoInfoBarDelegateAndroid::CreateInfoBar( | |
24 infobar_service, | |
25 base::MakeUnique<DataReductionPromoInfoBarDelegateAndroid>())); | |
26 } | |
27 | |
28 DataReductionPromoInfoBarDelegateAndroid:: | |
29 DataReductionPromoInfoBarDelegateAndroid() {} | |
30 | |
31 DataReductionPromoInfoBarDelegateAndroid:: | |
32 ~DataReductionPromoInfoBarDelegateAndroid() { | |
33 JNIEnv* env = base::android::AttachCurrentThread(); | |
34 Java_DataReductionPromoInfoBarDelegate_onNativeDestroyed(env); | |
35 } | |
36 | |
37 // static | |
38 bool DataReductionPromoInfoBarDelegateAndroid::Register(JNIEnv* env) { | |
39 return RegisterNativesImpl(env); | |
40 } | |
41 | |
42 // static | |
43 void DataReductionPromoInfoBarDelegateAndroid::Launch( | |
44 JNIEnv* env, jclass, jobject jweb_contents) { | |
45 content::WebContents* web_contents = | |
46 content::WebContents::FromJavaWebContents(jweb_contents); | |
47 DCHECK(web_contents); | |
48 Create(web_contents); | |
49 } | |
50 | |
51 base::android::ScopedJavaLocalRef<jobject> | |
52 DataReductionPromoInfoBarDelegateAndroid::CreateRenderInfoBar(JNIEnv* env) { | |
53 return Java_DataReductionPromoInfoBarDelegate_showPromoInfoBar(env); | |
54 } | |
55 | |
56 infobars::InfoBarDelegate::InfoBarIdentifier | |
57 DataReductionPromoInfoBarDelegateAndroid::GetIdentifier() const { | |
58 return DATA_REDUCTION_PROMO_INFOBAR_DELEGATE_ANDROID; | |
59 } | |
60 | |
61 base::string16 DataReductionPromoInfoBarDelegateAndroid::GetMessageText() | |
62 const { | |
63 // Message is set in DataReductionPromoInfoBar.java. | |
64 return base::string16(); | |
65 } | |
66 | |
67 bool DataReductionPromoInfoBarDelegateAndroid::Accept() { | |
68 JNIEnv* env = base::android::AttachCurrentThread(); | |
69 Java_DataReductionPromoInfoBarDelegate_accept(env); | |
70 return true; | |
71 } | |
72 | |
73 // JNI for DataReductionPromoInfoBarDelegate. | |
74 void Launch(JNIEnv* env, | |
75 const JavaParamRef<jclass>& clazz, | |
76 const JavaParamRef<jobject>& jweb_contents) { | |
77 DataReductionPromoInfoBarDelegateAndroid::Launch(env, clazz, jweb_contents); | |
78 } | |
OLD | NEW |