From 99b1c9b53e29d2362f97b21705e1d1b03c6f425f Mon Sep 17 00:00:00 2001 From: "zturner@chromium.org" Date: Tue, 3 Sep 2013 23:47:57 +0000 Subject: Make the metro viewer responsible for relaunching browser in desktop mode. Browsers can force a metro -> desktop transition by calling ShellExecuteEx with a special argument. However, the process that calls ShellExecute must itself be a metro process. This change implements that behavior. Without this change, triggering a relaunch in desktop mode while in ash would launch chrome in the desktop mode, but it would not automatically transition from metro to desktop. cpu@:*metro* bauerb@:chrome\browser\plugins\* sky@:ui\aura\* jschuh@:security review for ipc messages in ui\metro_viewer BUG=280377 Review URL: https://chromiumcodereview.appspot.com/23592024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221075 0039d316-1c4b-4281-b951-d872f2087c98 --- win8/metro_driver/chrome_app_view_ash.cc | 23 +++++++++++++++++++++++ win8/metro_driver/chrome_app_view_ash.h | 10 +++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) (limited to 'win8') diff --git a/win8/metro_driver/chrome_app_view_ash.cc b/win8/metro_driver/chrome_app_view_ash.cc index 8686b53..206ea83 100644 --- a/win8/metro_driver/chrome_app_view_ash.cc +++ b/win8/metro_driver/chrome_app_view_ash.cc @@ -11,6 +11,7 @@ #include "base/bind.h" #include "base/command_line.h" +#include "base/files/file_path.h" #include "base/message_loop/message_loop.h" #include "base/path_service.h" #include "base/threading/thread.h" @@ -83,6 +84,8 @@ class ChromeChannelListener : public IPC::Listener { virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { IPC_BEGIN_MESSAGE_MAP(ChromeChannelListener, message) + IPC_MESSAGE_HANDLER(MetroViewerHostMsg_OpenURLOnDesktop, + OnOpenURLOnDesktop) IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetCursor, OnSetCursor) IPC_MESSAGE_HANDLER(MetroViewerHostMsg_DisplayFileOpen, OnDisplayFileOpenDialog) @@ -102,6 +105,14 @@ class ChromeChannelListener : public IPC::Listener { } private: + void OnOpenURLOnDesktop(const base::FilePath& shortcut, + const string16& url) { + ui_proxy_->PostTask(FROM_HERE, + base::Bind(&ChromeAppViewAsh::OnOpenURLOnDesktop, + base::Unretained(app_view_), + shortcut, url)); + } + void OnSetCursor(int64 cursor) { ui_proxy_->PostTask(FROM_HERE, base::Bind(&ChromeAppViewAsh::OnSetCursor, @@ -502,6 +513,18 @@ HRESULT ChromeAppViewAsh::Unsnap() { } +void ChromeAppViewAsh::OnOpenURLOnDesktop(const base::FilePath& shortcut, + const string16& url) { + base::FilePath::StringType file = shortcut.value(); + SHELLEXECUTEINFO sei = { sizeof(sei) }; + sei.fMask = SEE_MASK_FLAG_LOG_USAGE; + sei.nShow = SW_SHOWNORMAL; + sei.lpFile = file.c_str(); + sei.lpDirectory = L""; + sei.lpParameters = url.c_str(); + BOOL result = ShellExecuteEx(&sei); +} + void ChromeAppViewAsh::OnSetCursor(HCURSOR cursor) { ::SetCursor(HCURSOR(cursor)); } diff --git a/win8/metro_driver/chrome_app_view_ash.h b/win8/metro_driver/chrome_app_view_ash.h index 57f20b9..62f0476 100644 --- a/win8/metro_driver/chrome_app_view_ash.h +++ b/win8/metro_driver/chrome_app_view_ash.h @@ -10,16 +10,19 @@ #include #include -#include "base/files/file_path.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/strings/string16.h" #include "ui/base/events/event_constants.h" #include "win8/metro_driver/direct3d_helper.h" +namespace base { +class FilePath; +} + namespace IPC { - class Listener; - class ChannelProxy; +class Listener; +class ChannelProxy; } class OpenFilePickerSession; @@ -46,6 +49,7 @@ class ChromeAppViewAsh // Returns S_OK on success. static HRESULT Unsnap(); + void OnOpenURLOnDesktop(const base::FilePath& shortcut, const string16& url); void OnSetCursor(HCURSOR cursor); void OnDisplayFileOpenDialog(const string16& title, const string16& filter, -- cgit v1.1