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

Side by Side Diff: content/browser/android/interstitial_page_delegate_android.cc

Issue 2237943002: Remove now-unnecessary .obj() in Java method calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@switch-context
Patch Set: Rebase *again* :( Created 4 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/android/interstitial_page_delegate_android.h" 5 #include "content/browser/android/interstitial_page_delegate_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/android/scoped_java_ref.h" 9 #include "base/android/scoped_java_ref.h"
10 #include "content/public/browser/interstitial_page.h" 10 #include "content/public/browser/interstitial_page.h"
(...skipping 11 matching lines...) Expand all
22 const std::string& html_content) 22 const std::string& html_content)
23 : weak_java_obj_(env, obj), 23 : weak_java_obj_(env, obj),
24 html_content_(html_content), 24 html_content_(html_content),
25 page_(NULL) { 25 page_(NULL) {
26 } 26 }
27 27
28 InterstitialPageDelegateAndroid::~InterstitialPageDelegateAndroid() { 28 InterstitialPageDelegateAndroid::~InterstitialPageDelegateAndroid() {
29 JNIEnv* env = AttachCurrentThread(); 29 JNIEnv* env = AttachCurrentThread();
30 ScopedJavaLocalRef<jobject> obj = weak_java_obj_.get(env); 30 ScopedJavaLocalRef<jobject> obj = weak_java_obj_.get(env);
31 if (obj.obj()) 31 if (obj.obj())
32 Java_InterstitialPageDelegateAndroid_onNativeDestroyed(env, obj.obj()); 32 Java_InterstitialPageDelegateAndroid_onNativeDestroyed(env, obj);
33 } 33 }
34 34
35 void InterstitialPageDelegateAndroid::Proceed( 35 void InterstitialPageDelegateAndroid::Proceed(
36 JNIEnv* env, 36 JNIEnv* env,
37 const JavaParamRef<jobject>& obj) { 37 const JavaParamRef<jobject>& obj) {
38 if (page_) 38 if (page_)
39 page_->Proceed(); 39 page_->Proceed();
40 } 40 }
41 41
42 void InterstitialPageDelegateAndroid::DontProceed( 42 void InterstitialPageDelegateAndroid::DontProceed(
43 JNIEnv* env, 43 JNIEnv* env,
44 const JavaParamRef<jobject>& obj) { 44 const JavaParamRef<jobject>& obj) {
45 if (page_) 45 if (page_)
46 page_->DontProceed(); 46 page_->DontProceed();
47 } 47 }
48 48
49 std::string InterstitialPageDelegateAndroid::GetHTMLContents() { 49 std::string InterstitialPageDelegateAndroid::GetHTMLContents() {
50 return html_content_; 50 return html_content_;
51 } 51 }
52 52
53 void InterstitialPageDelegateAndroid::OnProceed() { 53 void InterstitialPageDelegateAndroid::OnProceed() {
54 JNIEnv* env = AttachCurrentThread(); 54 JNIEnv* env = AttachCurrentThread();
55 ScopedJavaLocalRef<jobject> obj = weak_java_obj_.get(env); 55 ScopedJavaLocalRef<jobject> obj = weak_java_obj_.get(env);
56 if (obj.obj()) 56 if (obj.obj())
57 Java_InterstitialPageDelegateAndroid_onProceed(env, obj.obj()); 57 Java_InterstitialPageDelegateAndroid_onProceed(env, obj);
58 } 58 }
59 59
60 void InterstitialPageDelegateAndroid::OnDontProceed() { 60 void InterstitialPageDelegateAndroid::OnDontProceed() {
61 JNIEnv* env = AttachCurrentThread(); 61 JNIEnv* env = AttachCurrentThread();
62 ScopedJavaLocalRef<jobject> obj = weak_java_obj_.get(env); 62 ScopedJavaLocalRef<jobject> obj = weak_java_obj_.get(env);
63 if (obj.obj()) 63 if (obj.obj())
64 Java_InterstitialPageDelegateAndroid_onDontProceed(env, obj.obj()); 64 Java_InterstitialPageDelegateAndroid_onDontProceed(env, obj);
65 } 65 }
66 66
67 void InterstitialPageDelegateAndroid::CommandReceived( 67 void InterstitialPageDelegateAndroid::CommandReceived(
68 const std::string& command) { 68 const std::string& command) {
69 JNIEnv* env = AttachCurrentThread(); 69 JNIEnv* env = AttachCurrentThread();
70 ScopedJavaLocalRef<jobject> obj = weak_java_obj_.get(env); 70 ScopedJavaLocalRef<jobject> obj = weak_java_obj_.get(env);
71 if (obj.obj()) { 71 if (obj.obj()) {
72 std::string sanitized_command(command); 72 std::string sanitized_command(command);
73 // The JSONified response has quotes, remove them. 73 // The JSONified response has quotes, remove them.
74 if (sanitized_command.length() > 1 && sanitized_command[0] == '"') { 74 if (sanitized_command.length() > 1 && sanitized_command[0] == '"') {
75 sanitized_command = sanitized_command.substr( 75 sanitized_command = sanitized_command.substr(
76 1, sanitized_command.length() - 2); 76 1, sanitized_command.length() - 2);
77 } 77 }
78 78
79 Java_InterstitialPageDelegateAndroid_commandReceived( 79 Java_InterstitialPageDelegateAndroid_commandReceived(
80 env, obj.obj(), 80 env, obj,
81 base::android::ConvertUTF8ToJavaString(env, sanitized_command).obj()); 81 base::android::ConvertUTF8ToJavaString(env, sanitized_command));
82 } 82 }
83 } 83 }
84 84
85 // static 85 // static
86 bool InterstitialPageDelegateAndroid 86 bool InterstitialPageDelegateAndroid
87 ::RegisterInterstitialPageDelegateAndroid(JNIEnv* env) { 87 ::RegisterInterstitialPageDelegateAndroid(JNIEnv* env) {
88 return RegisterNativesImpl(env); 88 return RegisterNativesImpl(env);
89 } 89 }
90 90
91 static jlong Init(JNIEnv* env, 91 static jlong Init(JNIEnv* env,
92 const JavaParamRef<jobject>& obj, 92 const JavaParamRef<jobject>& obj,
93 const JavaParamRef<jstring>& html_content) { 93 const JavaParamRef<jstring>& html_content) {
94 InterstitialPageDelegateAndroid* delegate = 94 InterstitialPageDelegateAndroid* delegate =
95 new InterstitialPageDelegateAndroid( 95 new InterstitialPageDelegateAndroid(
96 env, obj, base::android::ConvertJavaStringToUTF8(env, html_content)); 96 env, obj, base::android::ConvertJavaStringToUTF8(env, html_content));
97 return reinterpret_cast<intptr_t>(delegate); 97 return reinterpret_cast<intptr_t>(delegate);
98 } 98 }
99 99
100 } // namespace content 100 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/interface_registry_android_impl.cc ('k') | content/browser/android/popup_touch_handle_drawable.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698