From: Cheng Zhao Date: Tue, 17 May 2016 12:49:05 +0000 (+0900) Subject: Make sure BrowserContext is always destroyed after WebContents X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=118afab67b0b28b8962abafa838684d71a013013;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Make sure BrowserContext is always destroyed after WebContents --- diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 8761482..e3d7c1f 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -274,7 +274,7 @@ WebContents::WebContents(v8::Isolate* isolate, } Observe(web_contents); - InitWithWebContents(web_contents); + InitWithWebContents(web_contents, session->browser_context()); managed_web_contents()->GetView()->SetDelegate(this); @@ -397,7 +397,7 @@ void WebContents::HandleKeyboardEvent( if (event.windowsKeyCode == ui::VKEY_ESCAPE && is_html_fullscreen()) { // Escape exits tabbed fullscreen mode. ExitFullscreenModeForTab(source); - } else if (type_ == BROWSER_WINDOW) { + } else if (type_ == BROWSER_WINDOW && owner_window()) { owner_window()->HandleKeyboardEvent(source, event); } else if (type_ == WEB_VIEW && guest_delegate_) { // Send the unhandled keyboard events back to the embedder. diff --git a/atom/browser/common_web_contents_delegate.cc b/atom/browser/common_web_contents_delegate.cc index 2093b8f..d4b3f18 100644 --- a/atom/browser/common_web_contents_delegate.cc +++ b/atom/browser/common_web_contents_delegate.cc @@ -182,7 +182,9 @@ CommonWebContentsDelegate::~CommonWebContentsDelegate() { } void CommonWebContentsDelegate::InitWithWebContents( - content::WebContents* web_contents) { + content::WebContents* web_contents, + AtomBrowserContext* browser_context) { + browser_context_ = browser_context; web_contents->SetDelegate(this); printing::PrintViewManagerBasic::CreateForWebContents(web_contents); diff --git a/atom/browser/common_web_contents_delegate.h b/atom/browser/common_web_contents_delegate.h index dbd5dde..8ea04af 100644 --- a/atom/browser/common_web_contents_delegate.h +++ b/atom/browser/common_web_contents_delegate.h @@ -19,6 +19,7 @@ using brightray::DevToolsFileSystemIndexer; namespace atom { +class AtomBrowserContext; class AtomJavaScriptDialogManager; class NativeWindow; class WebDialogHelper; @@ -33,7 +34,8 @@ class CommonWebContentsDelegate // Creates a InspectableWebContents object and takes onwership of // |web_contents|. - void InitWithWebContents(content::WebContents* web_contents); + void InitWithWebContents(content::WebContents* web_contents, + AtomBrowserContext* browser_context); // Set the window as owner window. void SetOwnerWindow(NativeWindow* owner_window); @@ -145,6 +147,9 @@ class CommonWebContentsDelegate scoped_ptr dialog_manager_; scoped_refptr devtools_file_system_indexer_; + // Make sure BrowserContext is alwasys destroyed after WebContents. + scoped_refptr browser_context_; + // The stored InspectableWebContents object. // Notice that web_contents_ must be placed after dialog_manager_, so we can // make sure web_contents_ is destroyed before dialog_manager_, otherwise a