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

Side by Side Diff: chrome/browser/process_singleton_win.cc

Issue 10910311: If desktop chrome is launched via the New Window/the recently opened url shortcuts on the chrome sh… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/win/metro.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/process_singleton.h" 5 #include "chrome/browser/process_singleton.h"
6 6
7 #include <shellapi.h> 7 #include <shellapi.h>
8 #include <shobjidl.h>
8 9
9 #include "base/base_paths.h" 10 #include "base/base_paths.h"
10 #include "base/command_line.h" 11 #include "base/command_line.h"
11 #include "base/file_path.h" 12 #include "base/file_path.h"
12 #include "base/path_service.h" 13 #include "base/path_service.h"
13 #include "base/process_util.h" 14 #include "base/process_util.h"
14 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
15 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
16 #include "base/win/metro.h" 17 #include "base/win/metro.h"
18 #include "base/win/scoped_com_initializer.h"
19 #include "base/win/scoped_comptr.h"
17 #include "base/win/scoped_handle.h" 20 #include "base/win/scoped_handle.h"
21 #include "base/win/windows_version.h"
18 #include "base/win/wrapped_window_proc.h" 22 #include "base/win/wrapped_window_proc.h"
19 #include "chrome/browser/ui/simple_message_box.h" 23 #include "chrome/browser/ui/simple_message_box.h"
20 #include "chrome/common/chrome_constants.h" 24 #include "chrome/common/chrome_constants.h"
25 #include "chrome/installer/util/browser_distribution.h"
26 #include "chrome/installer/util/shell_util.h"
21 #include "chrome/installer/util/wmi.h" 27 #include "chrome/installer/util/wmi.h"
22 #include "content/public/common/result_codes.h" 28 #include "content/public/common/result_codes.h"
23 #include "grit/chromium_strings.h" 29 #include "grit/chromium_strings.h"
24 #include "grit/generated_resources.h" 30 #include "grit/generated_resources.h"
25 #include "net/base/escape.h" 31 #include "net/base/escape.h"
26 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
27 #include "ui/base/win/hwnd_util.h" 33 #include "ui/base/win/hwnd_util.h"
28 34
29 namespace { 35 namespace {
30 36
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 119
114 // Get command line. 120 // Get command line.
115 const std::wstring cmd_line = 121 const std::wstring cmd_line =
116 msg.substr(second_null + 1, third_null - second_null); 122 msg.substr(second_null + 1, third_null - second_null);
117 *parsed_command_line = CommandLine::FromString(cmd_line); 123 *parsed_command_line = CommandLine::FromString(cmd_line);
118 return true; 124 return true;
119 } 125 }
120 return false; 126 return false;
121 } 127 }
122 128
129 bool ActivateMetroChrome() {
130 FilePath chrome_exe;
131 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
132 NOTREACHED() << "Failed to get chrome exe path";
133 return false;
134 }
135 string16 app_id = ShellUtil::GetBrowserModelId(
136 BrowserDistribution::GetDistribution(), chrome_exe.value());
137 if (app_id.empty()) {
138 NOTREACHED() << "Failed to get chrome app user model id.";
139 return false;
140 }
141
142 base::win::ScopedComPtr<IApplicationActivationManager> activation_manager;
143 HRESULT hr = activation_manager.CreateInstance(
144 CLSID_ApplicationActivationManager);
145 if (!activation_manager) {
146 NOTREACHED() << "Failed to cocreate activation manager. Error: " << hr;
147 return false;
148 }
149
150 unsigned long pid = 0;
151 hr = activation_manager->ActivateApplication(app_id.c_str(),
152 L"open",
153 AO_NONE,
154 &pid);
155 if (FAILED(hr)) {
156 NOTREACHED() << "Failed to activate metro chrome. Error: " << hr;
157 return false;
158 }
159 return true;
160 }
161
123 } // namespace 162 } // namespace
124 163
125 // Microsoft's Softricity virtualization breaks the sandbox processes. 164 // Microsoft's Softricity virtualization breaks the sandbox processes.
126 // So, if we detect the Softricity DLL we use WMI Win32_Process.Create to 165 // So, if we detect the Softricity DLL we use WMI Win32_Process.Create to
127 // break out of the virtualization environment. 166 // break out of the virtualization environment.
128 // http://code.google.com/p/chromium/issues/detail?id=43650 167 // http://code.google.com/p/chromium/issues/detail?id=43650
129 bool ProcessSingleton::EscapeVirtualization(const FilePath& user_data_dir) { 168 bool ProcessSingleton::EscapeVirtualization(const FilePath& user_data_dir) {
130 if (::GetModuleHandle(L"sftldr_wow64.dll") || 169 if (::GetModuleHandle(L"sftldr_wow64.dll") ||
131 ::GetModuleHandle(L"sftldr.dll")) { 170 ::GetModuleHandle(L"sftldr.dll")) {
132 int process_id; 171 int process_id;
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 NULL, 342 NULL,
304 reinterpret_cast<LPARAM>(&cds), 343 reinterpret_cast<LPARAM>(&cds),
305 SMTO_ABORTIFHUNG, 344 SMTO_ABORTIFHUNG,
306 kTimeoutInSeconds * 1000, 345 kTimeoutInSeconds * 1000,
307 &result)) { 346 &result)) {
308 // It is possible that the process owning this window may have died by now. 347 // It is possible that the process owning this window may have died by now.
309 if (!result) { 348 if (!result) {
310 remote_window_ = NULL; 349 remote_window_ = NULL;
311 return PROCESS_NONE; 350 return PROCESS_NONE;
312 } 351 }
352
353 base::win::ScopedHandle process_handle;
354 if (base::win::GetVersion() >= base::win::VERSION_WIN8 &&
355 base::OpenProcessHandleWithAccess(
356 process_id, PROCESS_QUERY_INFORMATION,
357 process_handle.Receive())) {
358 if (base::win::IsProcessImmersive(process_handle.Get()))
359 ActivateMetroChrome();
360 }
313 return PROCESS_NOTIFIED; 361 return PROCESS_NOTIFIED;
314 } 362 }
315 363
316 // It is possible that the process owning this window may have died by now. 364 // It is possible that the process owning this window may have died by now.
317 if (!IsWindow(remote_window_)) { 365 if (!IsWindow(remote_window_)) {
318 remote_window_ = NULL; 366 remote_window_ = NULL;
319 return PROCESS_NONE; 367 return PROCESS_NONE;
320 } 368 }
321 369
322 // The window is hung. Scan for every window to find a visible one. 370 // The window is hung. Scan for every window to find a visible one.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 switch (message) { 450 switch (message) {
403 case WM_COPYDATA: 451 case WM_COPYDATA:
404 return OnCopyData(reinterpret_cast<HWND>(wparam), 452 return OnCopyData(reinterpret_cast<HWND>(wparam),
405 reinterpret_cast<COPYDATASTRUCT*>(lparam)); 453 reinterpret_cast<COPYDATASTRUCT*>(lparam));
406 default: 454 default:
407 break; 455 break;
408 } 456 }
409 457
410 return ::DefWindowProc(hwnd, message, wparam, lparam); 458 return ::DefWindowProc(hwnd, message, wparam, lparam);
411 } 459 }
OLDNEW
« no previous file with comments | « base/win/metro.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698