Commit f9ea544b authored by sky@chromium.org's avatar sky@chromium.org

Fixes crash in RemoteWindowTreeHostWin::HandleActivateDesktop

Rather than route this through RemoteWindowTreeHostWin (which can now
be NULL) I'm routing it through ChromeMetroViewerProcessHost. I'm also
adding a NULL check as it may be possible in some code paths for the
host to have been disconnected and therefor NULL.

BUG=374766
TEST=none
R=ananta@chromium.org

Review URL: https://codereview.chromium.org/297713002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271816 0039d316-1c4b-4281-b951-d872f2087c98
parent 7a630519
...@@ -19,11 +19,11 @@ ...@@ -19,11 +19,11 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "chrome/browser/metro_utils/metro_chrome_win.h" #include "chrome/browser/metro_utils/metro_chrome_win.h"
#include "chrome/browser/metro_viewer/chrome_metro_viewer_process_host_aurawin.h"
#include "chrome/browser/shell_integration.h" #include "chrome/browser/shell_integration.h"
#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_constants.h"
#include "chrome/installer/util/util_constants.h" #include "chrome/installer/util/util_constants.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "ui/aura/remote_window_tree_host_win.h"
#endif #endif
namespace chrome { namespace chrome {
...@@ -88,7 +88,7 @@ void ActivateDesktopHelper(AshExecutionStatus ash_execution_status) { ...@@ -88,7 +88,7 @@ void ActivateDesktopHelper(AshExecutionStatus ash_execution_status) {
// Actually launching the process needs to happen in the metro viewer, // Actually launching the process needs to happen in the metro viewer,
// otherwise it won't automatically transition to desktop. So we have // otherwise it won't automatically transition to desktop. So we have
// to send an IPC to the viewer to do the ShellExecute. // to send an IPC to the viewer to do the ShellExecute.
aura::HandleActivateDesktop(path, ash_execution_status == ASH_TERMINATE); HandleActivateDesktop(path, ash_execution_status == ASH_TERMINATE);
} }
#endif #endif
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "ui/aura/remote_window_tree_host_win.h" #include "ui/aura/remote_window_tree_host_win.h"
#include "ui/gfx/win/dpi.h" #include "ui/gfx/win/dpi.h"
#include "ui/metro_viewer/metro_viewer_messages.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace { namespace {
...@@ -66,11 +67,28 @@ void OpenURL(const GURL& url) { ...@@ -66,11 +67,28 @@ void OpenURL(const GURL& url) {
} // namespace } // namespace
void HandleActivateDesktop(const base::FilePath& path, bool ash_exit) {
if (ChromeMetroViewerProcessHost::instance()) {
ChromeMetroViewerProcessHost::instance()->Send(
new MetroViewerHostMsg_ActivateDesktop(path, ash_exit));
}
}
// static
ChromeMetroViewerProcessHost* ChromeMetroViewerProcessHost::instance_ = NULL;
ChromeMetroViewerProcessHost::ChromeMetroViewerProcessHost() ChromeMetroViewerProcessHost::ChromeMetroViewerProcessHost()
: MetroViewerProcessHost( : MetroViewerProcessHost(
content::BrowserThread::GetMessageLoopProxyForThread( content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::IO)) { content::BrowserThread::IO)) {
chrome::IncrementKeepAliveCount(); chrome::IncrementKeepAliveCount();
DCHECK(instance_ == NULL);
instance_ = this;
}
ChromeMetroViewerProcessHost::~ChromeMetroViewerProcessHost() {
DCHECK(instance_ == this);
instance_ = NULL;
} }
void ChromeMetroViewerProcessHost::OnChannelError() { void ChromeMetroViewerProcessHost::OnChannelError() {
......
...@@ -7,9 +7,25 @@ ...@@ -7,9 +7,25 @@
#include "win8/viewer/metro_viewer_process_host.h" #include "win8/viewer/metro_viewer_process_host.h"
namespace base {
class FilePath;
}
// Handles the activate desktop command for Metro Chrome Ash. The |ash_exit|
// parameter indicates whether the Ash process would be shutdown after
// activating the desktop.
void HandleActivateDesktop(const base::FilePath& shortcut, bool ash_exit);
class ChromeMetroViewerProcessHost : public win8::MetroViewerProcessHost { class ChromeMetroViewerProcessHost : public win8::MetroViewerProcessHost {
public: public:
ChromeMetroViewerProcessHost(); ChromeMetroViewerProcessHost();
virtual ~ChromeMetroViewerProcessHost();
// Returns the singleton ChromeMetroViewerProcessHost instance. This may
// return NULL.
static ChromeMetroViewerProcessHost* instance() {
return instance_;
}
private: private:
// win8::MetroViewerProcessHost implementation // win8::MetroViewerProcessHost implementation
...@@ -23,6 +39,8 @@ class ChromeMetroViewerProcessHost : public win8::MetroViewerProcessHost { ...@@ -23,6 +39,8 @@ class ChromeMetroViewerProcessHost : public win8::MetroViewerProcessHost {
const base::string16& search_string) OVERRIDE; const base::string16& search_string) OVERRIDE;
virtual void OnWindowSizeChanged(uint32 width, uint32 height) OVERRIDE; virtual void OnWindowSizeChanged(uint32 width, uint32 height) OVERRIDE;
static ChromeMetroViewerProcessHost* instance_;
DISALLOW_COPY_AND_ASSIGN(ChromeMetroViewerProcessHost); DISALLOW_COPY_AND_ASSIGN(ChromeMetroViewerProcessHost);
}; };
......
...@@ -135,13 +135,6 @@ void HandleSelectFolder(const base::string16& title, ...@@ -135,13 +135,6 @@ void HandleSelectFolder(const base::string16& title,
on_failure); on_failure);
} }
void HandleActivateDesktop(const base::FilePath& shortcut,
bool ash_exit) {
DCHECK(aura::RemoteWindowTreeHostWin::Instance());
aura::RemoteWindowTreeHostWin::Instance()->HandleActivateDesktop(shortcut,
ash_exit);
}
void HandleMetroExit() { void HandleMetroExit() {
DCHECK(aura::RemoteWindowTreeHostWin::Instance()); DCHECK(aura::RemoteWindowTreeHostWin::Instance());
aura::RemoteWindowTreeHostWin::Instance()->HandleMetroExit(); aura::RemoteWindowTreeHostWin::Instance()->HandleMetroExit();
...@@ -253,14 +246,6 @@ void RemoteWindowTreeHostWin::HandleOpenURLOnDesktop( ...@@ -253,14 +246,6 @@ void RemoteWindowTreeHostWin::HandleOpenURLOnDesktop(
host_->Send(new MetroViewerHostMsg_OpenURLOnDesktop(shortcut, url)); host_->Send(new MetroViewerHostMsg_OpenURLOnDesktop(shortcut, url));
} }
void RemoteWindowTreeHostWin::HandleActivateDesktop(
const base::FilePath& shortcut,
bool ash_exit) {
if (!host_)
return;
host_->Send(new MetroViewerHostMsg_ActivateDesktop(shortcut, ash_exit));
}
void RemoteWindowTreeHostWin::HandleMetroExit() { void RemoteWindowTreeHostWin::HandleMetroExit() {
if (!host_) if (!host_)
return; return;
......
...@@ -87,13 +87,6 @@ AURA_EXPORT void HandleSelectFolder(const base::string16& title, ...@@ -87,13 +87,6 @@ AURA_EXPORT void HandleSelectFolder(const base::string16& title,
const SelectFolderCompletion& on_success, const SelectFolderCompletion& on_success,
const FileSelectionCanceled& on_failure); const FileSelectionCanceled& on_failure);
// Handles the activate desktop command for Metro Chrome Ash. The |ash_exit|
// parameter indicates whether the Ash process would be shutdown after
// activating the desktop.
AURA_EXPORT void HandleActivateDesktop(
const base::FilePath& shortcut,
bool ash_exit);
// Handles the metro exit command. Notifies the metro viewer to shutdown // Handles the metro exit command. Notifies the metro viewer to shutdown
// gracefully. // gracefully.
AURA_EXPORT void HandleMetroExit(); AURA_EXPORT void HandleMetroExit();
...@@ -131,10 +124,6 @@ class AURA_EXPORT RemoteWindowTreeHostWin ...@@ -131,10 +124,6 @@ class AURA_EXPORT RemoteWindowTreeHostWin
void HandleOpenURLOnDesktop(const base::FilePath& shortcut, void HandleOpenURLOnDesktop(const base::FilePath& shortcut,
const base::string16& url); const base::string16& url);
// The |ash_exit| parameter indicates whether the Ash process would be
// shutdown after activating the desktop.
void HandleActivateDesktop(const base::FilePath& shortcut, bool ash_exit);
// Notify the metro viewer that it should shut itself down. // Notify the metro viewer that it should shut itself down.
void HandleMetroExit(); void HandleMetroExit();
......
...@@ -54,10 +54,10 @@ class MetroViewerProcessHost : public IPC::Listener, ...@@ -54,10 +54,10 @@ class MetroViewerProcessHost : public IPC::Listener,
bool LaunchViewerAndWaitForConnection( bool LaunchViewerAndWaitForConnection(
const base::string16& app_user_model_id); const base::string16& app_user_model_id);
private:
// IPC::Sender implementation: // IPC::Sender implementation:
virtual bool Send(IPC::Message* msg) OVERRIDE; virtual bool Send(IPC::Message* msg) OVERRIDE;
private:
// IPC::Listener implementation: // IPC::Listener implementation:
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
virtual void OnChannelError() OVERRIDE = 0; virtual void OnChannelError() OVERRIDE = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment