summaryrefslogtreecommitdiffstats
path: root/win8
diff options
context:
space:
mode:
authorrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-13 16:44:10 +0000
committerrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-13 16:44:10 +0000
commit1be93e07413904d6de56991892d46cec614f5def (patch)
tree188f2ce4895713a7719c47cddb56752bf93645ca /win8
parentead5ab3d6a8ee59ee0f7c366a4ff4d529956d8af (diff)
downloadchromium_src-1be93e07413904d6de56991892d46cec614f5def.zip
chromium_src-1be93e07413904d6de56991892d46cec614f5def.tar.gz
chromium_src-1be93e07413904d6de56991892d46cec614f5def.tar.bz2
Cause metro/ash to auto-launch the needed desktop process, without showing a background window.
BUG=151718 TEST=Launch metro ash, see it start. Review URL: https://chromiumcodereview.appspot.com/11367060 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167409 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'win8')
-rw-r--r--win8/delegate_execute/command_execute_impl.cc11
-rw-r--r--win8/delegate_execute/command_execute_impl.h3
-rw-r--r--win8/metro_driver/chrome_app_view_ash.cc66
-rw-r--r--win8/metro_driver/chrome_app_view_ash.h1
-rw-r--r--win8/metro_driver/metro_driver.gyp3
5 files changed, 63 insertions, 21 deletions
diff --git a/win8/delegate_execute/command_execute_impl.cc b/win8/delegate_execute/command_execute_impl.cc
index 8ebca57..d243546 100644
--- a/win8/delegate_execute/command_execute_impl.cc
+++ b/win8/delegate_execute/command_execute_impl.cc
@@ -61,6 +61,8 @@ HRESULT GetUrlFromShellItem(IShellItem* shell_item, string16* url) {
} // namespace
+bool CommandExecuteImpl::path_provider_initialized_ = false;
+
// CommandExecuteImpl is resposible for activating chrome in Windows 8. The
// flow is complicated and this tries to highlight the important events.
// The current approach is to have a single instance of chrome either
@@ -123,9 +125,14 @@ CommandExecuteImpl::CommandExecuteImpl()
chrome_mode_(ECHUIM_SYSTEM_LAUNCHER) {
memset(&start_info_, 0, sizeof(start_info_));
start_info_.cb = sizeof(start_info_);
+
// We need to query the user data dir of chrome so we need chrome's
- // path provider.
- chrome::RegisterPathProvider();
+ // path provider. We can be created multiplie times in a single instance
+ // however so make sure we do this only once.
+ if (!path_provider_initialized_) {
+ chrome::RegisterPathProvider();
+ path_provider_initialized_ = true;
+ }
}
// CommandExecuteImpl
diff --git a/win8/delegate_execute/command_execute_impl.h b/win8/delegate_execute/command_execute_impl.h
index 8fd00b8..8e0fcbf 100644
--- a/win8/delegate_execute/command_execute_impl.h
+++ b/win8/delegate_execute/command_execute_impl.h
@@ -86,6 +86,9 @@ class ATL_NO_VTABLE DECLSPEC_UUID("A2DF06F9-A21A-44A8-8A99-8B9C84F29160")
private:
static bool FindChromeExe(FilePath* chrome_exe);
+
+ static bool path_provider_initialized_;
+
bool GetLaunchScheme(string16* display_name, INTERNET_SCHEME* scheme);
HRESULT LaunchDesktopChrome();
// Returns the launch mode, i.e. desktop launch/metro launch, etc.
diff --git a/win8/metro_driver/chrome_app_view_ash.cc b/win8/metro_driver/chrome_app_view_ash.cc
index 6110197..e9a9363 100644
--- a/win8/metro_driver/chrome_app_view_ash.cc
+++ b/win8/metro_driver/chrome_app_view_ash.cc
@@ -8,10 +8,14 @@
#include <windows.foundation.h>
#include "base/bind.h"
+#include "base/command_line.h"
#include "base/message_loop.h"
+#include "base/path_service.h"
+#include "base/process_util.h"
#include "base/threading/thread.h"
#include "base/win/metro.h"
#include "base/win/win_util.h"
+#include "chrome/common/chrome_switches.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_channel_proxy.h"
#include "ipc/ipc_sender.h"
@@ -68,14 +72,41 @@ class ChromeChannelListener : public IPC::Listener {
DVLOG(1) << "Channel error";
MetroExit();
}
+};
- void Init(IPC::Sender* s) {
- sender_ = s;
+bool LaunchChromeAndWaitForIPCConnection(const std::string& channel_name) {
+ FilePath chrome_path;
+ if (!PathService::Get(base::FILE_EXE, &chrome_path))
+ return false;
+ CommandLine cl(chrome_path);
+
+ FilePath user_data_dir = CommandLine::ForCurrentProcess()->
+ GetSwitchValuePath(switches::kUserDataDir);
+ if (!user_data_dir.empty())
+ cl.AppendSwitchPath(switches::kUserDataDir, user_data_dir);
+
+ // Prevent a Chrome window from showing up on the desktop.
+ cl.AppendSwitch(switches::kSilentLaunch);
+
+ // Tell Chrome the IPC channel name to use.
+ cl.AppendSwitchASCII(switches::kViewerConnection, channel_name);
+
+ base::LaunchOptions launch_options;
+ launch_options.force_breakaway_from_job_ = true;
+ launch_options.start_hidden = true;
+
+ if (base::LaunchProcess(cl, launch_options, NULL)) {
+ int ms_elapsed = 0;
+ while (!IPC::Channel::IsNamedServerInitialized(channel_name) &&
+ ms_elapsed < 10000) {
+ ms_elapsed += 500;
+ Sleep(500);
+ }
+ return IPC::Channel::IsNamedServerInitialized(channel_name);
}
- private:
- IPC::Sender* sender_;
-};
+ return false;
+}
// This class helps decoding the pointer properties of an event.
class PointerInfoHandler {
@@ -189,8 +220,7 @@ uint32 GetKeyboardEventFlags() {
} // namespace
ChromeAppViewAsh::ChromeAppViewAsh()
- : ui_channel_(nullptr),
- ui_channel_listener_(nullptr) {
+ : ui_channel_(nullptr) {
globals.previous_state =
winapp::Activation::ApplicationExecutionState_NotRunning;
}
@@ -284,26 +314,28 @@ ChromeAppViewAsh::Run() {
MessageLoop msg_loop(MessageLoop::TYPE_UI);
// Create the IPC channel IO thread. It needs to out-live the ChannelProxy.
- base::Thread thread("metro_IO_thread");
+ base::Thread io_thread("metro_IO_thread");
base::Thread::Options options;
options.message_loop_type = MessageLoop::TYPE_IO;
- thread.StartWithOptions(options);
+ io_thread.StartWithOptions(options);
- // In Aura mode we create an IPC channel to the browser which should
- // be already running.
+ std::string ipc_channel_name("viewer");
+ ipc_channel_name.append(IPC::Channel::GenerateUniqueRandomChannelID());
+
+ // Start up Chrome and wait for the desired IPC server connection to exist.
+ LaunchChromeAndWaitForIPCConnection(ipc_channel_name);
+
+ // In Aura mode we create an IPC channel to the browser, then ask it to
+ // connect to us.
ChromeChannelListener ui_channel_listener;
- IPC::ChannelProxy ui_channel("viewer",
+ IPC::ChannelProxy ui_channel(ipc_channel_name,
IPC::Channel::MODE_NAMED_CLIENT,
&ui_channel_listener,
- thread.message_loop_proxy());
- ui_channel_listener.Init(&ui_channel);
-
- ui_channel_listener_ = &ui_channel_listener;
+ io_thread.message_loop_proxy());
ui_channel_ = &ui_channel;
ui_channel_->Send(new MetroViewerHostMsg_SetTargetSurface(
gfx::NativeViewId(globals.core_window)));
-
DVLOG(1) << "ICoreWindow sent " << globals.core_window;
// And post the task that'll do the inner Metro message pumping to it.
diff --git a/win8/metro_driver/chrome_app_view_ash.h b/win8/metro_driver/chrome_app_view_ash.h
index 88e8749..886510c 100644
--- a/win8/metro_driver/chrome_app_view_ash.h
+++ b/win8/metro_driver/chrome_app_view_ash.h
@@ -69,7 +69,6 @@ class ChromeAppViewAsh
metro_driver::Direct3DHelper direct3d_helper_;
- IPC::Listener* ui_channel_listener_;
IPC::ChannelProxy* ui_channel_;
};
diff --git a/win8/metro_driver/metro_driver.gyp b/win8/metro_driver/metro_driver.gyp
index 191c8d2..0d0081b 100644
--- a/win8/metro_driver/metro_driver.gyp
+++ b/win8/metro_driver/metro_driver.gyp
@@ -53,6 +53,7 @@
'dependencies': [
'../../base/base.gyp:base',
'../../build/temp_gyp/googleurl.gyp:googleurl',
+ '../../chrome/common_constants.gyp:common_constants',
'../../crypto/crypto.gyp:crypto',
'../../google_update/google_update.gyp:google_update',
'../../ipc/ipc.gyp:ipc',
@@ -69,7 +70,7 @@
'winrt_utils.h',
'<(SHARED_INTERMEDIATE_DIR)/metro_driver/metro_driver_dll_version.rc',
],
- 'conditions': [
+ 'conditions': [
['use_aura==1', {
'sources': [
'chrome_app_view_ash.cc',