| 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 "android_webview/native/aw_web_contents_delegate.h" | 5 #include "android_webview/native/aw_web_contents_delegate.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/find_helper.h" | 7 #include "android_webview/browser/find_helper.h" |
| 8 #include "android_webview/native/aw_contents.h" | 8 #include "android_webview/native/aw_contents.h" |
| 9 #include "android_webview/native/aw_javascript_dialog_creator.h" | 9 #include "android_webview/native/aw_javascript_dialog_creator.h" |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "content/public/browser/android/download_controller_android.h" | |
| 14 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 15 #include "jni/AwWebContentsDelegate_jni.h" | 14 #include "jni/AwWebContentsDelegate_jni.h" |
| 16 #include "net/http/http_request_headers.h" | |
| 17 | 15 |
| 18 using base::android::AttachCurrentThread; | 16 using base::android::AttachCurrentThread; |
| 19 using base::android::ScopedJavaLocalRef; | 17 using base::android::ScopedJavaLocalRef; |
| 20 using content::WebContents; | 18 using content::WebContents; |
| 21 | 19 |
| 22 namespace android_webview { | 20 namespace android_webview { |
| 23 | 21 |
| 24 static base::LazyInstance<AwJavaScriptDialogCreator>::Leaky | 22 static base::LazyInstance<AwJavaScriptDialogCreator>::Leaky |
| 25 g_javascript_dialog_creator = LAZY_INSTANCE_INITIALIZER; | 23 g_javascript_dialog_creator = LAZY_INSTANCE_INITIALIZER; |
| 26 | 24 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 50 | 48 |
| 51 aw_contents->GetFindHelper()->HandleFindReply(request_id, | 49 aw_contents->GetFindHelper()->HandleFindReply(request_id, |
| 52 number_of_matches, | 50 number_of_matches, |
| 53 active_match_ordinal, | 51 active_match_ordinal, |
| 54 final_update); | 52 final_update); |
| 55 } | 53 } |
| 56 | 54 |
| 57 bool AwWebContentsDelegate::CanDownload(content::RenderViewHost* source, | 55 bool AwWebContentsDelegate::CanDownload(content::RenderViewHost* source, |
| 58 int request_id, | 56 int request_id, |
| 59 const std::string& request_method) { | 57 const std::string& request_method) { |
| 60 if (request_method == net::HttpRequestHeaders::kGetMethod) { | 58 // Android webview intercepts download in its resource dispatcher host |
| 61 content::DownloadControllerAndroid::Get()->CreateGETDownload( | 59 // delegate, so should not reach here. |
| 62 source, request_id); | 60 NOTREACHED(); |
| 63 } | |
| 64 return false; | 61 return false; |
| 65 } | 62 } |
| 66 | 63 |
| 67 void AwWebContentsDelegate::OnStartDownload(WebContents* source, | 64 void AwWebContentsDelegate::OnStartDownload(WebContents* source, |
| 68 content::DownloadItem* download) { | 65 content::DownloadItem* download) { |
| 69 NOTREACHED(); // We always return false in CanDownload. | 66 NOTREACHED(); // Downloads are cancelled in ResourceDispatcherHostDelegate. |
| 70 } | 67 } |
| 71 | 68 |
| 72 void AwWebContentsDelegate::AddNewContents(content::WebContents* source, | 69 void AwWebContentsDelegate::AddNewContents(content::WebContents* source, |
| 73 content::WebContents* new_contents, | 70 content::WebContents* new_contents, |
| 74 WindowOpenDisposition disposition, | 71 WindowOpenDisposition disposition, |
| 75 const gfx::Rect& initial_pos, | 72 const gfx::Rect& initial_pos, |
| 76 bool user_gesture, | 73 bool user_gesture, |
| 77 bool* was_blocked) { | 74 bool* was_blocked) { |
| 78 JNIEnv* env = AttachCurrentThread(); | 75 JNIEnv* env = AttachCurrentThread(); |
| 79 | 76 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 if (java_delegate.obj()) { | 123 if (java_delegate.obj()) { |
| 127 Java_AwWebContentsDelegate_activateContents(env, java_delegate.obj()); | 124 Java_AwWebContentsDelegate_activateContents(env, java_delegate.obj()); |
| 128 } | 125 } |
| 129 } | 126 } |
| 130 | 127 |
| 131 bool RegisterAwWebContentsDelegate(JNIEnv* env) { | 128 bool RegisterAwWebContentsDelegate(JNIEnv* env) { |
| 132 return RegisterNativesImpl(env); | 129 return RegisterNativesImpl(env); |
| 133 } | 130 } |
| 134 | 131 |
| 135 } // namespace android_webview | 132 } // namespace android_webview |
| OLD | NEW |