| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/android/infobars/data_reduction_proxy_infobar.h" | |
| 6 | |
| 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 "chrome/browser/net/spdyproxy/data_reduction_proxy_infobar_delegate_and
roid.h" | |
| 14 #include "content/public/browser/web_contents.h" | |
| 15 #include "jni/DataReductionProxyInfoBarDelegate_jni.h" | |
| 16 | |
| 17 // DataReductionProxyInfoBar: | |
| 18 | |
| 19 // static | |
| 20 void DataReductionProxyInfoBar::Launch( | |
| 21 JNIEnv* env, jclass, jobject jweb_contents, jstring jlink_url) { | |
| 22 content::WebContents* web_contents = | |
| 23 content::WebContents::FromJavaWebContents(jweb_contents); | |
| 24 DCHECK(web_contents); | |
| 25 DataReductionProxyInfoBarDelegateAndroid::Create( | |
| 26 web_contents, base::android::ConvertJavaStringToUTF8(env, jlink_url)); | |
| 27 } | |
| 28 | |
| 29 // static | |
| 30 bool DataReductionProxyInfoBar::Register(JNIEnv* env) { | |
| 31 return RegisterNativesImpl(env); | |
| 32 } | |
| 33 | |
| 34 DataReductionProxyInfoBar::DataReductionProxyInfoBar( | |
| 35 std::unique_ptr<DataReductionProxyInfoBarDelegateAndroid> delegate) | |
| 36 : ConfirmInfoBar(std::move(delegate)), | |
| 37 java_data_reduction_proxy_delegate_() {} | |
| 38 | |
| 39 DataReductionProxyInfoBar::~DataReductionProxyInfoBar() { | |
| 40 } | |
| 41 | |
| 42 base::android::ScopedJavaLocalRef<jobject> | |
| 43 DataReductionProxyInfoBar::CreateRenderInfoBar(JNIEnv* env) { | |
| 44 java_data_reduction_proxy_delegate_.Reset( | |
| 45 Java_DataReductionProxyInfoBarDelegate_create(env)); | |
| 46 | |
| 47 return Java_DataReductionProxyInfoBarDelegate_showDataReductionProxyInfoBar( | |
| 48 env, java_data_reduction_proxy_delegate_.obj(), GetEnumeratedIconId()); | |
| 49 } | |
| 50 | |
| 51 DataReductionProxyInfoBarDelegateAndroid* | |
| 52 DataReductionProxyInfoBar::GetDelegate() { | |
| 53 return static_cast<DataReductionProxyInfoBarDelegateAndroid*>(delegate()); | |
| 54 } | |
| 55 | |
| 56 // DataReductionProxyInfoBarDelegate: | |
| 57 | |
| 58 // static | |
| 59 std::unique_ptr<infobars::InfoBar> | |
| 60 DataReductionProxyInfoBarDelegateAndroid::CreateInfoBar( | |
| 61 infobars::InfoBarManager* infobar_manager, | |
| 62 std::unique_ptr<DataReductionProxyInfoBarDelegateAndroid> delegate) { | |
| 63 return std::unique_ptr<infobars::InfoBar>( | |
| 64 new DataReductionProxyInfoBar(std::move(delegate))); | |
| 65 } | |
| 66 | |
| 67 // JNI for DataReductionProxyInfoBarDelegate. | |
| 68 void Launch(JNIEnv* env, | |
| 69 const JavaParamRef<jclass>& clazz, | |
| 70 const JavaParamRef<jobject>& jweb_contents, | |
| 71 const JavaParamRef<jstring>& jlink_url) { | |
| 72 DataReductionProxyInfoBar::Launch(env, clazz, jweb_contents, jlink_url); | |
| 73 } | |
| OLD | NEW |