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

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

Issue 10907166: Upstream chromium side of modal dialogs for webview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
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/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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 114
115 void ContentViewClient::OnInterstitialHidden() { 115 void ContentViewClient::OnInterstitialHidden() {
116 JNIEnv* env = AttachCurrentThread(); 116 JNIEnv* env = AttachCurrentThread();
117 ScopedJavaLocalRef<jobject> obj = weak_java_client_.get(env); 117 ScopedJavaLocalRef<jobject> obj = weak_java_client_.get(env);
118 if (obj.is_null()) 118 if (obj.is_null())
119 return; 119 return;
120 Java_ContentViewClient_onInterstitialHidden(env, obj.obj()); 120 Java_ContentViewClient_onInterstitialHidden(env, obj.obj());
121 } 121 }
122 122
123 bool ContentViewClient::OnJSModalDialog(JavaScriptMessageType type,
124 bool is_before_unload_dialog,
125 const GURL& url,
126 const string16& message,
127 const string16& default_value) {
128 JNIEnv* env = AttachCurrentThread();
129 ScopedJavaLocalRef<jobject> obj = weak_java_client_.get(env);
130 if (obj.is_null())
131 return false;
132 ScopedJavaLocalRef<jstring> jurl(ConvertUTF8ToJavaString(env, url.spec()));
133 ScopedJavaLocalRef<jstring> jmessage(ConvertUTF16ToJavaString(env, message));
134
135 // Special case for beforeunload dialogs, as that isn't encoded in the
136 // |type| of the dialog.
137 if (is_before_unload_dialog) {
138 return Java_ContentViewClient_onJsBeforeUnload(
139 env, obj.obj(),
140 jurl.obj(),
141 jmessage.obj());
142 }
143
144 switch (type) {
145 case JAVASCRIPT_MESSAGE_TYPE_ALERT:
146 return Java_ContentViewClient_onJsAlert(env, obj.obj(),
147 jurl.obj(),
148 jmessage.obj());
149
150 case JAVASCRIPT_MESSAGE_TYPE_CONFIRM:
151 return Java_ContentViewClient_onJsConfirm(env, obj.obj(),
152 jurl.obj(),
153 jmessage.obj());
154
155 case JAVASCRIPT_MESSAGE_TYPE_PROMPT: {
156 ScopedJavaLocalRef<jstring> jdefault_value(
157 ConvertUTF16ToJavaString(env, default_value));
158 return Java_ContentViewClient_onJsPrompt(env, obj.obj(),
159 jurl.obj(),
160 jmessage.obj(),
161 jdefault_value.obj());
162 }
163
164 default:
165 NOTREACHED();
166 return false;
167 }
168 }
169
170 ContentViewClientError ContentViewClient::ToContentViewClientError( 123 ContentViewClientError ContentViewClient::ToContentViewClientError(
171 int net_error) { 124 int net_error) {
172 // Note: many net::Error constants don't have an obvious mapping. 125 // Note: many net::Error constants don't have an obvious mapping.
173 // These will be handled by the default case, ERROR_UNKNOWN. 126 // These will be handled by the default case, ERROR_UNKNOWN.
174 switch(net_error) { 127 switch(net_error) {
175 case net::ERR_UNSUPPORTED_AUTH_SCHEME: 128 case net::ERR_UNSUPPORTED_AUTH_SCHEME:
176 return CONTENT_VIEW_CLIENT_ERROR_UNSUPPORTED_AUTH_SCHEME; 129 return CONTENT_VIEW_CLIENT_ERROR_UNSUPPORTED_AUTH_SCHEME;
177 130
178 case net::ERR_INVALID_AUTH_CREDENTIALS: 131 case net::ERR_INVALID_AUTH_CREDENTIALS:
179 case net::ERR_MISSING_AUTH_CREDENTIALS: 132 case net::ERR_MISSING_AUTH_CREDENTIALS:
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 231
279 bool RegisterContentViewClient(JNIEnv* env) { 232 bool RegisterContentViewClient(JNIEnv* env) {
280 if (!HasClass(env, kContentViewClientClassPath)) { 233 if (!HasClass(env, kContentViewClientClassPath)) {
281 DLOG(ERROR) << "Unable to find class ContentViewClient!"; 234 DLOG(ERROR) << "Unable to find class ContentViewClient!";
282 return false; 235 return false;
283 } 236 }
284 return RegisterNativesImpl(env); 237 return RegisterNativesImpl(env);
285 } 238 }
286 239
287 } // namespace content 240 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698