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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 } | 279 } |
280 | 280 |
281 jlong AwContents::GetWebContents(JNIEnv* env, jobject obj) { | 281 jlong AwContents::GetWebContents(JNIEnv* env, jobject obj) { |
282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
283 DCHECK(web_contents_); | 283 DCHECK(web_contents_); |
284 return reinterpret_cast<intptr_t>(web_contents_.get()); | 284 return reinterpret_cast<intptr_t>(web_contents_.get()); |
285 } | 285 } |
286 | 286 |
287 void AwContents::Destroy(JNIEnv* env, jobject obj) { | 287 void AwContents::Destroy(JNIEnv* env, jobject obj) { |
288 java_ref_.reset(); | 288 java_ref_.reset(); |
289 | 289 delete this; |
290 // We clear the contents_client_bridge_ here so that we break the link with | |
291 // the java peer. This is important for the popup window case, where we are | |
292 // swapping AwContents out that share the same java AwContentsClientBridge. | |
293 // See b/15074651. | |
294 AwContentsClientBridgeBase::Disassociate(web_contents_.get()); | |
295 contents_client_bridge_.reset(); | |
296 | |
297 // Do not wait until the WebContents are deleted asynchronously to clear | |
298 // the delegate and stop sending callbacks. | |
299 web_contents_->SetDelegate(NULL); | |
300 | |
301 // We do not delete AwContents immediately. Some applications try to delete | |
302 // Webview in ShouldOverrideUrlLoading callback, which is a sync IPC from | |
303 // Webkit. | |
304 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); | |
305 } | 290 } |
306 | 291 |
307 static jlong Init(JNIEnv* env, jclass, jobject browser_context) { | 292 static jlong Init(JNIEnv* env, jclass, jobject browser_context) { |
308 // TODO(joth): Use |browser_context| to get the native BrowserContext, rather | 293 // TODO(joth): Use |browser_context| to get the native BrowserContext, rather |
309 // than hard-code the default instance lookup here. | 294 // than hard-code the default instance lookup here. |
310 scoped_ptr<WebContents> web_contents(content::WebContents::Create( | 295 scoped_ptr<WebContents> web_contents(content::WebContents::Create( |
311 content::WebContents::CreateParams(AwBrowserContext::GetDefault()))); | 296 content::WebContents::CreateParams(AwBrowserContext::GetDefault()))); |
312 // Return an 'uninitialized' instance; most work is deferred until the | 297 // Return an 'uninitialized' instance; most work is deferred until the |
313 // subsequent SetJavaPeers() call. | 298 // subsequent SetJavaPeers() call. |
314 return reinterpret_cast<intptr_t>(new AwContents(web_contents.Pass())); | 299 return reinterpret_cast<intptr_t>(new AwContents(web_contents.Pass())); |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 } | 1062 } |
1078 | 1063 |
1079 browser_view_renderer_.TrimMemory(level, visible); | 1064 browser_view_renderer_.TrimMemory(level, visible); |
1080 } | 1065 } |
1081 | 1066 |
1082 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { | 1067 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { |
1083 g_should_download_favicons = true; | 1068 g_should_download_favicons = true; |
1084 } | 1069 } |
1085 | 1070 |
1086 } // namespace android_webview | 1071 } // namespace android_webview |
OLD | NEW |