| 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/aw_javascript_dialog_manager.h" | 7 #include "android_webview/browser/aw_javascript_dialog_manager.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_contents_io_thread_client_impl.h" |
| 10 #include "base/android/jni_array.h" | 11 #include "base/android/jni_array.h" |
| 11 #include "base/android/jni_string.h" | 12 #include "base/android/jni_string.h" |
| 12 #include "base/android/scoped_java_ref.h" | 13 #include "base/android/scoped_java_ref.h" |
| 13 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 14 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 16 #include "content/public/browser/render_process_host.h" | 17 #include "content/public/browser/render_process_host.h" |
| 17 #include "content/public/browser/render_view_host.h" | 18 #include "content/public/browser/render_view_host.h" |
| 18 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 19 #include "content/public/common/file_chooser_params.h" | 20 #include "content/public/common/file_chooser_params.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 // DeleteSoon as WebContentsImpl may call methods on |new_contents| | 152 // DeleteSoon as WebContentsImpl may call methods on |new_contents| |
| 152 // after this method returns. | 153 // after this method returns. |
| 153 base::MessageLoop::current()->DeleteSoon(FROM_HERE, new_contents); | 154 base::MessageLoop::current()->DeleteSoon(FROM_HERE, new_contents); |
| 154 } | 155 } |
| 155 | 156 |
| 156 if (was_blocked) { | 157 if (was_blocked) { |
| 157 *was_blocked = !create_popup; | 158 *was_blocked = !create_popup; |
| 158 } | 159 } |
| 159 } | 160 } |
| 160 | 161 |
| 162 // Notifies the delegate about the creation of a new WebContents. This |
| 163 // typically happens when popups are created. |
| 164 void AwWebContentsDelegate::WebContentsCreated( |
| 165 WebContents* source_contents, |
| 166 int64 source_frame_id, |
| 167 const string16& frame_name, |
| 168 const GURL& target_url, |
| 169 content::WebContents* new_contents) { |
| 170 AwContentsIoThreadClientImpl::RegisterPendingContents(new_contents); |
| 171 } |
| 172 |
| 161 void AwWebContentsDelegate::CloseContents(WebContents* source) { | 173 void AwWebContentsDelegate::CloseContents(WebContents* source) { |
| 162 JNIEnv* env = AttachCurrentThread(); | 174 JNIEnv* env = AttachCurrentThread(); |
| 163 | 175 |
| 164 ScopedJavaLocalRef<jobject> java_delegate = GetJavaDelegate(env); | 176 ScopedJavaLocalRef<jobject> java_delegate = GetJavaDelegate(env); |
| 165 if (java_delegate.obj()) { | 177 if (java_delegate.obj()) { |
| 166 Java_AwWebContentsDelegate_closeContents(env, java_delegate.obj()); | 178 Java_AwWebContentsDelegate_closeContents(env, java_delegate.obj()); |
| 167 } | 179 } |
| 168 } | 180 } |
| 169 | 181 |
| 170 void AwWebContentsDelegate::ActivateContents(WebContents* contents) { | 182 void AwWebContentsDelegate::ActivateContents(WebContents* contents) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 DVLOG(0) << "File Chooser result: mode = " << mode | 228 DVLOG(0) << "File Chooser result: mode = " << mode |
| 217 << ", file paths = " << JoinString(file_path_str, ":"); | 229 << ", file paths = " << JoinString(file_path_str, ":"); |
| 218 rvh->FilesSelectedInChooser(files, mode); | 230 rvh->FilesSelectedInChooser(files, mode); |
| 219 } | 231 } |
| 220 | 232 |
| 221 bool RegisterAwWebContentsDelegate(JNIEnv* env) { | 233 bool RegisterAwWebContentsDelegate(JNIEnv* env) { |
| 222 return RegisterNativesImpl(env); | 234 return RegisterNativesImpl(env); |
| 223 } | 235 } |
| 224 | 236 |
| 225 } // namespace android_webview | 237 } // namespace android_webview |
| OLD | NEW |