OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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.h" | 5 #include "android_webview/native/aw_contents.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "android_webview/browser/aw_browser_context.h" | 9 #include "android_webview/browser/aw_browser_context.h" |
10 #include "android_webview/browser/aw_browser_main_parts.h" | 10 #include "android_webview/browser/aw_browser_main_parts.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
281 } | 281 } |
282 | 282 |
283 jlong AwContents::GetWebContents(JNIEnv* env, jobject obj) { | 283 jlong AwContents::GetWebContents(JNIEnv* env, jobject obj) { |
284 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 284 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
285 DCHECK(web_contents_); | 285 DCHECK(web_contents_); |
286 return reinterpret_cast<intptr_t>(web_contents_.get()); | 286 return reinterpret_cast<intptr_t>(web_contents_.get()); |
287 } | 287 } |
288 | 288 |
289 void AwContents::Destroy(JNIEnv* env, jobject obj) { | 289 void AwContents::Destroy(JNIEnv* env, jobject obj) { |
290 java_ref_.reset(); | 290 java_ref_.reset(); |
291 | 291 delete this; |
292 // We clear the contents_client_bridge_ here so that we break the link with | |
293 // the java peer. This is important for the popup window case, where we are | |
294 // swapping AwContents out that share the same java AwContentsClientBridge. | |
295 // See b/15074651. | |
benm (inactive)
2014/10/29 14:56:15
Can you check the repro case from this internal bu
boliu
2014/10/29 15:14:33
Will do. I'll let you the result afterwards.
boliu
2014/10/29 18:51:59
Not conclusive :(
Nothing appeared wrong when I f
| |
296 AwContentsClientBridgeBase::Disassociate(web_contents_.get()); | |
297 contents_client_bridge_.reset(); | |
298 | |
299 // Do not wait until the WebContents are deleted asynchronously to clear | |
300 // the delegate and stop sending callbacks. | |
301 web_contents_->SetDelegate(NULL); | |
302 | |
303 // We do not delete AwContents immediately. Some applications try to delete | |
304 // Webview in ShouldOverrideUrlLoading callback, which is a sync IPC from | |
305 // Webkit. | |
306 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); | |
sgurun-gerrit only
2014/10/31 19:01:43
Have you tried the condition here? Does it work fi
boliu
2014/10/31 19:49:01
Not sure what you are asking here. What condition?
hush (inactive)
2014/10/31 20:58:16
Will an app that calls WebView#destroy() in Should
boliu
2014/10/31 21:47:05
I think it's pretty obvious it will work. Will add
| |
307 } | 292 } |
308 | 293 |
309 static jlong Init(JNIEnv* env, jclass, jobject browser_context) { | 294 static jlong Init(JNIEnv* env, jclass, jobject browser_context) { |
310 // TODO(joth): Use |browser_context| to get the native BrowserContext, rather | 295 // TODO(joth): Use |browser_context| to get the native BrowserContext, rather |
311 // than hard-code the default instance lookup here. | 296 // than hard-code the default instance lookup here. |
312 scoped_ptr<WebContents> web_contents(content::WebContents::Create( | 297 scoped_ptr<WebContents> web_contents(content::WebContents::Create( |
313 content::WebContents::CreateParams(AwBrowserContext::GetDefault()))); | 298 content::WebContents::CreateParams(AwBrowserContext::GetDefault()))); |
314 // Return an 'uninitialized' instance; most work is deferred until the | 299 // Return an 'uninitialized' instance; most work is deferred until the |
315 // subsequent SetJavaPeers() call. | 300 // subsequent SetJavaPeers() call. |
316 return reinterpret_cast<intptr_t>(new AwContents(web_contents.Pass())); | 301 return reinterpret_cast<intptr_t>(new AwContents(web_contents.Pass())); |
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1169 } | 1154 } |
1170 | 1155 |
1171 browser_view_renderer_.TrimMemory(level, visible); | 1156 browser_view_renderer_.TrimMemory(level, visible); |
1172 } | 1157 } |
1173 | 1158 |
1174 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { | 1159 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { |
1175 g_should_download_favicons = true; | 1160 g_should_download_favicons = true; |
1176 } | 1161 } |
1177 | 1162 |
1178 } // namespace android_webview | 1163 } // namespace android_webview |
OLD | NEW |