Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: chrome/browser/net/spdyproxy/data_reduction_promo_infobar_delegate_android.cc

Issue 2315323002: Pass JavaRef to WebContents::FromJavaWebContents. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/net/spdyproxy/data_reduction_promo_infobar_delegate_and roid.h" 5 #include "chrome/browser/net/spdyproxy/data_reduction_promo_infobar_delegate_and roid.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/infobars/infobar_service.h" 8 #include "chrome/browser/infobars/infobar_service.h"
9 #include "components/infobars/core/infobar.h" 9 #include "components/infobars/core/infobar.h"
10 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
11 #include "jni/DataReductionPromoInfoBarDelegate_jni.h" 11 #include "jni/DataReductionPromoInfoBarDelegate_jni.h"
12 12
13 using base::android::JavaParamRef; 13 using base::android::JavaParamRef;
14 using base::android::JavaRef;
14 15
15 // static 16 // static
16 void DataReductionPromoInfoBarDelegateAndroid::Create( 17 void DataReductionPromoInfoBarDelegateAndroid::Create(
17 content::WebContents* web_contents) { 18 content::WebContents* web_contents) {
18 InfoBarService* infobar_service = 19 InfoBarService* infobar_service =
19 InfoBarService::FromWebContents(web_contents); 20 InfoBarService::FromWebContents(web_contents);
20 infobar_service->AddInfoBar( 21 infobar_service->AddInfoBar(
21 DataReductionPromoInfoBarDelegateAndroid::CreateInfoBar( 22 DataReductionPromoInfoBarDelegateAndroid::CreateInfoBar(
22 infobar_service, 23 infobar_service,
23 base::MakeUnique<DataReductionPromoInfoBarDelegateAndroid>())); 24 base::MakeUnique<DataReductionPromoInfoBarDelegateAndroid>()));
24 } 25 }
25 26
26 DataReductionPromoInfoBarDelegateAndroid:: 27 DataReductionPromoInfoBarDelegateAndroid::
27 DataReductionPromoInfoBarDelegateAndroid() {} 28 DataReductionPromoInfoBarDelegateAndroid() {}
28 29
29 DataReductionPromoInfoBarDelegateAndroid:: 30 DataReductionPromoInfoBarDelegateAndroid::
30 ~DataReductionPromoInfoBarDelegateAndroid() { 31 ~DataReductionPromoInfoBarDelegateAndroid() {
31 JNIEnv* env = base::android::AttachCurrentThread(); 32 JNIEnv* env = base::android::AttachCurrentThread();
32 Java_DataReductionPromoInfoBarDelegate_onNativeDestroyed(env); 33 Java_DataReductionPromoInfoBarDelegate_onNativeDestroyed(env);
33 } 34 }
34 35
35 // static 36 // static
36 bool DataReductionPromoInfoBarDelegateAndroid::Register(JNIEnv* env) { 37 bool DataReductionPromoInfoBarDelegateAndroid::Register(JNIEnv* env) {
37 return RegisterNativesImpl(env); 38 return RegisterNativesImpl(env);
38 } 39 }
39 40
40 // static 41 // static
41 void DataReductionPromoInfoBarDelegateAndroid::Launch( 42 void DataReductionPromoInfoBarDelegateAndroid::Launch(
42 JNIEnv* env, jclass, jobject jweb_contents) { 43 JNIEnv* env,
44 const JavaRef<jobject>& jweb_contents) {
43 content::WebContents* web_contents = 45 content::WebContents* web_contents =
44 content::WebContents::FromJavaWebContents(jweb_contents); 46 content::WebContents::FromJavaWebContents(jweb_contents);
45 DCHECK(web_contents); 47 DCHECK(web_contents);
46 Create(web_contents); 48 Create(web_contents);
47 } 49 }
48 50
49 base::android::ScopedJavaLocalRef<jobject> 51 base::android::ScopedJavaLocalRef<jobject>
50 DataReductionPromoInfoBarDelegateAndroid::CreateRenderInfoBar(JNIEnv* env) { 52 DataReductionPromoInfoBarDelegateAndroid::CreateRenderInfoBar(JNIEnv* env) {
51 return Java_DataReductionPromoInfoBarDelegate_showPromoInfoBar(env); 53 return Java_DataReductionPromoInfoBarDelegate_showPromoInfoBar(env);
52 } 54 }
(...skipping 12 matching lines...) Expand all
65 bool DataReductionPromoInfoBarDelegateAndroid::Accept() { 67 bool DataReductionPromoInfoBarDelegateAndroid::Accept() {
66 JNIEnv* env = base::android::AttachCurrentThread(); 68 JNIEnv* env = base::android::AttachCurrentThread();
67 Java_DataReductionPromoInfoBarDelegate_accept(env); 69 Java_DataReductionPromoInfoBarDelegate_accept(env);
68 return true; 70 return true;
69 } 71 }
70 72
71 // JNI for DataReductionPromoInfoBarDelegate. 73 // JNI for DataReductionPromoInfoBarDelegate.
72 void Launch(JNIEnv* env, 74 void Launch(JNIEnv* env,
73 const JavaParamRef<jclass>& clazz, 75 const JavaParamRef<jclass>& clazz,
74 const JavaParamRef<jobject>& jweb_contents) { 76 const JavaParamRef<jobject>& jweb_contents) {
75 DataReductionPromoInfoBarDelegateAndroid::Launch(env, clazz, jweb_contents); 77 DataReductionPromoInfoBarDelegateAndroid::Launch(env, jweb_contents);
76 } 78 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698