Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2208)

Unified Diff: apps/shell_window.cc

Issue 20243003: Fix crash when reloading packaged app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to after mac app shim fix Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « apps/shell_window.h ('k') | chrome/browser/extensions/platform_app_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/shell_window.cc
diff --git a/apps/shell_window.cc b/apps/shell_window.cc
index d0dd9cc0c05de467155ba9aea376cfc8b0b678a1..4f8bd4222043c5fa9207e91bfdac0175666cd0ee 100644
--- a/apps/shell_window.cc
+++ b/apps/shell_window.cc
@@ -280,9 +280,15 @@ void ShellWindow::RequestToLockMouse(WebContents* web_contents,
}
void ShellWindow::OnNativeClose() {
- extensions::ShellWindowRegistry::Get(profile_)->RemoveShellWindow(this);
- if (shell_window_contents_)
- shell_window_contents_->NativeWindowClosed();
+ if (extension_) {
+ // If |extension_| is NULL here, it is because the extension has been
+ // unloaded. In this case, the window will have already been removed from
+ // the ShellWindowRegistry, and the app can not be informed of the window
+ // closing as it has gone.
+ extensions::ShellWindowRegistry::Get(profile_)->RemoveShellWindow(this);
+ if (shell_window_contents_)
+ shell_window_contents_->NativeWindowClosed();
+ }
delete this;
}
@@ -447,7 +453,7 @@ void ShellWindow::UpdateExtensionAppIcon() {
}
void ShellWindow::CloseContents(WebContents* contents) {
- native_app_window_->Close();
+ Close();
}
bool ShellWindow::ShouldSuppressDialogs() {
@@ -526,12 +532,16 @@ void ShellWindow::Observe(int type,
const extensions::Extension* unloaded_extension =
content::Details<extensions::UnloadedExtensionInfo>(
details)->extension;
- if (extension_ == unloaded_extension)
- native_app_window_->Close();
+ 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;
+ }
break;
}
case chrome::NOTIFICATION_APP_TERMINATING:
- native_app_window_->Close();
+ Close();
break;
default:
NOTREACHED() << "Received unexpected notification";
@@ -557,6 +567,11 @@ WebContentsModalDialogHost* ShellWindow::GetWebContentsModalDialogHost() {
return native_app_window_.get();
}
+void ShellWindow::Close() {
+ extensions::ShellWindowRegistry::Get(profile_)->RemoveShellWindow(this);
+ native_app_window_->Close();
+}
+
void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level,
const std::string& message) {
content::RenderViewHost* rvh = web_contents()->GetRenderViewHost();
« no previous file with comments | « apps/shell_window.h ('k') | chrome/browser/extensions/platform_app_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698