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

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

Issue 12620004: [android_webview] Fake onReceivedError callback for intercepted navigations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make findbugs happy Created 7 years, 9 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 "android_webview/native/aw_contents_io_thread_client_impl.h" 5 #include "android_webview/native/aw_contents_io_thread_client_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <utility> 8 #include <utility>
9 9
10 #include "android_webview/native/intercepted_request_data_impl.h" 10 #include "android_webview/native/intercepted_request_data_impl.h"
11 #include "base/android/jni_helper.h" 11 #include "base/android/jni_helper.h"
12 #include "base/android/jni_string.h" 12 #include "base/android/jni_string.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/memory/linked_ptr.h" 14 #include "base/memory/linked_ptr.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/render_process_host.h" 18 #include "content/public/browser/render_process_host.h"
19 #include "content/public/browser/render_view_host.h" 19 #include "content/public/browser/render_view_host.h"
20 #include "content/public/browser/resource_request_info.h"
20 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
21 #include "content/public/browser/web_contents_observer.h" 22 #include "content/public/browser/web_contents_observer.h"
22 #include "googleurl/src/gurl.h" 23 #include "googleurl/src/gurl.h"
23 #include "net/url_request/url_request.h" 24 #include "net/url_request/url_request.h"
24 25
25 #include "jni/AwContentsIoThreadClient_jni.h" 26 #include "jni/AwContentsIoThreadClient_jni.h"
26 27
27 using base::android::AttachCurrentThread; 28 using base::android::AttachCurrentThread;
28 using base::android::ConvertUTF8ToJavaString; 29 using base::android::ConvertUTF8ToJavaString;
29 using base::android::JavaRef; 30 using base::android::JavaRef;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 env, java_object_.obj())); 189 env, java_object_.obj()));
189 } 190 }
190 191
191 scoped_ptr<InterceptedRequestData> 192 scoped_ptr<InterceptedRequestData>
192 AwContentsIoThreadClientImpl::ShouldInterceptRequest( 193 AwContentsIoThreadClientImpl::ShouldInterceptRequest(
193 const GURL& location, 194 const GURL& location,
194 const net::URLRequest* request) { 195 const net::URLRequest* request) {
195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
196 if (java_object_.is_null()) 197 if (java_object_.is_null())
197 return scoped_ptr<InterceptedRequestData>(); 198 return scoped_ptr<InterceptedRequestData>();
199 const content::ResourceRequestInfo* info =
200 content::ResourceRequestInfo::ForRequest(request);
201 bool is_main_frame = info && info->IsMainFrame();
198 202
199 JNIEnv* env = AttachCurrentThread(); 203 JNIEnv* env = AttachCurrentThread();
200 ScopedJavaLocalRef<jstring> jstring_url = 204 ScopedJavaLocalRef<jstring> jstring_url =
201 ConvertUTF8ToJavaString(env, location.spec()); 205 ConvertUTF8ToJavaString(env, location.spec());
202 ScopedJavaLocalRef<jobject> ret = 206 ScopedJavaLocalRef<jobject> ret =
203 Java_AwContentsIoThreadClient_shouldInterceptRequest( 207 Java_AwContentsIoThreadClient_shouldInterceptRequest(
204 env, java_object_.obj(), jstring_url.obj()); 208 env, java_object_.obj(), jstring_url.obj(), is_main_frame);
205 if (ret.is_null()) 209 if (ret.is_null())
206 return scoped_ptr<InterceptedRequestData>(); 210 return scoped_ptr<InterceptedRequestData>();
207 return scoped_ptr<InterceptedRequestData>( 211 return scoped_ptr<InterceptedRequestData>(
208 new InterceptedRequestDataImpl(ret)); 212 new InterceptedRequestDataImpl(ret));
209 } 213 }
210 214
211 bool AwContentsIoThreadClientImpl::ShouldBlockContentUrls() const { 215 bool AwContentsIoThreadClientImpl::ShouldBlockContentUrls() const {
212 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 216 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
213 if (java_object_.is_null()) 217 if (java_object_.is_null())
214 return false; 218 return false;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 289
286 Java_AwContentsIoThreadClient_newLoginRequest( 290 Java_AwContentsIoThreadClient_newLoginRequest(
287 env, java_object_.obj(), jrealm.obj(), jaccount.obj(), jargs.obj()); 291 env, java_object_.obj(), jrealm.obj(), jaccount.obj(), jargs.obj());
288 } 292 }
289 293
290 bool RegisterAwContentsIoThreadClientImpl(JNIEnv* env) { 294 bool RegisterAwContentsIoThreadClientImpl(JNIEnv* env) {
291 return RegisterNativesImpl(env); 295 return RegisterNativesImpl(env);
292 } 296 }
293 297
294 } // namespace android_webview 298 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldInterceptRequestTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698