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

Side by Side Diff: android_webview/native/android_protocol_handler.cc

Issue 109023011: Do not use CalledByNativeUnchecked (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 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
« no previous file with comments | « android_webview/java/src/org/chromium/android_webview/AndroidProtocolHandler.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "android_webview/native/android_protocol_handler.h" 5 #include "android_webview/native/android_protocol_handler.h"
6 6
7 #include "android_webview/browser/net/android_stream_reader_url_request_job.h" 7 #include "android_webview/browser/net/android_stream_reader_url_request_job.h"
8 #include "android_webview/browser/net/aw_url_request_job_factory.h" 8 #include "android_webview/browser/net/aw_url_request_job_factory.h"
9 #include "android_webview/common/url_constants.h" 9 #include "android_webview/common/url_constants.h"
10 #include "android_webview/native/input_stream_impl.h" 10 #include "android_webview/native/input_stream_impl.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 139
140 // Open the input stream. 140 // Open the input stream.
141 ScopedJavaLocalRef<jstring> jurl = 141 ScopedJavaLocalRef<jstring> jurl =
142 ConvertUTF8ToJavaString(env, url.spec()); 142 ConvertUTF8ToJavaString(env, url.spec());
143 ScopedJavaLocalRef<jobject> stream = 143 ScopedJavaLocalRef<jobject> stream =
144 android_webview::Java_AndroidProtocolHandler_open( 144 android_webview::Java_AndroidProtocolHandler_open(
145 env, 145 env,
146 GetResourceContext(env).obj(), 146 GetResourceContext(env).obj(),
147 jurl.obj()); 147 jurl.obj());
148 148
149 // Check and clear pending exceptions. 149 if (stream.is_null()) {
150 if (ClearException(env) || stream.is_null()) {
151 DLOG(ERROR) << "Unable to open input stream for Android URL"; 150 DLOG(ERROR) << "Unable to open input stream for Android URL";
152 return scoped_ptr<InputStream>(); 151 return scoped_ptr<InputStream>();
153 } 152 }
154 return make_scoped_ptr<InputStream>(new InputStreamImpl(stream)); 153 return make_scoped_ptr<InputStream>(new InputStreamImpl(stream));
155 } 154 }
156 155
157 void AndroidStreamReaderURLRequestJobDelegateImpl::OnInputStreamOpenFailed( 156 void AndroidStreamReaderURLRequestJobDelegateImpl::OnInputStreamOpenFailed(
158 net::URLRequest* request, 157 net::URLRequest* request,
159 bool* restart) { 158 bool* restart) {
160 DCHECK(!HasRequestPreviouslyFailed(request)); 159 DCHECK(!HasRequestPreviouslyFailed(request));
(...skipping 14 matching lines...) Expand all
175 // fail, as the mime type cannot be determined for all supported schemes. 174 // fail, as the mime type cannot be determined for all supported schemes.
176 ScopedJavaLocalRef<jstring> url = 175 ScopedJavaLocalRef<jstring> url =
177 ConvertUTF8ToJavaString(env, request->url().spec()); 176 ConvertUTF8ToJavaString(env, request->url().spec());
178 const InputStreamImpl* stream_impl = 177 const InputStreamImpl* stream_impl =
179 InputStreamImpl::FromInputStream(stream); 178 InputStreamImpl::FromInputStream(stream);
180 ScopedJavaLocalRef<jstring> returned_type = 179 ScopedJavaLocalRef<jstring> returned_type =
181 android_webview::Java_AndroidProtocolHandler_getMimeType( 180 android_webview::Java_AndroidProtocolHandler_getMimeType(
182 env, 181 env,
183 GetResourceContext(env).obj(), 182 GetResourceContext(env).obj(),
184 stream_impl->jobj(), url.obj()); 183 stream_impl->jobj(), url.obj());
185 if (ClearException(env) || returned_type.is_null()) 184 if (returned_type.is_null())
186 return false; 185 return false;
187 186
188 *mime_type = base::android::ConvertJavaStringToUTF8(returned_type); 187 *mime_type = base::android::ConvertJavaStringToUTF8(returned_type);
189 return true; 188 return true;
190 } 189 }
191 190
192 bool AndroidStreamReaderURLRequestJobDelegateImpl::GetCharset( 191 bool AndroidStreamReaderURLRequestJobDelegateImpl::GetCharset(
193 JNIEnv* env, 192 JNIEnv* env,
194 net::URLRequest* request, 193 net::URLRequest* request,
195 android_webview::InputStream* stream, 194 android_webview::InputStream* stream,
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 env, android_webview::kAndroidAssetPath).Release(); 307 env, android_webview::kAndroidAssetPath).Release();
309 } 308 }
310 309
311 static jstring GetAndroidResourcePath(JNIEnv* env, jclass /*clazz*/) { 310 static jstring GetAndroidResourcePath(JNIEnv* env, jclass /*clazz*/) {
312 // OK to release, JNI binding. 311 // OK to release, JNI binding.
313 return ConvertUTF8ToJavaString( 312 return ConvertUTF8ToJavaString(
314 env, android_webview::kAndroidResourcePath).Release(); 313 env, android_webview::kAndroidResourcePath).Release();
315 } 314 }
316 315
317 } // namespace android_webview 316 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/java/src/org/chromium/android_webview/AndroidProtocolHandler.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698