Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Unified Diff: win8/viewer/metro_viewer_process_host.cc

Issue 227573007: Third part of porting Chrome Ash to Windows 7 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lf Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: win8/viewer/metro_viewer_process_host.cc
diff --git a/win8/viewer/metro_viewer_process_host.cc b/win8/viewer/metro_viewer_process_host.cc
index a44ea3c473ae74ad8a0ac6a6f30c142439abd666..4143eb38c625b46879d25ad7c1731a85f3a621b6 100644
--- a/win8/viewer/metro_viewer_process_host.cc
+++ b/win8/viewer/metro_viewer_process_host.cc
@@ -10,12 +10,17 @@
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
+#include "base/path_service.h"
+#include "base/process/launch.h"
#include "base/process/process.h"
#include "base/process/process_handle.h"
#include "base/strings/string16.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/waitable_event.h"
#include "base/time/time.h"
#include "base/win/scoped_comptr.h"
+#include "base/win/windows_version.h"
+//#include "chrome/common/chrome_constants.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_message_macros.h"
#include "ui/aura/remote_window_tree_host_win.h"
@@ -87,18 +92,41 @@ bool MetroViewerProcessHost::LaunchViewerAndWaitForConnection(
message_filter_ = new InternalMessageFilter(this);
channel_->AddFilter(message_filter_);
- base::win::ScopedComPtr<IApplicationActivationManager> activator;
- HRESULT hr = activator.CreateInstance(CLSID_ApplicationActivationManager);
- if (SUCCEEDED(hr)) {
- DWORD pid = 0;
- // Use the "connect" verb to
- hr = activator->ActivateApplication(
- app_user_model_id.c_str(), kMetroViewerConnectVerb, AO_NONE, &pid);
+ if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
+ base::win::ScopedComPtr<IApplicationActivationManager> activator;
+ HRESULT hr = activator.CreateInstance(CLSID_ApplicationActivationManager);
+ if (SUCCEEDED(hr)) {
+ DWORD pid = 0;
+ // Use the "connect" verb to
+ hr = activator->ActivateApplication(
+ app_user_model_id.c_str(), kMetroViewerConnectVerb, AO_NONE, &pid);
+
+ if (FAILED(hr)) {
+ LOG(ERROR) << "Tried and failed to launch Metro Chrome. "
+ << "hr=" << std::hex << hr;
+ return false;
+ }
+ }
+ } else {
+ // For Windows 7 we just launch the viewer ourselves here.
+ base::FilePath chrome_path;
+ if (!PathService::Get(base::DIR_EXE, &chrome_path))
+ return false;
+ // First try and go up a level to find chrome.exe.
+ chrome_path = chrome_path.Append(L"chrome.exe");
+ if (!base::PathExists(chrome_path))
+ chrome_path = chrome_path.DirName().DirName().Append(L"chrome.exe");
+ if (!base::PathExists(chrome_path))
+ return false;
+
+ CommandLine cl(chrome_path);
+ cl.AppendArg("-ServerName:DefaultBrowserServer");
+ cl.AppendSwitch(base::UTF16ToASCII(kMetroViewerConnectVerb));
+ base::LaunchOptions launch_options;
+ if (!base::LaunchProcess(cl, launch_options, NULL))
+ return false;
}
- LOG_IF(ERROR, FAILED(hr)) << "Tried and failed to launch Metro Chrome. "
- << "hr=" << std::hex << hr;
-
// Having launched the viewer process, now we wait for it to connect.
bool success =
channel_connected_event_->TimedWait(base::TimeDelta::FromSeconds(
« win8/metro_driver/metro_driver_win7.cc ('K') | « win8/metro_driver/metro_driver_win7.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698