OLD | NEW |
---|---|
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 Loading... | |
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) | 115 #if !defined(USE_AURA) |
cpu_(ooo_6.6-7.5)
2015/01/22 00:43:21
I believe this code is dead so I think removing it
rvargas (doing something else)
2015/01/22 01:51:17
Done.
| |
116 if (base::win::IsMetroProcess()) { | 116 if (base::win::IsMetroProcess()) { |
117 // Interesting corner case. We are launched as a metro process but we | 117 // Interesting corner case. We are launched as a metro process but we |
118 // found another chrome running. Since metro enforces single instance then | 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 | 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 | 120 // activation. This scenario is unique; other cases should be properly |
121 // handled by the delegate_execute which will not activate a second chrome. | 121 // handled by the delegate_execute which will not activate a second chrome. |
122 base::string16 terms; | 122 base::string16 terms; |
123 base::win::MetroLaunchType launch = base::win::GetMetroLaunchParams(&terms); | 123 base::win::MetroLaunchType launch = base::win::GetMetroLaunchParams(&terms); |
124 if (launch != base::win::METRO_SEARCH) { | 124 if (launch != base::win::METRO_SEARCH) { |
125 LOG(WARNING) << "In metro mode, but and launch is " << launch; | 125 LOG(WARNING) << "In metro mode, but and launch is " << launch; |
126 } else { | 126 } else { |
127 std::string query = EscapeQueryParamValue(base::UTF16ToUTF8(terms), true); | 127 std::string query = EscapeQueryParamValue(base::UTF16ToUTF8(terms), true); |
128 std::string url = base::StringPrintf(kSearchUrl, query.c_str()); | 128 std::string url = base::StringPrintf(kSearchUrl, query.c_str()); |
129 SHELLEXECUTEINFOA sei = { sizeof(sei) }; | 129 SHELLEXECUTEINFOA sei = { sizeof(sei) }; |
130 sei.fMask = SEE_MASK_FLAG_LOG_USAGE; | 130 sei.fMask = SEE_MASK_FLAG_LOG_USAGE; |
131 sei.nShow = SW_SHOWNORMAL; | 131 sei.nShow = SW_SHOWNORMAL; |
132 sei.lpFile = url.c_str(); | 132 sei.lpFile = url.c_str(); |
133 OutputDebugStringA(sei.lpFile); | 133 OutputDebugStringA(sei.lpFile); |
134 sei.lpDirectory = ""; | 134 sei.lpDirectory = ""; |
135 ::ShellExecuteExA(&sei); | 135 ::ShellExecuteExA(&sei); |
136 } | 136 } |
137 return NOTIFY_SUCCESS; | 137 return NOTIFY_SUCCESS; |
138 } | 138 } |
139 | 139 |
140 base::win::ScopedHandle process_handle; | 140 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
141 if (base::win::GetVersion() >= base::win::VERSION_WIN8 && | 141 base::Process process = |
142 base::OpenProcessHandleWithAccess( | 142 base::Process::OpenWithAccess(process_id, PROCESS_QUERY_INFORMATION); |
143 process_id, PROCESS_QUERY_INFORMATION, | 143 if (process.IsValid() && base::win::IsProcessImmersive(process.Handle())) |
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(); | 144 chrome::ActivateMetroChrome(); |
151 } | 145 } |
152 #endif | 146 #endif |
153 | 147 |
154 base::CommandLine command_line(*base::CommandLine::ForCurrentProcess()); | 148 base::CommandLine command_line(*base::CommandLine::ForCurrentProcess()); |
155 command_line.AppendSwitchASCII( | 149 command_line.AppendSwitchASCII( |
156 switches::kOriginalProcessStartTime, | 150 switches::kOriginalProcessStartTime, |
157 base::Int64ToString( | 151 base::Int64ToString( |
158 base::CurrentProcessInfo::CreationTime().ToInternalValue())); | 152 base::CurrentProcessInfo::CreationTime().ToInternalValue())); |
159 | 153 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 | 186 |
193 // It is possible that the process owning this window may have died by now. | 187 // It is possible that the process owning this window may have died by now. |
194 if (!::IsWindow(remote_window)) | 188 if (!::IsWindow(remote_window)) |
195 return NOTIFY_FAILED; | 189 return NOTIFY_FAILED; |
196 | 190 |
197 // If the window couldn't be notified but still exists, assume it is hung. | 191 // If the window couldn't be notified but still exists, assume it is hung. |
198 return NOTIFY_WINDOW_HUNG; | 192 return NOTIFY_WINDOW_HUNG; |
199 } | 193 } |
200 | 194 |
201 } // namespace chrome | 195 } // namespace chrome |
OLD | NEW |