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 #include <chrome/browser/ui/android/infobars/data_reduction_promo_infobar.h> | |
7 #include <utility> | |
8 | |
9 #include "base/android/jni_android.h" | |
10 #include "base/android/jni_string.h" | |
11 #include "base/logging.h" | |
12 #include "chrome/browser/android/resource_mapper.h" | |
13 #include "content/public/browser/web_contents.h" | |
14 #include "jni/DataReductionPromoInfoBarDelegate_jni.h" | |
15 | |
16 // DataReductionPromoInfoBar: | |
17 | |
18 // static | |
19 void DataReductionPromoInfoBar::Launch( | |
20 JNIEnv* env, jclass, jobject jweb_contents) { | |
21 content::WebContents* web_contents = | |
22 content::WebContents::FromJavaWebContents(jweb_contents); | |
23 DCHECK(web_contents); | |
24 DataReductionPromoInfoBarDelegateAndroid::Create(web_contents); | |
25 } | |
26 | |
27 // static | |
28 bool DataReductionPromoInfoBar::Register(JNIEnv* env) { | |
29 return RegisterNativesImpl(env); | |
30 } | |
31 | |
32 DataReductionPromoInfoBar::DataReductionPromoInfoBar( | |
33 std::unique_ptr<DataReductionPromoInfoBarDelegateAndroid> delegate) | |
34 : ConfirmInfoBar(std::move(delegate)), | |
35 java_data_reduction_promo_delegate_() {} | |
36 | |
37 DataReductionPromoInfoBar::~DataReductionPromoInfoBar() { | |
Raj
2016/06/13 17:52:18
nit: Can this be inlined.
megjablon
2016/06/23 23:17:30
Style guide says not to https://www.chromium.org/d
| |
38 } | |
39 | |
40 base::android::ScopedJavaLocalRef<jobject> | |
41 DataReductionPromoInfoBar::CreateRenderInfoBar(JNIEnv* env) { | |
42 java_data_reduction_promo_delegate_.Reset( | |
43 Java_DataReductionPromoInfoBarDelegate_create(env)); | |
44 | |
45 return Java_DataReductionPromoInfoBarDelegate_showDataReductionPromoInfoBar( | |
46 env, java_data_reduction_promo_delegate_.obj()); | |
47 } | |
48 | |
49 DataReductionPromoInfoBarDelegateAndroid* | |
50 DataReductionPromoInfoBar::GetDelegate() { | |
51 return static_cast<DataReductionPromoInfoBarDelegateAndroid*>(delegate()); | |
52 } | |
53 | |
54 // DataReductionPromoInfoBarDelegate: | |
55 | |
56 // static | |
57 std::unique_ptr<infobars::InfoBar> | |
58 DataReductionPromoInfoBarDelegateAndroid::CreateInfoBar( | |
59 infobars::InfoBarManager* infobar_manager, | |
60 std::unique_ptr<DataReductionPromoInfoBarDelegateAndroid> delegate) { | |
61 return std::unique_ptr<infobars::InfoBar>( | |
62 new DataReductionPromoInfoBar(std::move(delegate))); | |
63 } | |
64 | |
65 // JNI for DataReductionPromoInfoBarDelegate. | |
66 void Launch(JNIEnv* env, | |
67 const JavaParamRef<jclass>& clazz, | |
68 const JavaParamRef<jobject>& jweb_contents) { | |
69 DataReductionPromoInfoBar::Launch(env, clazz, jweb_contents); | |
70 } | |
OLD | NEW |