| 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 "android_webview/native/aw_contents_io_thread_client_impl.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 const gfx::Rect& initial_rect, | 136 const gfx::Rect& initial_rect, |
| 137 bool user_gesture, | 137 bool user_gesture, |
| 138 bool* was_blocked) { | 138 bool* was_blocked) { |
| 139 JNIEnv* env = AttachCurrentThread(); | 139 JNIEnv* env = AttachCurrentThread(); |
| 140 | 140 |
| 141 bool is_dialog = disposition == NEW_POPUP; | 141 bool is_dialog = disposition == NEW_POPUP; |
| 142 ScopedJavaLocalRef<jobject> java_delegate = GetJavaDelegate(env); | 142 ScopedJavaLocalRef<jobject> java_delegate = GetJavaDelegate(env); |
| 143 bool create_popup = false; | 143 bool create_popup = false; |
| 144 | 144 |
| 145 if (java_delegate.obj()) { | 145 if (java_delegate.obj()) { |
| 146 create_popup = Java_AwWebContentsDelegate_addNewContents(env, | 146 create_popup = Java_AwWebContentsDelegate_addNewContents( |
| 147 java_delegate.obj(), is_dialog, user_gesture); | 147 env, java_delegate, is_dialog, user_gesture); |
| 148 } | 148 } |
| 149 | 149 |
| 150 if (create_popup) { | 150 if (create_popup) { |
| 151 // The embedder would like to display the popup and we will receive | 151 // The embedder would like to display the popup and we will receive |
| 152 // a callback from them later with an AwContents to use to display | 152 // a callback from them later with an AwContents to use to display |
| 153 // it. The source AwContents takes ownership of the new WebContents | 153 // it. The source AwContents takes ownership of the new WebContents |
| 154 // until then, and when the callback is made we will swap the WebContents | 154 // until then, and when the callback is made we will swap the WebContents |
| 155 // out into the new AwContents. | 155 // out into the new AwContents. |
| 156 AwContents::FromWebContents(source)->SetPendingWebContentsForPopup( | 156 AwContents::FromWebContents(source)->SetPendingWebContentsForPopup( |
| 157 base::WrapUnique(new_contents)); | 157 base::WrapUnique(new_contents)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 void AwWebContentsDelegate::NavigationStateChanged( | 174 void AwWebContentsDelegate::NavigationStateChanged( |
| 175 content::WebContents* source, | 175 content::WebContents* source, |
| 176 content::InvalidateTypes changed_flags) { | 176 content::InvalidateTypes changed_flags) { |
| 177 JNIEnv* env = AttachCurrentThread(); | 177 JNIEnv* env = AttachCurrentThread(); |
| 178 | 178 |
| 179 ScopedJavaLocalRef<jobject> java_delegate = GetJavaDelegate(env); | 179 ScopedJavaLocalRef<jobject> java_delegate = GetJavaDelegate(env); |
| 180 if (java_delegate.obj()) { | 180 if (java_delegate.obj()) { |
| 181 Java_AwWebContentsDelegate_navigationStateChanged(env, java_delegate.obj(), | 181 Java_AwWebContentsDelegate_navigationStateChanged(env, java_delegate, |
| 182 changed_flags); | 182 changed_flags); |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 | 185 |
| 186 // Notifies the delegate about the creation of a new WebContents. This | 186 // Notifies the delegate about the creation of a new WebContents. This |
| 187 // typically happens when popups are created. | 187 // typically happens when popups are created. |
| 188 void AwWebContentsDelegate::WebContentsCreated( | 188 void AwWebContentsDelegate::WebContentsCreated( |
| 189 WebContents* source_contents, | 189 WebContents* source_contents, |
| 190 int opener_render_frame_id, | 190 int opener_render_frame_id, |
| 191 const std::string& frame_name, | 191 const std::string& frame_name, |
| 192 const GURL& target_url, | 192 const GURL& target_url, |
| 193 content::WebContents* new_contents) { | 193 content::WebContents* new_contents) { |
| 194 AwContentsIoThreadClientImpl::RegisterPendingContents(new_contents); | 194 AwContentsIoThreadClientImpl::RegisterPendingContents(new_contents); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void AwWebContentsDelegate::CloseContents(WebContents* source) { | 197 void AwWebContentsDelegate::CloseContents(WebContents* source) { |
| 198 JNIEnv* env = AttachCurrentThread(); | 198 JNIEnv* env = AttachCurrentThread(); |
| 199 | 199 |
| 200 ScopedJavaLocalRef<jobject> java_delegate = GetJavaDelegate(env); | 200 ScopedJavaLocalRef<jobject> java_delegate = GetJavaDelegate(env); |
| 201 if (java_delegate.obj()) { | 201 if (java_delegate.obj()) { |
| 202 Java_AwWebContentsDelegate_closeContents(env, java_delegate.obj()); | 202 Java_AwWebContentsDelegate_closeContents(env, java_delegate); |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 void AwWebContentsDelegate::ActivateContents(WebContents* contents) { | 206 void AwWebContentsDelegate::ActivateContents(WebContents* contents) { |
| 207 JNIEnv* env = AttachCurrentThread(); | 207 JNIEnv* env = AttachCurrentThread(); |
| 208 | 208 |
| 209 ScopedJavaLocalRef<jobject> java_delegate = GetJavaDelegate(env); | 209 ScopedJavaLocalRef<jobject> java_delegate = GetJavaDelegate(env); |
| 210 if (java_delegate.obj()) { | 210 if (java_delegate.obj()) { |
| 211 Java_AwWebContentsDelegate_activateContents(env, java_delegate.obj()); | 211 Java_AwWebContentsDelegate_activateContents(env, java_delegate); |
| 212 } | 212 } |
| 213 } | 213 } |
| 214 | 214 |
| 215 void AwWebContentsDelegate::LoadingStateChanged(WebContents* source, | 215 void AwWebContentsDelegate::LoadingStateChanged(WebContents* source, |
| 216 bool to_different_document) { | 216 bool to_different_document) { |
| 217 // Page title may have changed, need to inform the embedder. | 217 // Page title may have changed, need to inform the embedder. |
| 218 // |source| may be null if loading has started. | 218 // |source| may be null if loading has started. |
| 219 JNIEnv* env = AttachCurrentThread(); | 219 JNIEnv* env = AttachCurrentThread(); |
| 220 | 220 |
| 221 ScopedJavaLocalRef<jobject> java_delegate = GetJavaDelegate(env); | 221 ScopedJavaLocalRef<jobject> java_delegate = GetJavaDelegate(env); |
| 222 if (java_delegate.obj()) { | 222 if (java_delegate.obj()) { |
| 223 Java_AwWebContentsDelegate_loadingStateChanged(env, java_delegate.obj()); | 223 Java_AwWebContentsDelegate_loadingStateChanged(env, java_delegate); |
| 224 } | 224 } |
| 225 } | 225 } |
| 226 | 226 |
| 227 bool AwWebContentsDelegate::ShouldResumeRequestsForCreatedWindow() { | 227 bool AwWebContentsDelegate::ShouldResumeRequestsForCreatedWindow() { |
| 228 // Always return false here since we need to defer loading the created window | 228 // Always return false here since we need to defer loading the created window |
| 229 // until after we have attached a new delegate to the new webcontents (which | 229 // until after we have attached a new delegate to the new webcontents (which |
| 230 // happens asynchronously). | 230 // happens asynchronously). |
| 231 return false; | 231 return false; |
| 232 } | 232 } |
| 233 | 233 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 DVLOG(0) << "File Chooser result: mode = " << mode | 314 DVLOG(0) << "File Chooser result: mode = " << mode |
| 315 << ", file paths = " << base::JoinString(file_path_str, ":"); | 315 << ", file paths = " << base::JoinString(file_path_str, ":"); |
| 316 rfh->FilesSelectedInChooser(files, mode); | 316 rfh->FilesSelectedInChooser(files, mode); |
| 317 } | 317 } |
| 318 | 318 |
| 319 bool RegisterAwWebContentsDelegate(JNIEnv* env) { | 319 bool RegisterAwWebContentsDelegate(JNIEnv* env) { |
| 320 return RegisterNativesImpl(env); | 320 return RegisterNativesImpl(env); |
| 321 } | 321 } |
| 322 | 322 |
| 323 } // namespace android_webview | 323 } // namespace android_webview |
| OLD | NEW |