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

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

Issue 60823002: Fix some non-aura specific code related to metro startup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add comment explaining the reasoning for splitting compound if statement. Created 7 years, 1 month 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 | « no previous file | 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 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
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 // Receive() causes the process handle to be set in the destructor of the
gab 2013/11/05 22:46:55 This very much surprised me as I expected the obje
gab 2013/11/05 22:50:12 this ^^^
145 chrome::ActivateMetroChrome(); 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.
gab 2013/11/05 22:46:55 This is pretty bad... a comment should probably be
149 if (base::win::IsProcessImmersive(process_handle.Get()))
150 chrome::ActivateMetroChrome();
gab 2013/11/05 22:46:55 The use case this was meant to handle is that if y
146 } 151 }
152 #endif
147 153
148 CommandLine command_line(*CommandLine::ForCurrentProcess()); 154 CommandLine command_line(*CommandLine::ForCurrentProcess());
149 command_line.AppendSwitchASCII( 155 command_line.AppendSwitchASCII(
150 switches::kOriginalProcessStartTime, 156 switches::kOriginalProcessStartTime,
151 base::Int64ToString( 157 base::Int64ToString(
152 base::CurrentProcessInfo::CreationTime().ToInternalValue())); 158 base::CurrentProcessInfo::CreationTime().ToInternalValue()));
153 159
154 if (fast_start) 160 if (fast_start)
155 command_line.AppendSwitch(switches::kFastStart); 161 command_line.AppendSwitch(switches::kFastStart);
156 162
(...skipping 29 matching lines...) Expand all
186 192
187 // It is possible that the process owning this window may have died by now. 193 // It is possible that the process owning this window may have died by now.
188 if (!::IsWindow(remote_window)) 194 if (!::IsWindow(remote_window))
189 return NOTIFY_FAILED; 195 return NOTIFY_FAILED;
190 196
191 // If the window couldn't be notified but still exists, assume it is hung. 197 // If the window couldn't be notified but still exists, assume it is hung.
192 return NOTIFY_WINDOW_HUNG; 198 return NOTIFY_WINDOW_HUNG;
193 } 199 }
194 200
195 } // namespace chrome 201 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698