Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / android / infobars / data_reduction_proxy_infobar.cc
blob57e295e769813a04c399480d623dbfa85406ea32
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.
5 #include "chrome/browser/ui/android/infobars/data_reduction_proxy_infobar.h"
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h"
9 #include "base/logging.h"
10 #include "chrome/browser/android/resource_mapper.h"
11 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_infobar_delegate.h"
12 #include "content/public/browser/web_contents.h"
13 #include "jni/DataReductionProxyInfoBarDelegate_jni.h"
15 // DataReductionProxyInfoBar:
17 // static
18 void DataReductionProxyInfoBar::Launch(
19 JNIEnv* env, jclass, jobject jweb_contents, jstring jlink_url) {
20 content::WebContents* web_contents =
21 content::WebContents::FromJavaWebContents(jweb_contents);
22 DCHECK(web_contents);
23 DataReductionProxyInfoBarDelegate::Create(
24 web_contents, base::android::ConvertJavaStringToUTF8(env, jlink_url));
27 // static
28 bool DataReductionProxyInfoBar::Register(JNIEnv* env) {
29 return RegisterNativesImpl(env);
32 DataReductionProxyInfoBar::DataReductionProxyInfoBar(
33 scoped_ptr<DataReductionProxyInfoBarDelegate> delegate)
34 : ConfirmInfoBar(delegate.Pass()), java_data_reduction_proxy_delegate_() {
37 DataReductionProxyInfoBar::~DataReductionProxyInfoBar() {
40 base::android::ScopedJavaLocalRef<jobject>
41 DataReductionProxyInfoBar::CreateRenderInfoBar(JNIEnv* env) {
42 java_data_reduction_proxy_delegate_.Reset(
43 Java_DataReductionProxyInfoBarDelegate_create(env));
45 return Java_DataReductionProxyInfoBarDelegate_showDataReductionProxyInfoBar(
46 env,
47 java_data_reduction_proxy_delegate_.obj(),
48 reinterpret_cast<intptr_t>(this),
49 GetEnumeratedIconId());
52 DataReductionProxyInfoBarDelegate* DataReductionProxyInfoBar::GetDelegate() {
53 return static_cast<DataReductionProxyInfoBarDelegate*>(delegate());
57 // DataReductionProxyInfoBarDelegate:
59 // static
60 scoped_ptr<infobars::InfoBar> DataReductionProxyInfoBarDelegate::CreateInfoBar(
61 infobars::InfoBarManager* infobar_manager,
62 scoped_ptr<DataReductionProxyInfoBarDelegate> delegate) {
63 return scoped_ptr<infobars::InfoBar>(
64 new DataReductionProxyInfoBar(delegate.Pass()));
68 // JNI for DataReductionProxyInfoBarDelegate.
69 void
70 Launch(JNIEnv* env, jclass clazz, jobject jweb_contents, jstring jlink_url) {
71 DataReductionProxyInfoBar::Launch(env, clazz, jweb_contents, jlink_url);