| 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 "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "android_webview/browser/find_helper.h" | 8 #include "android_webview/browser/find_helper.h" |
| 9 #include "android_webview/native/aw_contents.h" | 9 #include "android_webview/native/aw_contents.h" |
| 10 #include "android_webview/native/aw_javascript_dialog_creator.h" | 10 #include "android_webview/native/aw_javascript_dialog_creator.h" |
| 11 #include "content/public/browser/android/download_controller_android.h" | 11 #include "content/public/browser/android/download_controller_android.h" |
| 12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
| 13 #include "jni/AwWebContentsDelegate_jni.h" |
| 13 #include "net/http/http_request_headers.h" | 14 #include "net/http/http_request_headers.h" |
| 14 | 15 |
| 16 using base::android::AttachCurrentThread; |
| 15 using content::WebContents; | 17 using content::WebContents; |
| 16 | 18 |
| 17 namespace android_webview { | 19 namespace android_webview { |
| 18 | 20 |
| 19 static base::LazyInstance<AwJavaScriptDialogCreator>::Leaky | 21 static base::LazyInstance<AwJavaScriptDialogCreator>::Leaky |
| 20 g_javascript_dialog_creator = LAZY_INSTANCE_INITIALIZER; | 22 g_javascript_dialog_creator = LAZY_INSTANCE_INITIALIZER; |
| 21 | 23 |
| 22 AwWebContentsDelegate::AwWebContentsDelegate( | 24 AwWebContentsDelegate::AwWebContentsDelegate( |
| 23 JNIEnv* env, | 25 JNIEnv* env, |
| 24 jobject obj) | 26 jobject obj) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 source, request_id); | 59 source, request_id); |
| 58 } | 60 } |
| 59 return false; | 61 return false; |
| 60 } | 62 } |
| 61 | 63 |
| 62 void AwWebContentsDelegate::OnStartDownload(WebContents* source, | 64 void AwWebContentsDelegate::OnStartDownload(WebContents* source, |
| 63 content::DownloadItem* download) { | 65 content::DownloadItem* download) { |
| 64 NOTREACHED(); // We always return false in CanDownload. | 66 NOTREACHED(); // We always return false in CanDownload. |
| 65 } | 67 } |
| 66 | 68 |
| 69 void AwWebContentsDelegate::AddNewContents(content::WebContents* source, |
| 70 content::WebContents* new_contents, |
| 71 WindowOpenDisposition disposition, |
| 72 const gfx::Rect& initial_pos, |
| 73 bool user_gesture, |
| 74 bool* was_blocked) { |
| 75 JNIEnv* env = AttachCurrentThread(); |
| 76 |
| 77 bool is_dialog = disposition == NEW_POPUP; |
| 78 bool create_popup = Java_AwWebContentsDelegate_addNewContents(env, |
| 79 GetJavaDelegate(env).obj(), is_dialog, user_gesture); |
| 80 |
| 81 if (create_popup) { |
| 82 // TODO(benm): Implement, taking ownership of new_contents. |
| 83 NOTIMPLEMENTED() << "Popup windows are currently not supported for" |
| 84 << "the chromium powered Android WebView."; |
| 85 } else { |
| 86 // The embedder has forgone their chance to display this popup |
| 87 // window, so we're done with the WebContents now. |
| 88 delete new_contents; |
| 89 } |
| 90 |
| 91 if (was_blocked) { |
| 92 *was_blocked = !create_popup; |
| 93 } |
| 94 } |
| 95 |
| 96 bool RegisterAwWebContentsDelegate(JNIEnv* env) { |
| 97 return RegisterNativesImpl(env); |
| 98 } |
| 99 |
| 67 } // namespace android_webview | 100 } // namespace android_webview |
| OLD | NEW |