| OLD | NEW |
| 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/content_view_client.h" | 5 #include "content/browser/android/content_view_client.h" |
| 6 | 6 |
| 7 #include <android/keycodes.h> | 7 #include <android/keycodes.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 125 |
| 126 void ContentViewClient::SetFindHelper(FindHelper* find_helper) { | 126 void ContentViewClient::SetFindHelper(FindHelper* find_helper) { |
| 127 find_helper_ = find_helper; | 127 find_helper_ = find_helper; |
| 128 } | 128 } |
| 129 | 129 |
| 130 void ContentViewClient::SetJavaScriptDialogCreator( | 130 void ContentViewClient::SetJavaScriptDialogCreator( |
| 131 JavaScriptDialogCreator* javascript_dialog_creator) { | 131 JavaScriptDialogCreator* javascript_dialog_creator) { |
| 132 javascript_dialog_creator_ = javascript_dialog_creator; | 132 javascript_dialog_creator_ = javascript_dialog_creator; |
| 133 } | 133 } |
| 134 | 134 |
| 135 bool ContentViewClient::OnJSModalDialog(JavaScriptMessageType type, | 135 bool ContentViewClient::OnJsModalDialog(JavaScriptMessageType type, |
| 136 bool is_before_unload_dialog, | 136 bool is_before_unload_dialog, |
| 137 const GURL& url, | 137 const GURL& url, |
| 138 const string16& message, | 138 const string16& message, |
| 139 const string16& default_value) { | 139 const string16& default_value, |
| 140 jobject js_result) { |
| 140 JNIEnv* env = AttachCurrentThread(); | 141 JNIEnv* env = AttachCurrentThread(); |
| 141 ScopedJavaLocalRef<jstring> jurl(ConvertUTF8ToJavaString(env, url.spec())); | 142 ScopedJavaLocalRef<jstring> jurl(ConvertUTF8ToJavaString(env, url.spec())); |
| 142 ScopedJavaLocalRef<jstring> jmessage(ConvertUTF16ToJavaString(env, message)); | 143 ScopedJavaLocalRef<jstring> jmessage(ConvertUTF16ToJavaString(env, message)); |
| 143 | 144 |
| 144 // Special case for beforeunload dialogs, as that isn't encoded in the | 145 // Special case for beforeunload dialogs, as that isn't encoded in the |
| 145 // |type| of the dialog. | 146 // |type| of the dialog. |
| 146 if (is_before_unload_dialog) { | 147 if (is_before_unload_dialog) { |
| 147 return Java_ContentViewClient_onJsBeforeUnload(env, | 148 return Java_ContentViewClient_onJsBeforeUnload(env, |
| 148 weak_java_client_.get(env).obj(), | 149 weak_java_client_.get(env).obj(), |
| 149 jurl.obj(), | 150 jurl.obj(), |
| 150 jmessage.obj()); | 151 jmessage.obj(), |
| 152 js_result); |
| 151 } | 153 } |
| 152 | 154 |
| 153 switch (type) { | 155 switch (type) { |
| 154 case JAVASCRIPT_MESSAGE_TYPE_ALERT: | 156 case JAVASCRIPT_MESSAGE_TYPE_ALERT: |
| 155 return Java_ContentViewClient_onJsAlert(env, | 157 return Java_ContentViewClient_onJsAlert(env, |
| 156 weak_java_client_.get(env).obj(), | 158 weak_java_client_.get(env).obj(), |
| 157 jurl.obj(), | 159 jurl.obj(), |
| 158 jmessage.obj()); | 160 jmessage.obj(), |
| 161 js_result); |
| 159 | 162 |
| 160 case JAVASCRIPT_MESSAGE_TYPE_CONFIRM: | 163 case JAVASCRIPT_MESSAGE_TYPE_CONFIRM: |
| 161 return Java_ContentViewClient_onJsConfirm(env, | 164 return Java_ContentViewClient_onJsConfirm(env, |
| 162 weak_java_client_.get(env).obj(), | 165 weak_java_client_.get(env).obj(), |
| 163 jurl.obj(), | 166 jurl.obj(), |
| 164 jmessage.obj()); | 167 jmessage.obj(), |
| 168 js_result); |
| 165 | 169 |
| 166 case JAVASCRIPT_MESSAGE_TYPE_PROMPT: { | 170 case JAVASCRIPT_MESSAGE_TYPE_PROMPT: { |
| 167 ScopedJavaLocalRef<jstring> jdefault_value( | 171 ScopedJavaLocalRef<jstring> jdefault_value( |
| 168 ConvertUTF16ToJavaString(env, default_value)); | 172 ConvertUTF16ToJavaString(env, default_value)); |
| 169 return Java_ContentViewClient_onJsPrompt(env, | 173 return Java_ContentViewClient_onJsPrompt(env, |
| 170 weak_java_client_.get(env).obj(), | 174 weak_java_client_.get(env).obj(), |
| 171 jurl.obj(), | 175 jurl.obj(), |
| 172 jmessage.obj(), | 176 jmessage.obj(), |
| 173 jdefault_value.obj()); | 177 jdefault_value.obj(), |
| 178 js_result); |
| 174 } | 179 } |
| 175 | 180 |
| 176 default: | 181 default: |
| 177 NOTREACHED(); | 182 NOTREACHED(); |
| 178 return false; | 183 return false; |
| 179 } | 184 } |
| 180 } | 185 } |
| 181 | 186 |
| 182 // ---------------------------------------------------------------------------- | 187 // ---------------------------------------------------------------------------- |
| 183 // WebContentsDelegate methods | 188 // WebContentsDelegate methods |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 | 579 |
| 575 bool RegisterContentViewClient(JNIEnv* env) { | 580 bool RegisterContentViewClient(JNIEnv* env) { |
| 576 if (!HasClass(env, kContentViewClientClassPath)) { | 581 if (!HasClass(env, kContentViewClientClassPath)) { |
| 577 DLOG(ERROR) << "Unable to find class ContentViewClient!"; | 582 DLOG(ERROR) << "Unable to find class ContentViewClient!"; |
| 578 return false; | 583 return false; |
| 579 } | 584 } |
| 580 return RegisterNativesImpl(env); | 585 return RegisterNativesImpl(env); |
| 581 } | 586 } |
| 582 | 587 |
| 583 } // namespace content | 588 } // namespace content |
| OLD | NEW |