diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-11 10:16:56 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-11 10:16:56 +0000 |
commit | 5b1e85ac9f00a23a731ddf956ef67faab9656fc5 (patch) | |
tree | 521f801af91ab282b1ca0c4479b3db6a8d32e439 | |
parent | 82110b56b8cd193cdc6b960d75f01b9fcbce6038 (diff) | |
download | chromium_src-5b1e85ac9f00a23a731ddf956ef67faab9656fc5.zip chromium_src-5b1e85ac9f00a23a731ddf956ef67faab9656fc5.tar.gz chromium_src-5b1e85ac9f00a23a731ddf956ef67faab9656fc5.tar.bz2 |
Revert 181666
PlatformAppBrowserTest.ReloadRelaunches crashes on Win and Linux
> Fix issue 174250, crash when reloading packaged app.
>
> When a shell window was closed, it wasn't removed from the registry immediately
> (it was removed in a callback from OnNativeClose, which happens a bit later.)
> This meant that when the app was loaded again, the window was still in the
> registry with a stale pointer to the old extension. ExtensionSettingsHandler
> was tickling this by iterating shell windows on extension load.
>
> BUG=174250
>
> Review URL: https://codereview.chromium.org/12210107
TBR=jeremya@chromium.org
Review URL: https://codereview.chromium.org/12224091
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181673 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/extensions/shell_window_registry.cc | 5 | ||||
-rw-r--r-- | chrome/browser/ui/extensions/shell_window.cc | 22 | ||||
-rw-r--r-- | chrome/browser/ui/extensions/shell_window.h | 5 |
3 files changed, 6 insertions, 26 deletions
diff --git a/chrome/browser/extensions/shell_window_registry.cc b/chrome/browser/extensions/shell_window_registry.cc index 4f7a873..f7495f8 100644 --- a/chrome/browser/extensions/shell_window_registry.cc +++ b/chrome/browser/extensions/shell_window_registry.cc @@ -67,9 +67,8 @@ void ShellWindowRegistry::ShellWindowIconChanged(ShellWindow* shell_window) { } void ShellWindowRegistry::RemoveShellWindow(ShellWindow* shell_window) { - size_t num_erased = shell_windows_.erase(shell_window); - if (num_erased > 0) - FOR_EACH_OBSERVER(Observer, observers_, OnShellWindowRemoved(shell_window)); + shell_windows_.erase(shell_window); + FOR_EACH_OBSERVER(Observer, observers_, OnShellWindowRemoved(shell_window)); } void ShellWindowRegistry::AddObserver(Observer* observer) { diff --git a/chrome/browser/ui/extensions/shell_window.cc b/chrome/browser/ui/extensions/shell_window.cc index 9e25302..cc6972f 100644 --- a/chrome/browser/ui/extensions/shell_window.cc +++ b/chrome/browser/ui/extensions/shell_window.cc @@ -249,11 +249,6 @@ ShellWindow::~ShellWindow() { chrome::EndKeepAlive(); } -void ShellWindow::Close() { - extensions::ShellWindowRegistry::Get(profile_)->RemoveShellWindow(this); - native_app_window_->Close(); -} - void ShellWindow::RequestMediaAccessPermission( content::WebContents* web_contents, const content::MediaStreamRequest& request, @@ -353,11 +348,6 @@ void ShellWindow::RequestToLockMouse(WebContents* web_contents, } void ShellWindow::OnNativeClose() { - // This method is shared between the path for the user clicking the close - // button and the path where a close is triggered by code (e.g. by the - // extension being unloaded). In the latter case, this RemoveShellWindow is - // superfluous, since it will already have been removed, but the call is - // idempotent so it's harmless the second time. extensions::ShellWindowRegistry::Get(profile_)->RemoveShellWindow(this); content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); rvh->Send(new ExtensionMsg_AppWindowClosed(rvh->GetRoutingID())); @@ -502,7 +492,7 @@ void ShellWindow::UpdateExtensionAppIcon() { void ShellWindow::CloseContents(WebContents* contents) { DCHECK(contents == web_contents_); - Close(); + native_app_window_->Close(); } bool ShellWindow::ShouldSuppressDialogs() { @@ -592,16 +582,12 @@ void ShellWindow::Observe(int type, const extensions::Extension* unloaded_extension = content::Details<extensions::UnloadedExtensionInfo>( details)->extension; - if (extension_ == unloaded_extension) { - Close(); - // After this notification finishes processing, the Extension will be - // deleted, so we null out our reference to avoid bad access. - extension_ = NULL; - } + if (extension_ == unloaded_extension) + native_app_window_->Close(); break; } case chrome::NOTIFICATION_APP_TERMINATING: - Close(); + native_app_window_->Close(); break; default: NOTREACHED() << "Received unexpected notification"; diff --git a/chrome/browser/ui/extensions/shell_window.h b/chrome/browser/ui/extensions/shell_window.h index ee6e234..a996ed3 100644 --- a/chrome/browser/ui/extensions/shell_window.h +++ b/chrome/browser/ui/extensions/shell_window.h @@ -133,11 +133,6 @@ class ShellWindow : public content::NotificationObserver, // per platform). Public users of ShellWindow should use ShellWindow::Create. void Init(const GURL& url, const CreateParams& params); - // Remove the window from the ShellWindowRegistry and tell the native - // window to close. The native window won't be actually closed until - // OnNativeClose(). - void Close(); - // content::WebContentsObserver implementation. virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |