summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/lifetime/application_lifetime.h12
-rw-r--r--chrome/browser/lifetime/application_lifetime_win.cc14
-rw-r--r--chrome/browser/platform_util_win.cc13
-rw-r--r--ui/aura/remote_root_window_host_win.cc5
-rw-r--r--ui/aura/remote_root_window_host_win.h9
-rw-r--r--ui/metro_viewer/metro_viewer_messages.h5
-rw-r--r--win8/metro_driver/chrome_app_view_ash.cc21
-rw-r--r--win8/metro_driver/chrome_app_view_ash.h2
8 files changed, 66 insertions, 15 deletions
diff --git a/chrome/browser/lifetime/application_lifetime.h b/chrome/browser/lifetime/application_lifetime.h
index 59c0d4a..8172e55 100644
--- a/chrome/browser/lifetime/application_lifetime.h
+++ b/chrome/browser/lifetime/application_lifetime.h
@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_LIFETIME_APPLICATION_LIFETIME_H_
#define CHROME_BROWSER_LIFETIME_APPLICATION_LIFETIME_H_
+#include "base/compiler_specific.h"
+
class Browser;
namespace chrome {
@@ -35,6 +37,16 @@ void AttemptRestart();
void AttemptRestartWithModeSwitch();
void AttemptRestartToDesktopMode();
void AttemptRestartToMetroMode();
+
+enum AshExecutionStatus {
+ ASH_KEEP_RUNNING,
+ ASH_TERMINATE,
+};
+
+// Helper function to activate the desktop from Ash mode. The
+// |ash_execution_status| parameter indicates if we should exit Ash after
+// activating desktop.
+void ActivateDesktopHelper(AshExecutionStatus ash_execution_status);
#endif
// Attempt to exit by closing all browsers. This is equivalent to
diff --git a/chrome/browser/lifetime/application_lifetime_win.cc b/chrome/browser/lifetime/application_lifetime_win.cc
index 9c5cbde..74615e9 100644
--- a/chrome/browser/lifetime/application_lifetime_win.cc
+++ b/chrome/browser/lifetime/application_lifetime_win.cc
@@ -66,7 +66,9 @@ void ActivateDesktopHelperReply() {
AttemptRestart();
}
-void ActivateDesktopHelper() {
+void ActivateDesktopIgnore() {}
+
+void ActivateDesktopHelper(AshExecutionStatus ash_execution_status) {
scoped_ptr<base::Environment> env(base::Environment::Create());
std::string version_str;
@@ -88,11 +90,15 @@ void ActivateDesktopHelper() {
path = path.Append(installer::kDelegateExecuteExe);
+ bool ash_exit = ash_execution_status == ASH_TERMINATE;
// 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,
- base::Bind(ActivateDesktopHelperReply));
+ aura::HandleActivateDesktop(
+ path,
+ ash_exit,
+ ash_exit ? base::Bind(ActivateDesktopHelperReply) :
+ base::Bind(ActivateDesktopIgnore));
}
#endif
@@ -106,7 +112,7 @@ void AttemptRestartToDesktopMode() {
// We need to PostTask as there is some IO involved.
content::BrowserThread::PostTask(
content::BrowserThread::PROCESS_LAUNCHER, FROM_HERE,
- base::Bind(&ActivateDesktopHelper));
+ base::Bind(&ActivateDesktopHelper, ASH_TERMINATE));
#else
AttemptRestart();
diff --git a/chrome/browser/platform_util_win.cc b/chrome/browser/platform_util_win.cc
index 2a6a8d7..aa2a0a1 100644
--- a/chrome/browser/platform_util_win.cc
+++ b/chrome/browser/platform_util_win.cc
@@ -19,6 +19,8 @@
#include "base/win/scoped_co_mem.h"
#include "base/win/scoped_comptr.h"
#include "base/win/windows_version.h"
+#include "chrome/browser/lifetime/application_lifetime.h"
+#include "chrome/browser/ui/host_desktop.h"
#include "content/public/browser/browser_thread.h"
#include "ui/base/win/shell.h"
#include "ui/gfx/native_widget_types.h"
@@ -133,18 +135,29 @@ namespace platform_util {
void ShowItemInFolder(const base::FilePath& full_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH)
+ chrome::ActivateDesktopHelper(chrome::ASH_KEEP_RUNNING);
+
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
base::Bind(&ShowItemInFolderOnFileThread, full_path));
}
void OpenItem(const base::FilePath& full_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH)
+ chrome::ActivateDesktopHelper(chrome::ASH_KEEP_RUNNING);
+
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
base::Bind(base::IgnoreResult(&ui::win::OpenItemViaShell), full_path));
}
void OpenExternal(const GURL& url) {
+ if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH)
+ chrome::ActivateDesktopHelper(chrome::ASH_KEEP_RUNNING);
+
// Quote the input scheme to be sure that the command does not have
// parameters unexpected by the external program. This url should already
// have been escaped.
diff --git a/ui/aura/remote_root_window_host_win.cc b/ui/aura/remote_root_window_host_win.cc
index 0b58d1a..f647566 100644
--- a/ui/aura/remote_root_window_host_win.cc
+++ b/ui/aura/remote_root_window_host_win.cc
@@ -135,9 +135,11 @@ void HandleSelectFolder(const base::string16& title,
}
void HandleActivateDesktop(const base::FilePath& shortcut,
+ bool ash_exit,
const ActivateDesktopCompleted& on_success) {
DCHECK(aura::RemoteRootWindowHostWin::Instance());
aura::RemoteRootWindowHostWin::Instance()->HandleActivateDesktop(shortcut,
+ ash_exit,
on_success);
}
@@ -232,12 +234,13 @@ void RemoteRootWindowHostWin::HandleOpenURLOnDesktop(
void RemoteRootWindowHostWin::HandleActivateDesktop(
const base::FilePath& shortcut,
+ bool ash_exit,
const ActivateDesktopCompleted& on_success) {
if (!host_)
return;
DCHECK(activate_completed_callback_.is_null());
activate_completed_callback_ = on_success;
- host_->Send(new MetroViewerHostMsg_ActivateDesktop(shortcut));
+ host_->Send(new MetroViewerHostMsg_ActivateDesktop(shortcut, ash_exit));
}
void RemoteRootWindowHostWin::HandleOpenFile(
diff --git a/ui/aura/remote_root_window_host_win.h b/ui/aura/remote_root_window_host_win.h
index 92788da..04bd6bc 100644
--- a/ui/aura/remote_root_window_host_win.h
+++ b/ui/aura/remote_root_window_host_win.h
@@ -88,8 +88,11 @@ AURA_EXPORT void HandleSelectFolder(const base::string16& title,
// Handles the activate desktop command for Metro Chrome Ash. The on_success
// callback passed in is invoked when activation is completed.
+// 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,
const ActivateDesktopCompleted& on_success);
// RootWindowHost implementaton that receives events from a different
@@ -117,7 +120,11 @@ class AURA_EXPORT RemoteRootWindowHostWin
void HandleOpenURLOnDesktop(const base::FilePath& shortcut,
const base::string16& url);
- void HandleActivateDesktop(const base::FilePath& shortcut,
+ // 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,
const ActivateDesktopCompleted& on_success);
void HandleOpenFile(const base::string16& title,
diff --git a/ui/metro_viewer/metro_viewer_messages.h b/ui/metro_viewer/metro_viewer_messages.h
index 3cddb2e..d562461 100644
--- a/ui/metro_viewer/metro_viewer_messages.h
+++ b/ui/metro_viewer/metro_viewer_messages.h
@@ -97,8 +97,9 @@ IPC_MESSAGE_CONTROL0(MetroViewerHostMsg_ActivateDesktopDone)
// Messages sent from the browser to the viewer:
// Requests the viewer to activate desktop mode.
-IPC_MESSAGE_CONTROL1(MetroViewerHostMsg_ActivateDesktop,
- base::FilePath /* shortcut */);
+IPC_MESSAGE_CONTROL2(MetroViewerHostMsg_ActivateDesktop,
+ base::FilePath /* shortcut */,
+ bool /* ash exit */);
// Requests the viewer to open a URL in desktop mode.
IPC_MESSAGE_CONTROL2(MetroViewerHostMsg_OpenURLOnDesktop,
diff --git a/win8/metro_driver/chrome_app_view_ash.cc b/win8/metro_driver/chrome_app_view_ash.cc
index c557bb5..2e96a00 100644
--- a/win8/metro_driver/chrome_app_view_ash.cc
+++ b/win8/metro_driver/chrome_app_view_ash.cc
@@ -185,11 +185,11 @@ class ChromeChannelListener : public IPC::Listener {
}
private:
- void OnActivateDesktop(const base::FilePath& shortcut) {
+ void OnActivateDesktop(const base::FilePath& shortcut, bool ash_exit) {
ui_proxy_->PostTask(FROM_HERE,
base::Bind(&ChromeAppViewAsh::OnActivateDesktop,
base::Unretained(app_view_),
- shortcut));
+ shortcut, ash_exit));
}
void OnOpenURLOnDesktop(const base::FilePath& shortcut,
@@ -676,12 +676,15 @@ HRESULT ChromeAppViewAsh::Unsnap() {
return hr;
}
-void ChromeAppViewAsh::OnActivateDesktop(const base::FilePath& file_path) {
+void ChromeAppViewAsh::OnActivateDesktop(const base::FilePath& file_path,
+ bool ash_exit) {
DVLOG(1) << "ChannelAppViewAsh::OnActivateDesktop\n";
- // As we are the top level window, the exiting is done async so we manage
- // to execute the entire function including the final Send().
- MetroExit(core_window_hwnd());
+ if (ash_exit) {
+ // As we are the top level window, the exiting is done async so we manage
+ // to execute the entire function including the final Send().
+ MetroExit(core_window_hwnd());
+ }
// We are just executing delegate_execute here without parameters. Assumption
// here is that this process will be reused by shell when asking for
@@ -695,7 +698,13 @@ void ChromeAppViewAsh::OnActivateDesktop(const base::FilePath& file_path) {
sei.nShow = SW_SHOWNORMAL;
sei.lpFile = file_path.value().c_str();
sei.lpParameters = NULL;
+ if (!ash_exit)
+ sei.fMask |= SEE_MASK_NOCLOSEPROCESS;
::ShellExecuteExW(&sei);
+ if (!ash_exit) {
+ ::TerminateProcess(sei.hProcess, 0);
+ ::CloseHandle(sei.hProcess);
+ }
ui_channel_->Send(new MetroViewerHostMsg_ActivateDesktopDone());
}
diff --git a/win8/metro_driver/chrome_app_view_ash.h b/win8/metro_driver/chrome_app_view_ash.h
index d50255b..c2e6d42 100644
--- a/win8/metro_driver/chrome_app_view_ash.h
+++ b/win8/metro_driver/chrome_app_view_ash.h
@@ -60,7 +60,7 @@ class ChromeAppViewAsh
// Returns S_OK on success.
static HRESULT Unsnap();
- void OnActivateDesktop(const base::FilePath& file_path);
+ void OnActivateDesktop(const base::FilePath& file_path, bool ash_exit);
void OnOpenURLOnDesktop(const base::FilePath& shortcut, const string16& url);
void OnSetCursor(HCURSOR cursor);
void OnDisplayFileOpenDialog(const string16& title,