Chromium Code Reviews| Index: chrome/browser/ui/android/infobars/data_reduction_promo_infobar.cc |
| diff --git a/chrome/browser/ui/android/infobars/data_reduction_promo_infobar.cc b/chrome/browser/ui/android/infobars/data_reduction_promo_infobar.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..21ef1a66c07c31bfb2288d6235baa4ac9b820d68 |
| --- /dev/null |
| +++ b/chrome/browser/ui/android/infobars/data_reduction_promo_infobar.cc |
| @@ -0,0 +1,70 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include <chrome/browser/net/spdyproxy/data_reduction_promo_infobar_delegate_android.h> |
| +#include <chrome/browser/ui/android/infobars/data_reduction_promo_infobar.h> |
| +#include <utility> |
| + |
| +#include "base/android/jni_android.h" |
| +#include "base/android/jni_string.h" |
| +#include "base/logging.h" |
| +#include "chrome/browser/android/resource_mapper.h" |
| +#include "content/public/browser/web_contents.h" |
| +#include "jni/DataReductionPromoInfoBarDelegate_jni.h" |
| + |
| +// DataReductionPromoInfoBar: |
| + |
| +// static |
| +void DataReductionPromoInfoBar::Launch( |
| + JNIEnv* env, jclass, jobject jweb_contents) { |
| + content::WebContents* web_contents = |
| + content::WebContents::FromJavaWebContents(jweb_contents); |
| + DCHECK(web_contents); |
| + DataReductionPromoInfoBarDelegateAndroid::Create(web_contents); |
| +} |
| + |
| +// static |
| +bool DataReductionPromoInfoBar::Register(JNIEnv* env) { |
| + return RegisterNativesImpl(env); |
| +} |
| + |
| +DataReductionPromoInfoBar::DataReductionPromoInfoBar( |
| + std::unique_ptr<DataReductionPromoInfoBarDelegateAndroid> delegate) |
| + : ConfirmInfoBar(std::move(delegate)), |
| + java_data_reduction_promo_delegate_() {} |
| + |
| +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
|
| +} |
| + |
| +base::android::ScopedJavaLocalRef<jobject> |
| +DataReductionPromoInfoBar::CreateRenderInfoBar(JNIEnv* env) { |
| + java_data_reduction_promo_delegate_.Reset( |
| + Java_DataReductionPromoInfoBarDelegate_create(env)); |
| + |
| + return Java_DataReductionPromoInfoBarDelegate_showDataReductionPromoInfoBar( |
| + env, java_data_reduction_promo_delegate_.obj()); |
| +} |
| + |
| +DataReductionPromoInfoBarDelegateAndroid* |
| +DataReductionPromoInfoBar::GetDelegate() { |
| + return static_cast<DataReductionPromoInfoBarDelegateAndroid*>(delegate()); |
| +} |
| + |
| +// DataReductionPromoInfoBarDelegate: |
| + |
| +// static |
| +std::unique_ptr<infobars::InfoBar> |
| +DataReductionPromoInfoBarDelegateAndroid::CreateInfoBar( |
| + infobars::InfoBarManager* infobar_manager, |
| + std::unique_ptr<DataReductionPromoInfoBarDelegateAndroid> delegate) { |
| + return std::unique_ptr<infobars::InfoBar>( |
| + new DataReductionPromoInfoBar(std::move(delegate))); |
| +} |
| + |
| +// JNI for DataReductionPromoInfoBarDelegate. |
| +void Launch(JNIEnv* env, |
| + const JavaParamRef<jclass>& clazz, |
| + const JavaParamRef<jobject>& jweb_contents) { |
| + DataReductionPromoInfoBar::Launch(env, clazz, jweb_contents); |
| +} |