summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chrome_browser_main_win.cc10
-rw-r--r--chrome/browser/metro_viewer/metro_viewer_process_host_win.cc7
-rw-r--r--chrome/browser/metro_viewer/metro_viewer_process_host_win.h2
-rw-r--r--chrome/browser/ui/startup/startup_browser_creator.cc9
-rw-r--r--chrome/common/chrome_switches.cc8
-rw-r--r--chrome/common/chrome_switches.h2
-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
11 files changed, 95 insertions, 27 deletions
diff --git a/chrome/browser/chrome_browser_main_win.cc b/chrome/browser/chrome_browser_main_win.cc
index ba21ddf..9cbd305 100644
--- a/chrome/browser/chrome_browser_main_win.cc
+++ b/chrome/browser/chrome_browser_main_win.cc
@@ -259,8 +259,16 @@ void ChromeBrowserMainPartsWin::PreMainMessageLoopRun() {
ChromeBrowserMainParts::PreMainMessageLoopRun();
removable_device_notifications_window_->Init();
+
#if defined(USE_AURA)
- metro_viewer_process_host_.reset(new MetroViewerProcessHost);
+ CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ if (command_line.HasSwitch(switches::kViewerConnection) &&
+ !metro_viewer_process_host_) {
+ // Tell the metro viewer process host to connect to the given IPC channel.
+ metro_viewer_process_host_.reset(
+ new MetroViewerProcessHost(
+ command_line.GetSwitchValueASCII(switches::kViewerConnection)));
+ }
#endif
if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
diff --git a/chrome/browser/metro_viewer/metro_viewer_process_host_win.cc b/chrome/browser/metro_viewer/metro_viewer_process_host_win.cc
index 1fd77f3..23dc1dd 100644
--- a/chrome/browser/metro_viewer/metro_viewer_process_host_win.cc
+++ b/chrome/browser/metro_viewer/metro_viewer_process_host_win.cc
@@ -13,11 +13,10 @@
#include "ui/metro_viewer/metro_viewer_messages.h"
#include "ui/surface/accelerated_surface_win.h"
-MetroViewerProcessHost::MetroViewerProcessHost() {
+MetroViewerProcessHost::MetroViewerProcessHost(
+ const std::string& ipc_channel_name) {
channel_.reset(new IPC::ChannelProxy(
- // TODO(scottmg): Need to have a secure way to randomize and request
- // this name from the viewer-side.
- "viewer",
+ ipc_channel_name.c_str(),
IPC::Channel::MODE_NAMED_SERVER,
this,
content::BrowserThread::GetMessageLoopProxyForThread(
diff --git a/chrome/browser/metro_viewer/metro_viewer_process_host_win.h b/chrome/browser/metro_viewer/metro_viewer_process_host_win.h
index f825826..9d71524 100644
--- a/chrome/browser/metro_viewer/metro_viewer_process_host_win.h
+++ b/chrome/browser/metro_viewer/metro_viewer_process_host_win.h
@@ -21,7 +21,7 @@ class MetroViewerProcessHost : public IPC::Listener,
public IPC::Sender,
public base::NonThreadSafe {
public:
- MetroViewerProcessHost();
+ explicit MetroViewerProcessHost(const std::string& ipc_channel_name);
virtual ~MetroViewerProcessHost();
// IPC::Sender implementation.
diff --git a/chrome/browser/ui/startup/startup_browser_creator.cc b/chrome/browser/ui/startup/startup_browser_creator.cc
index 5493fdb..d1d461c 100644
--- a/chrome/browser/ui/startup/startup_browser_creator.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator.cc
@@ -392,6 +392,15 @@ bool StartupBrowserCreator::ProcessCmdLineImpl(
return false;
}
+ if (command_line.HasSwitch(switches::kSilentLaunch)) {
+ std::vector<GURL> urls_to_open = GetURLsFromCommandLine(
+ command_line, cur_dir, last_used_profile);
+ size_t expected_tabs =
+ std::max(static_cast<int>(urls_to_open.size()), 0);
+ if (expected_tabs == 0)
+ silent_launch = true;
+ }
+
if (command_line.HasSwitch(switches::kAutomationClientChannelID)) {
std::string automation_channel_id = command_line.GetSwitchValueASCII(
switches::kAutomationClientChannelID);
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 54a108f..ab03d11 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -1198,6 +1198,10 @@ const char kSideloadWipeout[] = "sideload-wipeout";
// specified.
const char kSilentDumpOnDCHECK[] = "silent-dump-on-dcheck";
+// Causes Chrome to launch without opening any windows by default. Useful if
+// one wishes to use Chrome as an ash server.
+const char kSilentLaunch[] = "silent-launch";
+
// Simulates an update being available.
const char kSimulateUpgrade[] = "simulate-upgrade";
@@ -1344,6 +1348,10 @@ const char kVariationsServerURL[] = "variations-server-url";
// Prints version information and quits.
const char kVersion[] = "version";
+// Requests that Chrome connect to a remote viewer process using an IPC
+// channel of the given name.
+const char kViewerConnection[] = "viewer-connection";
+
// Cycle through a series of URLs listed in the specified file.
const char kVisitURLs[] = "visit-urls";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index aa6e06f..7baa28b 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -308,6 +308,7 @@ extern const char kScriptBadges[];
extern const char kScriptBubble[];
extern const char kSearchInOmniboxHint[];
extern const char kSideloadWipeout[];
+extern const char kSilentLaunch[];
extern const char kSetToken[];
extern const char kShowAppList[];
extern const char kShowAppListShortcut[];
@@ -357,6 +358,7 @@ extern const char kUserDataDir[];
extern const char kUseWebBasedSigninFlow[];
extern const char kVariationsServerURL[];
extern const char kVersion[];
+extern const char kViewerConnection[];
extern const char kVisitURLs[];
extern const char kWebIntentsNativeServicesEnabled[];
extern const char kWebIntentsInvocationEnabled[];
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',