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

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

Issue 860453002: Move OpenProcessHandleWithAccess to Process::OpenWithAccess. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ServiceProcessControlBrowserTest.Setup again Created 5 years, 11 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
« no previous file with comments | « base/process/process_win.cc ('k') | chrome/browser/plugins/plugin_observer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/chrome_process_finder_win.h" 5 #include "chrome/browser/chrome_process_finder_win.h"
6 6
7 #include <shellapi.h> 7 #include <shellapi.h>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/process/process_handle.h" 14 #include "base/process/process.h"
15 #include "base/process/process_info.h" 15 #include "base/process/process_info.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/win/message_window.h" 19 #include "base/win/message_window.h"
20 #include "base/win/metro.h" 20 #include "base/win/metro.h"
21 #include "base/win/scoped_handle.h" 21 #include "base/win/scoped_handle.h"
22 #include "base/win/win_util.h" 22 #include "base/win/win_util.h"
23 #include "base/win/windows_version.h" 23 #include "base/win/windows_version.h"
24 #include "chrome/browser/metro_utils/metro_chrome_win.h" 24 #include "chrome/browser/metro_utils/metro_chrome_win.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 NotifyChromeResult AttemptToNotifyRunningChrome(HWND remote_window, 105 NotifyChromeResult AttemptToNotifyRunningChrome(HWND remote_window,
106 bool fast_start) { 106 bool fast_start) {
107 DCHECK(remote_window); 107 DCHECK(remote_window);
108 static const char kSearchUrl[] = 108 static const char kSearchUrl[] =
109 "http://www.google.com/search?q=%s&sourceid=chrome&ie=UTF-8"; 109 "http://www.google.com/search?q=%s&sourceid=chrome&ie=UTF-8";
110 DWORD process_id = 0; 110 DWORD process_id = 0;
111 DWORD thread_id = GetWindowThreadProcessId(remote_window, &process_id); 111 DWORD thread_id = GetWindowThreadProcessId(remote_window, &process_id);
112 if (!thread_id || !process_id) 112 if (!thread_id || !process_id)
113 return NOTIFY_FAILED; 113 return NOTIFY_FAILED;
114 114
115 #if !defined(USE_AURA)
116 if (base::win::IsMetroProcess()) {
117 // Interesting corner case. We are launched as a metro process but we
118 // found another chrome running. Since metro enforces single instance then
119 // the other chrome must be desktop chrome and this must be a search charm
120 // activation. This scenario is unique; other cases should be properly
121 // handled by the delegate_execute which will not activate a second chrome.
122 base::string16 terms;
123 base::win::MetroLaunchType launch = base::win::GetMetroLaunchParams(&terms);
124 if (launch != base::win::METRO_SEARCH) {
125 LOG(WARNING) << "In metro mode, but and launch is " << launch;
126 } else {
127 std::string query = EscapeQueryParamValue(base::UTF16ToUTF8(terms), true);
128 std::string url = base::StringPrintf(kSearchUrl, query.c_str());
129 SHELLEXECUTEINFOA sei = { sizeof(sei) };
130 sei.fMask = SEE_MASK_FLAG_LOG_USAGE;
131 sei.nShow = SW_SHOWNORMAL;
132 sei.lpFile = url.c_str();
133 OutputDebugStringA(sei.lpFile);
134 sei.lpDirectory = "";
135 ::ShellExecuteExA(&sei);
136 }
137 return NOTIFY_SUCCESS;
138 }
139
140 base::win::ScopedHandle process_handle;
141 if (base::win::GetVersion() >= base::win::VERSION_WIN8 &&
142 base::OpenProcessHandleWithAccess(
143 process_id, PROCESS_QUERY_INFORMATION,
144 process_handle.Receive())) {
145 // Receive() causes the process handle to be set in the destructor of the
146 // temporary receiver object, which does not happen until after the if
147 // statement is complete. So IsProcessImmersive() should only be checked
148 // as part of a separate if statement.
149 if (base::win::IsProcessImmersive(process_handle.Get()))
150 chrome::ActivateMetroChrome();
151 }
152 #endif
Nico 2015/07/26 02:54:08 Did you delete this block intentionally? It looks
153
154 base::CommandLine command_line(*base::CommandLine::ForCurrentProcess()); 115 base::CommandLine command_line(*base::CommandLine::ForCurrentProcess());
155 command_line.AppendSwitchASCII( 116 command_line.AppendSwitchASCII(
156 switches::kOriginalProcessStartTime, 117 switches::kOriginalProcessStartTime,
157 base::Int64ToString( 118 base::Int64ToString(
158 base::CurrentProcessInfo::CreationTime().ToInternalValue())); 119 base::CurrentProcessInfo::CreationTime().ToInternalValue()));
159 120
160 if (fast_start) 121 if (fast_start)
161 command_line.AppendSwitch(switches::kFastStart); 122 command_line.AppendSwitch(switches::kFastStart);
162 123
163 // Send the command line to the remote chrome window. 124 // Send the command line to the remote chrome window.
(...skipping 28 matching lines...) Expand all
192 153
193 // It is possible that the process owning this window may have died by now. 154 // It is possible that the process owning this window may have died by now.
194 if (!::IsWindow(remote_window)) 155 if (!::IsWindow(remote_window))
195 return NOTIFY_FAILED; 156 return NOTIFY_FAILED;
196 157
197 // If the window couldn't be notified but still exists, assume it is hung. 158 // If the window couldn't be notified but still exists, assume it is hung.
198 return NOTIFY_WINDOW_HUNG; 159 return NOTIFY_WINDOW_HUNG;
199 } 160 }
200 161
201 } // namespace chrome 162 } // namespace chrome
OLDNEW
« no previous file with comments | « base/process/process_win.cc ('k') | chrome/browser/plugins/plugin_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698