Chromium Code Reviews| 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" |
| (...skipping 94 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 (base::win::IsMetroProcess()) { | 116 if (base::win::IsMetroProcess()) { |
| 116 // 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 |
| 117 // found another chrome running. Since metro enforces single instance then | 118 // found another chrome running. Since metro enforces single instance then |
| 118 // 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 |
| 119 // activation. This scenario is unique; other cases should be properly | 120 // activation. This scenario is unique; other cases should be properly |
| 120 // 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. |
| 121 string16 terms; | 122 string16 terms; |
| 122 base::win::MetroLaunchType launch = base::win::GetMetroLaunchParams(&terms); | 123 base::win::MetroLaunchType launch = base::win::GetMetroLaunchParams(&terms); |
| 123 if (launch != base::win::METRO_SEARCH) { | 124 if (launch != base::win::METRO_SEARCH) { |
| 124 LOG(WARNING) << "In metro mode, but and launch is " << launch; | 125 LOG(WARNING) << "In metro mode, but and launch is " << launch; |
| 125 } else { | 126 } else { |
| 126 std::string query = EscapeQueryParamValue(UTF16ToUTF8(terms), true); | 127 std::string query = EscapeQueryParamValue(UTF16ToUTF8(terms), true); |
| 127 std::string url = base::StringPrintf(kSearchUrl, query.c_str()); | 128 std::string url = base::StringPrintf(kSearchUrl, query.c_str()); |
| 128 SHELLEXECUTEINFOA sei = { sizeof(sei) }; | 129 SHELLEXECUTEINFOA sei = { sizeof(sei) }; |
| 129 sei.fMask = SEE_MASK_FLAG_LOG_USAGE; | 130 sei.fMask = SEE_MASK_FLAG_LOG_USAGE; |
| 130 sei.nShow = SW_SHOWNORMAL; | 131 sei.nShow = SW_SHOWNORMAL; |
| 131 sei.lpFile = url.c_str(); | 132 sei.lpFile = url.c_str(); |
| 132 OutputDebugStringA(sei.lpFile); | 133 OutputDebugStringA(sei.lpFile); |
| 133 sei.lpDirectory = ""; | 134 sei.lpDirectory = ""; |
| 134 ::ShellExecuteExA(&sei); | 135 ::ShellExecuteExA(&sei); |
| 135 } | 136 } |
| 136 return NOTIFY_SUCCESS; | 137 return NOTIFY_SUCCESS; |
| 137 } | 138 } |
| 138 | 139 |
| 139 base::win::ScopedHandle process_handle; | 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::OpenProcessHandleWithAccess( | 142 base::OpenProcessHandleWithAccess( |
| 142 process_id, PROCESS_QUERY_INFORMATION, | 143 process_id, PROCESS_QUERY_INFORMATION, |
| 143 process_handle.Receive()) && | 144 process_handle.Receive())) { |
| 144 base::win::IsProcessImmersive(process_handle.Get())) { | 145 if (base::win::IsProcessImmersive(process_handle.Get())) |
|
rvargas (doing something else)
2013/11/05 21:07:29
A short comment about not mixing the two if statem
| |
| 145 chrome::ActivateMetroChrome(); | 146 chrome::ActivateMetroChrome(); |
| 146 } | 147 } |
| 148 #endif | |
| 147 | 149 |
| 148 CommandLine command_line(*CommandLine::ForCurrentProcess()); | 150 CommandLine command_line(*CommandLine::ForCurrentProcess()); |
| 149 command_line.AppendSwitchASCII( | 151 command_line.AppendSwitchASCII( |
| 150 switches::kOriginalProcessStartTime, | 152 switches::kOriginalProcessStartTime, |
| 151 base::Int64ToString( | 153 base::Int64ToString( |
| 152 base::CurrentProcessInfo::CreationTime().ToInternalValue())); | 154 base::CurrentProcessInfo::CreationTime().ToInternalValue())); |
| 153 | 155 |
| 154 if (fast_start) | 156 if (fast_start) |
| 155 command_line.AppendSwitch(switches::kFastStart); | 157 command_line.AppendSwitch(switches::kFastStart); |
| 156 | 158 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 186 | 188 |
| 187 // It is possible that the process owning this window may have died by now. | 189 // It is possible that the process owning this window may have died by now. |
| 188 if (!::IsWindow(remote_window)) | 190 if (!::IsWindow(remote_window)) |
| 189 return NOTIFY_FAILED; | 191 return NOTIFY_FAILED; |
| 190 | 192 |
| 191 // If the window couldn't be notified but still exists, assume it is hung. | 193 // If the window couldn't be notified but still exists, assume it is hung. |
| 192 return NOTIFY_WINDOW_HUNG; | 194 return NOTIFY_WINDOW_HUNG; |
| 193 } | 195 } |
| 194 | 196 |
| 195 } // namespace chrome | 197 } // namespace chrome |
| OLD | NEW |