diff options
author | gab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-21 07:49:58 +0000 |
---|---|---|
committer | gab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-21 07:49:58 +0000 |
commit | 8c2f290e2e178336ab89a01d94ebba774152a6f5 (patch) | |
tree | 802bf45a7853f72013d55fb1578d099240c4132b | |
parent | ae30caa256bbcf0b80af9f41d803320874c2ac0f (diff) | |
download | chromium_src-8c2f290e2e178336ab89a01d94ebba774152a6f5.zip chromium_src-8c2f290e2e178336ab89a01d94ebba774152a6f5.tar.gz chromium_src-8c2f290e2e178336ab89a01d94ebba774152a6f5.tar.bz2 |
Make the browser<-->metro_viewer IPC channel name a constant instead of hardcoding it in a few places and passing it via a flag.
Supporting a more generic use case via flags was making things more complicated for no apparent reason (other than perhaps one day supporting a random-channel-id -- I removed that TODO in this CL). This simplification will make it easier to introduce some sort of --viewer-launch-via-appid-and-connect flag for https://codereview.chromium.org/16022003/
BUG=179830
TEST=Can still launch Ash in Metro.
Review URL: https://chromiumcodereview.appspot.com/15731003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207750 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/test/ash_test_base.cc | 3 | ||||
-rw-r--r-- | ash/test/test_metro_viewer_process_host.cc | 22 | ||||
-rw-r--r-- | ash/test/test_metro_viewer_process_host.h | 8 | ||||
-rw-r--r-- | chrome/browser/browser_process_platform_part_aurawin.cc | 8 | ||||
-rw-r--r-- | chrome/browser/metro_viewer/chrome_metro_viewer_process_host_aurawin.cc | 10 | ||||
-rw-r--r-- | chrome/browser/metro_viewer/chrome_metro_viewer_process_host_aurawin.h | 4 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 9 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 5 | ||||
-rw-r--r-- | win8/delegate_execute/command_execute_impl.cc | 8 | ||||
-rw-r--r-- | win8/metro_driver/chrome_app_view_ash.cc | 12 | ||||
-rw-r--r-- | win8/metro_driver/metro_driver.gyp | 3 | ||||
-rw-r--r-- | win8/viewer/metro_viewer_constants.cc | 11 | ||||
-rw-r--r-- | win8/viewer/metro_viewer_constants.h | 16 | ||||
-rw-r--r-- | win8/viewer/metro_viewer_process_host.cc | 4 | ||||
-rw-r--r-- | win8/viewer/metro_viewer_process_host.h | 17 | ||||
-rw-r--r-- | win8/win8.gyp | 2 |
16 files changed, 75 insertions, 67 deletions
diff --git a/ash/test/ash_test_base.cc b/ash/test/ash_test_base.cc index 8e93f27..7c03586 100644 --- a/ash/test/ash_test_base.cc +++ b/ash/test/ash_test_base.cc @@ -124,8 +124,7 @@ void AshTestBase::SetUp() { ipc_thread_->StartWithOptions(options); metro_viewer_host_.reset( - new TestMetroViewerProcessHost("viewer", - ipc_thread_->message_loop_proxy())); + new TestMetroViewerProcessHost(ipc_thread_->message_loop_proxy())); CHECK(metro_viewer_host_->LaunchViewerAndWaitForConnection( win8::test::kDefaultTestAppUserModelId)); aura::RemoteRootWindowHostWin* root_window_host = diff --git a/ash/test/test_metro_viewer_process_host.cc b/ash/test/test_metro_viewer_process_host.cc index 3819d35..a788da9 100644 --- a/ash/test/test_metro_viewer_process_host.cc +++ b/ash/test/test_metro_viewer_process_host.cc @@ -4,30 +4,18 @@ #include "ash/test/test_metro_viewer_process_host.h" -#include <shellapi.h> -#include <shlobj.h> - -#include "base/command_line.h" -#include "base/file_util.h" -#include "base/files/file_path.h" -#include "base/strings/string16.h" -#include "base/time.h" -#include "base/win/scoped_com_initializer.h" -#include "base/win/scoped_comptr.h" -#include "ipc/ipc_channel_proxy.h" -#include "ipc/ipc_message_macros.h" +#include <windef.h> + +#include "base/logging.h" #include "ui/aura/remote_root_window_host_win.h" -#include "ui/metro_viewer/metro_viewer_messages.h" #include "ui/surface/accelerated_surface_win.h" namespace ash { namespace test { TestMetroViewerProcessHost::TestMetroViewerProcessHost( - const std::string& ipc_channel_name, base::SingleThreadTaskRunner* ipc_task_runner) - : MetroViewerProcessHost(ipc_channel_name, ipc_task_runner), - closed_unexpectedly_(false) { + : MetroViewerProcessHost(ipc_task_runner), closed_unexpectedly_(false) { } TestMetroViewerProcessHost::~TestMetroViewerProcessHost() { @@ -43,7 +31,7 @@ void TestMetroViewerProcessHost::OnSetTargetSurface( DLOG(INFO) << __FUNCTION__ << ", target_surface = " << target_surface; HWND hwnd = reinterpret_cast<HWND>(target_surface); - backing_surface.reset(new AcceleratedSurface(hwnd)); + backing_surface_.reset(new AcceleratedSurface(hwnd)); scoped_refptr<AcceleratedPresenter> any_window = AcceleratedPresenter::GetForWindow(NULL); diff --git a/ash/test/test_metro_viewer_process_host.h b/ash/test/test_metro_viewer_process_host.h index 63ca815..e6d0a64 100644 --- a/ash/test/test_metro_viewer_process_host.h +++ b/ash/test/test_metro_viewer_process_host.h @@ -5,8 +5,7 @@ #ifndef ASH_TEST_TEST_METRO_VIEWER_PROCESS_HOST_H_ #define ASH_TEST_TEST_METRO_VIEWER_PROCESS_HOST_H_ -#include <string> - +#include "base/memory/scoped_ptr.h" #include "win8/viewer/metro_viewer_process_host.h" class AcceleratedSurface; @@ -16,8 +15,7 @@ namespace test { class TestMetroViewerProcessHost : public win8::MetroViewerProcessHost { public: - TestMetroViewerProcessHost(const std::string& ipc_channel_name, - base::SingleThreadTaskRunner* ipc_task_runner); + TestMetroViewerProcessHost(base::SingleThreadTaskRunner* ipc_task_runner); virtual ~TestMetroViewerProcessHost(); bool closed_unexpectedly() { return closed_unexpectedly_; } @@ -29,7 +27,7 @@ class TestMetroViewerProcessHost : public win8::MetroViewerProcessHost { virtual void OnOpenURL(const string16& url) OVERRIDE; virtual void OnHandleSearchRequest(const string16& search_string) OVERRIDE; - scoped_ptr<AcceleratedSurface> backing_surface; + scoped_ptr<AcceleratedSurface> backing_surface_; bool closed_unexpectedly_; diff --git a/chrome/browser/browser_process_platform_part_aurawin.cc b/chrome/browser/browser_process_platform_part_aurawin.cc index e6be06d..8299d01 100644 --- a/chrome/browser/browser_process_platform_part_aurawin.cc +++ b/chrome/browser/browser_process_platform_part_aurawin.cc @@ -25,12 +25,10 @@ void BrowserProcessPlatformPart::OnMetroViewerProcessTerminated() { void BrowserProcessPlatformPart::PlatformSpecificCommandLineProcessing( const CommandLine& command_line) { if (base::win::GetVersion() >= base::win::VERSION_WIN8 && - command_line.HasSwitch(switches::kViewerConnection) && + command_line.HasSwitch(switches::kViewerConnect) && !metro_viewer_process_host_.get()) { - // Tell the metro viewer process host to connect to the given IPC channel. - metro_viewer_process_host_.reset( - new ChromeMetroViewerProcessHost( - command_line.GetSwitchValueASCII(switches::kViewerConnection))); + // Create a host to connect to the Metro viewer process over IPC. + metro_viewer_process_host_.reset(new ChromeMetroViewerProcessHost()); } } diff --git a/chrome/browser/metro_viewer/chrome_metro_viewer_process_host_aurawin.cc b/chrome/browser/metro_viewer/chrome_metro_viewer_process_host_aurawin.cc index 268510e..7ba1f9c 100644 --- a/chrome/browser/metro_viewer/chrome_metro_viewer_process_host_aurawin.cc +++ b/chrome/browser/metro_viewer/chrome_metro_viewer_process_host_aurawin.cc @@ -57,12 +57,10 @@ void OpenURL(const GURL& url) { } // namespace -ChromeMetroViewerProcessHost::ChromeMetroViewerProcessHost( - const std::string& ipc_channel_name) - : MetroViewerProcessHost( - ipc_channel_name, - content::BrowserThread::GetMessageLoopProxyForThread( - content::BrowserThread::IO)) { +ChromeMetroViewerProcessHost::ChromeMetroViewerProcessHost() + : MetroViewerProcessHost( + content::BrowserThread::GetMessageLoopProxyForThread( + content::BrowserThread::IO)) { g_browser_process->AddRefModule(); } diff --git a/chrome/browser/metro_viewer/chrome_metro_viewer_process_host_aurawin.h b/chrome/browser/metro_viewer/chrome_metro_viewer_process_host_aurawin.h index 826deb2..96ff005 100644 --- a/chrome/browser/metro_viewer/chrome_metro_viewer_process_host_aurawin.h +++ b/chrome/browser/metro_viewer/chrome_metro_viewer_process_host_aurawin.h @@ -5,13 +5,11 @@ #ifndef CHROME_BROWSER_METRO_VIEWER_CHROME_METRO_VIEWER_PROCESS_HOST_AURAWIN_H_ #define CHROME_BROWSER_METRO_VIEWER_CHROME_METRO_VIEWER_PROCESS_HOST_AURAWIN_H_ -#include <string> - #include "win8/viewer/metro_viewer_process_host.h" class ChromeMetroViewerProcessHost : public win8::MetroViewerProcessHost { public: - explicit ChromeMetroViewerProcessHost(const std::string& ipc_channel_name); + ChromeMetroViewerProcessHost(); private: // win8::MetroViewerProcessHost implementation diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 706c1e7..18d1cb1 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -1481,10 +1481,6 @@ 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"; @@ -1605,6 +1601,11 @@ const char kWindows8Search[] = "windows8-search"; #endif +#if defined(OS_WIN) && defined(USE_AURA) +// Requests that Chrome connect to the running Metro viewer process. +const char kViewerConnect[] = "viewer-connect"; +#endif + #ifndef NDEBUG // Enables overriding the path of file manager extension. const char kFileManagerExtensionPath[] = "filemgr-ext-path"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 7cc7ba1..7e404c1 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -393,7 +393,6 @@ extern const char kUserDataDir[]; extern const char kValidateCrx[]; extern const char kVariationsServerURL[]; extern const char kVersion[]; -extern const char kViewerConnection[]; extern const char kVisitURLs[]; extern const char kWhitelistedExtensionID[]; extern const char kWindowPosition[]; @@ -448,6 +447,10 @@ extern const char kWaitForMutex[]; extern const char kWindows8Search[]; #endif +#if defined(OS_WIN) && defined(USE_AURA) +extern const char kViewerConnect[]; +#endif + #ifndef NDEBUG extern const char kFileManagerExtensionPath[]; extern const char kImageLoaderExtensionPath[]; diff --git a/win8/delegate_execute/command_execute_impl.cc b/win8/delegate_execute/command_execute_impl.cc index 3d56344..03fb4da 100644 --- a/win8/delegate_execute/command_execute_impl.cc +++ b/win8/delegate_execute/command_execute_impl.cc @@ -59,6 +59,7 @@ HRESULT GetUrlFromShellItem(IShellItem* shell_item, string16* url) { return S_OK; } +#if defined(USE_AURA) bool LaunchChromeBrowserProcess() { base::FilePath delegate_exe_path; if (!PathService::Get(base::FILE_EXE, &delegate_exe_path)) @@ -88,16 +89,15 @@ bool LaunchChromeBrowserProcess() { // Prevent a Chrome window from showing up on the desktop. cl.AppendSwitch(switches::kSilentLaunch); - // Tell Chrome the IPC channel name to use. - // TODO(robertshield): Figure out how to get this name to both the launched - // desktop browser process and the resulting activated metro process. - cl.AppendSwitchASCII(switches::kViewerConnection, "viewer"); + // Tell Chrome to connect to the Metro viewer process. + cl.AppendSwitch(switches::kViewerConnect); base::LaunchOptions launch_options; launch_options.start_hidden = true; return base::LaunchProcess(cl, launch_options, NULL); } +#endif // defined(USE_AURA) } // namespace diff --git a/win8/metro_driver/chrome_app_view_ash.cc b/win8/metro_driver/chrome_app_view_ash.cc index 530d62c..87ac885 100644 --- a/win8/metro_driver/chrome_app_view_ash.cc +++ b/win8/metro_driver/chrome_app_view_ash.cc @@ -26,6 +26,7 @@ #include "win8/metro_driver/file_picker_ash.h" #include "win8/metro_driver/metro_driver.h" #include "win8/metro_driver/winrt_utils.h" +#include "win8/viewer/metro_viewer_constants.h" typedef winfoundtn::ITypedEventHandler< winapp::Core::CoreApplicationView*, @@ -432,20 +433,13 @@ ChromeAppViewAsh::Run() { options.message_loop_type = base::MessageLoop::TYPE_IO; io_thread.StartWithOptions(options); - std::string ipc_channel_name("viewer"); - - // TODO(robertshield): Figure out how to receive and append the channel ID - // from the delegate_execute instance that launched the browser process. - // See http://crbug.com/162474 - // ipc_channel_name.append(IPC::Channel::GenerateUniqueRandomChannelID()); - // Start up Chrome and wait for the desired IPC server connection to exist. - WaitForChromeIPCConnection(ipc_channel_name); + WaitForChromeIPCConnection(win8::kMetroViewerIPCChannelName); // In Aura mode we create an IPC channel to the browser, then ask it to // connect to us. ChromeChannelListener ui_channel_listener(&ui_loop_, this); - IPC::ChannelProxy ui_channel(ipc_channel_name, + IPC::ChannelProxy ui_channel(win8::kMetroViewerIPCChannelName, IPC::Channel::MODE_NAMED_CLIENT, &ui_channel_listener, io_thread.message_loop_proxy()); diff --git a/win8/metro_driver/metro_driver.gyp b/win8/metro_driver/metro_driver.gyp index bad7c79..483d7d9 100644 --- a/win8/metro_driver/metro_driver.gyp +++ b/win8/metro_driver/metro_driver.gyp @@ -72,6 +72,9 @@ ], 'conditions': [ ['use_aura==1', { + 'dependencies': [ + '../win8.gyp:metro_viewer', + ], 'sources': [ 'chrome_app_view_ash.cc', 'chrome_app_view_ash.h', diff --git a/win8/viewer/metro_viewer_constants.cc b/win8/viewer/metro_viewer_constants.cc new file mode 100644 index 0000000..578b22f --- /dev/null +++ b/win8/viewer/metro_viewer_constants.cc @@ -0,0 +1,11 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "win8/viewer/metro_viewer_constants.h" + +namespace win8 { + +const char kMetroViewerIPCChannelName[] = "viewer"; + +} // namespace win8 diff --git a/win8/viewer/metro_viewer_constants.h b/win8/viewer/metro_viewer_constants.h new file mode 100644 index 0000000..249f96c --- /dev/null +++ b/win8/viewer/metro_viewer_constants.h @@ -0,0 +1,16 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WIN8_VIEWER_METRO_VIEWER_CONSTANTS_H_ +#define WIN8_VIEWER_METRO_VIEWER_CONSTANTS_H_ + +namespace win8 { + +// The name of the IPC channel between the browser process and the metro viewer +// process. +extern const char kMetroViewerIPCChannelName[]; + +} // namespace win8 + +#endif // WIN8_VIEWER_METRO_VIEWER_CONSTANTS_H_ diff --git a/win8/viewer/metro_viewer_process_host.cc b/win8/viewer/metro_viewer_process_host.cc index b04fa21..512f14b 100644 --- a/win8/viewer/metro_viewer_process_host.cc +++ b/win8/viewer/metro_viewer_process_host.cc @@ -19,6 +19,7 @@ #include "ipc/ipc_message_macros.h" #include "ui/aura/remote_root_window_host_win.h" #include "ui/metro_viewer/metro_viewer_messages.h" +#include "win8/viewer/metro_viewer_constants.h" namespace win8 { @@ -32,11 +33,10 @@ void MetroViewerProcessHost::InternalMessageFilter::OnChannelConnected( } MetroViewerProcessHost::MetroViewerProcessHost( - const std::string& ipc_channel_name, base::SingleThreadTaskRunner* ipc_task_runner) { channel_.reset(new IPC::ChannelProxy( - ipc_channel_name.c_str(), + kMetroViewerIPCChannelName, IPC::Channel::MODE_NAMED_SERVER, this, ipc_task_runner)); diff --git a/win8/viewer/metro_viewer_process_host.h b/win8/viewer/metro_viewer_process_host.h index 288a320..67a6f7c 100644 --- a/win8/viewer/metro_viewer_process_host.h +++ b/win8/viewer/metro_viewer_process_host.h @@ -5,8 +5,6 @@ #ifndef WIN8_VIEWER_METRO_VIEWER_PROCESS_HOST_H_ #define WIN8_VIEWER_METRO_VIEWER_PROCESS_HOST_H_ -#include <string> - #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "base/strings/string16.h" @@ -32,13 +30,14 @@ class MetroViewerProcessHost : public IPC::Listener, public IPC::Sender, public base::NonThreadSafe { public: - // Initializes a viewer process host over |ipc_channel_name|. The given task - // runner correspond to a thread on which IPC::Channel is created and used - // (e.g. IO thread). Instantly connects to the viewer process if one is - // already connected to |ipc_channel_name|; a viewer can otherwise be - // launched synchronously via LaunchViewerAndWaitForConnection(). - MetroViewerProcessHost(const std::string& ipc_channel_name, - base::SingleThreadTaskRunner* ipc_task_runner); + // Initializes a viewer process host to connect to the Metro viewer process + // over IPC. The given task runner correspond to a thread on which + // IPC::Channel is created and used (e.g. IO thread). Instantly connects to + // the viewer process if one is already connected to |ipc_channel_name|; a + // viewer can otherwise be launched synchronously via + // LaunchViewerAndWaitForConnection(). + explicit MetroViewerProcessHost( + base::SingleThreadTaskRunner* ipc_task_runner); virtual ~MetroViewerProcessHost(); // Returns the process id of the viewer process if one is connected to this diff --git a/win8/win8.gyp b/win8/win8.gyp index 6e3d5a8..00bfa3b 100644 --- a/win8/win8.gyp +++ b/win8/win8.gyp @@ -60,6 +60,8 @@ '../ui/metro_viewer/metro_viewer.gyp:metro_viewer_messages', ], 'sources': [ + 'viewer/metro_viewer_constants.cc', + 'viewer/metro_viewer_constants.h', 'viewer/metro_viewer_process_host.cc', 'viewer/metro_viewer_process_host.h', ], |