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
This commit is contained in:
chrome/browser
lifetime
metro_viewer
ui/aura
win8/viewer
@ -19,11 +19,11 @@
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/path_service.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/common/chrome_constants.h"
|
||||
#include "chrome/installer/util/util_constants.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "ui/aura/remote_window_tree_host_win.h"
|
||||
#endif
|
||||
|
||||
namespace chrome {
|
||||
@ -88,7 +88,7 @@ void ActivateDesktopHelper(AshExecutionStatus ash_execution_status) {
|
||||
// Actually launching the process needs to happen in the metro viewer,
|
||||
// otherwise it won't automatically transition to desktop. So we have
|
||||
// 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
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "ui/aura/remote_window_tree_host_win.h"
|
||||
#include "ui/gfx/win/dpi.h"
|
||||
#include "ui/metro_viewer/metro_viewer_messages.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
namespace {
|
||||
@ -66,11 +67,28 @@ void OpenURL(const GURL& url) {
|
||||
|
||||
} // 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()
|
||||
: MetroViewerProcessHost(
|
||||
content::BrowserThread::GetMessageLoopProxyForThread(
|
||||
content::BrowserThread::IO)) {
|
||||
chrome::IncrementKeepAliveCount();
|
||||
DCHECK(instance_ == NULL);
|
||||
instance_ = this;
|
||||
}
|
||||
|
||||
ChromeMetroViewerProcessHost::~ChromeMetroViewerProcessHost() {
|
||||
DCHECK(instance_ == this);
|
||||
instance_ = NULL;
|
||||
}
|
||||
|
||||
void ChromeMetroViewerProcessHost::OnChannelError() {
|
||||
|
@ -7,9 +7,25 @@
|
||||
|
||||
#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 {
|
||||
public:
|
||||
ChromeMetroViewerProcessHost();
|
||||
virtual ~ChromeMetroViewerProcessHost();
|
||||
|
||||
// Returns the singleton ChromeMetroViewerProcessHost instance. This may
|
||||
// return NULL.
|
||||
static ChromeMetroViewerProcessHost* instance() {
|
||||
return instance_;
|
||||
}
|
||||
|
||||
private:
|
||||
// win8::MetroViewerProcessHost implementation
|
||||
@ -23,6 +39,8 @@ class ChromeMetroViewerProcessHost : public win8::MetroViewerProcessHost {
|
||||
const base::string16& search_string) OVERRIDE;
|
||||
virtual void OnWindowSizeChanged(uint32 width, uint32 height) OVERRIDE;
|
||||
|
||||
static ChromeMetroViewerProcessHost* instance_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ChromeMetroViewerProcessHost);
|
||||
};
|
||||
|
||||
|
@ -135,13 +135,6 @@ void HandleSelectFolder(const base::string16& title,
|
||||
on_failure);
|
||||
}
|
||||
|
||||
void HandleActivateDesktop(const base::FilePath& shortcut,
|
||||
bool ash_exit) {
|
||||
DCHECK(aura::RemoteWindowTreeHostWin::Instance());
|
||||
aura::RemoteWindowTreeHostWin::Instance()->HandleActivateDesktop(shortcut,
|
||||
ash_exit);
|
||||
}
|
||||
|
||||
void HandleMetroExit() {
|
||||
DCHECK(aura::RemoteWindowTreeHostWin::Instance());
|
||||
aura::RemoteWindowTreeHostWin::Instance()->HandleMetroExit();
|
||||
@ -253,14 +246,6 @@ void RemoteWindowTreeHostWin::HandleOpenURLOnDesktop(
|
||||
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() {
|
||||
if (!host_)
|
||||
return;
|
||||
|
@ -87,13 +87,6 @@ AURA_EXPORT void HandleSelectFolder(const base::string16& title,
|
||||
const SelectFolderCompletion& on_success,
|
||||
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
|
||||
// gracefully.
|
||||
AURA_EXPORT void HandleMetroExit();
|
||||
@ -131,10 +124,6 @@ class AURA_EXPORT RemoteWindowTreeHostWin
|
||||
void HandleOpenURLOnDesktop(const base::FilePath& shortcut,
|
||||
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.
|
||||
void HandleMetroExit();
|
||||
|
||||
|
@ -54,10 +54,10 @@ class MetroViewerProcessHost : public IPC::Listener,
|
||||
bool LaunchViewerAndWaitForConnection(
|
||||
const base::string16& app_user_model_id);
|
||||
|
||||
private:
|
||||
// IPC::Sender implementation:
|
||||
virtual bool Send(IPC::Message* msg) OVERRIDE;
|
||||
|
||||
private:
|
||||
// IPC::Listener implementation:
|
||||
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
|
||||
virtual void OnChannelError() OVERRIDE = 0;
|
||||
|
Reference in New Issue
Block a user