Loosen up heuristics for detecting account creation forms.
[chromium-blink-merge.git] / android_webview / native / intercepted_request_data.cc
blob80649bd646fed20d1b82bcddb6b3f7d0c0389cbd
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
3 // found in the LICENSE file.
5 #include "android_webview/native/intercepted_request_data.h"
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h"
9 #include "jni/InterceptedRequestData_jni.h"
11 using std::string;
12 using base::android::ScopedJavaLocalRef;
14 InterceptedRequestData::InterceptedRequestData(
15 JNIEnv* env, base::android::JavaRef<jobject> obj) {
16 java_object_.Reset(env, obj.obj());
19 InterceptedRequestData::~InterceptedRequestData() {
22 ScopedJavaLocalRef<jobject>
23 InterceptedRequestData::GetInputStream(JNIEnv* env) const {
24 return Java_InterceptedRequestData_getData(env, java_object_.obj());
27 bool InterceptedRequestData::GetMimeType(JNIEnv* env,
28 string* mime_type) const {
29 ScopedJavaLocalRef<jstring> jstring_mime_type =
30 Java_InterceptedRequestData_getMimeType(env, java_object_.obj());
31 if (jstring_mime_type.is_null())
32 return false;
33 *mime_type = ConvertJavaStringToUTF8(jstring_mime_type);
34 return true;
37 bool InterceptedRequestData::GetCharset(
38 JNIEnv* env, string* charset) const {
39 ScopedJavaLocalRef<jstring> jstring_charset =
40 Java_InterceptedRequestData_getCharset(env, java_object_.obj());
41 if (jstring_charset.is_null())
42 return false;
43 *charset = ConvertJavaStringToUTF8(jstring_charset);
44 return true;
47 bool RegisterInterceptedRequestData(JNIEnv* env) {
48 if (g_InterceptedRequestData_clazz)
49 return true;
50 if (!base::android::HasClass(env, kInterceptedRequestDataClassPath)) {
51 DLOG(ERROR) << "Unable to find class InterceptedRequestData!";
52 return false;
54 return RegisterNativesImpl(env);