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

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

Issue 11103008: Chrome should never attempt to launch in Metro if it is no longer default browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | « 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 (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 #include <shobjidl.h>
9 9
10 #include "base/base_paths.h" 10 #include "base/base_paths.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/process_util.h" 14 #include "base/process_util.h"
15 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "base/win/metro.h" 17 #include "base/win/metro.h"
18 #include "base/win/registry.h" 18 #include "base/win/registry.h"
19 #include "base/win/scoped_com_initializer.h" 19 #include "base/win/scoped_com_initializer.h"
20 #include "base/win/scoped_comptr.h" 20 #include "base/win/scoped_comptr.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 "base/win/wrapped_window_proc.h" 24 #include "base/win/wrapped_window_proc.h"
25 #include "chrome/browser/shell_integration.h"
25 #include "chrome/browser/ui/simple_message_box.h" 26 #include "chrome/browser/ui/simple_message_box.h"
26 #include "chrome/common/chrome_constants.h" 27 #include "chrome/common/chrome_constants.h"
27 #include "chrome/common/chrome_paths.h" 28 #include "chrome/common/chrome_paths.h"
28 #include "chrome/common/chrome_paths_internal.h" 29 #include "chrome/common/chrome_paths_internal.h"
29 #include "chrome/installer/util/browser_distribution.h" 30 #include "chrome/installer/util/browser_distribution.h"
30 #include "chrome/installer/util/install_util.h" 31 #include "chrome/installer/util/install_util.h"
31 #include "chrome/installer/util/shell_util.h" 32 #include "chrome/installer/util/shell_util.h"
32 #include "chrome/installer/util/wmi.h" 33 #include "chrome/installer/util/wmi.h"
33 #include "content/public/common/result_codes.h" 34 #include "content/public/common/result_codes.h"
34 #include "grit/chromium_strings.h" 35 #include "grit/chromium_strings.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 NOTREACHED() << "Failed to activate metro chrome. Error: " << hr; 165 NOTREACHED() << "Failed to activate metro chrome. Error: " << hr;
165 return false; 166 return false;
166 } 167 }
167 return true; 168 return true;
168 } 169 }
169 170
170 // Returns true if Chrome needs to be relaunched into Windows 8 immersive mode. 171 // Returns true if Chrome needs to be relaunched into Windows 8 immersive mode.
171 // Following conditions apply:- 172 // Following conditions apply:-
172 // 1. Windows 8 or greater. 173 // 1. Windows 8 or greater.
173 // 2. Not in Windows 8 immersive mode. 174 // 2. Not in Windows 8 immersive mode.
174 // 3. Process integrity level is not high. 175 // 3. Chrome is default browser.
175 // 4. The profile data directory is the default directory . 176 // 4. Process integrity level is not high.
176 // 5. Last used mode was immersive/machine is a tablet. 177 // 5. The profile data directory is the default directory.
178 // 6. Last used mode was immersive/machine is a tablet.
177 // TODO(ananta) 179 // TODO(ananta)
178 // Move this function to a common place as the Windows 8 delegate_execute 180 // Move this function to a common place as the Windows 8 delegate_execute
179 // handler can possibly use this. 181 // handler can possibly use this.
180 bool ShouldLaunchInWindows8ImmersiveMode(const FilePath& user_data_dir) { 182 bool ShouldLaunchInWindows8ImmersiveMode(const FilePath& user_data_dir) {
181 #if defined(USE_AURA) 183 #if defined(USE_AURA)
182 return false; 184 return false;
183 #endif 185 #endif
184 186
185 if (base::win::GetVersion() < base::win::VERSION_WIN8) 187 if (base::win::GetVersion() < base::win::VERSION_WIN8)
186 return false; 188 return false;
187 189
188 if (base::win::IsProcessImmersive(base::GetCurrentProcessHandle())) 190 if (base::win::IsProcessImmersive(base::GetCurrentProcessHandle()))
189 return false; 191 return false;
190 192
193 if (!ShellIntegration::IsDefaultBrowser())
194 return false;
195
191 base::IntegrityLevel integrity_level = base::INTEGRITY_UNKNOWN; 196 base::IntegrityLevel integrity_level = base::INTEGRITY_UNKNOWN;
192 base::GetProcessIntegrityLevel(base::GetCurrentProcessHandle(), 197 base::GetProcessIntegrityLevel(base::GetCurrentProcessHandle(),
193 &integrity_level); 198 &integrity_level);
194 if (integrity_level == base::HIGH_INTEGRITY) 199 if (integrity_level == base::HIGH_INTEGRITY)
195 return false; 200 return false;
196 201
197 FilePath default_user_data_dir; 202 FilePath default_user_data_dir;
198 if (!chrome::GetDefaultUserDataDirectory(&default_user_data_dir)) 203 if (!chrome::GetDefaultUserDataDirectory(&default_user_data_dir))
199 return false; 204 return false;
200 205
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 252 }
248 return false; 253 return false;
249 } 254 }
250 255
251 // Look for a Chrome instance that uses the same profile directory. 256 // Look for a Chrome instance that uses the same profile directory.
252 // If there isn't one, create a message window with its title set to 257 // If there isn't one, create a message window with its title set to
253 // the profile directory path. 258 // the profile directory path.
254 ProcessSingleton::ProcessSingleton(const FilePath& user_data_dir) 259 ProcessSingleton::ProcessSingleton(const FilePath& user_data_dir)
255 : window_(NULL), locked_(false), foreground_window_(NULL), 260 : window_(NULL), locked_(false), foreground_window_(NULL),
256 is_virtualized_(false), lock_file_(INVALID_HANDLE_VALUE) { 261 is_virtualized_(false), lock_file_(INVALID_HANDLE_VALUE) {
257 FilePath default_user_data_dir; 262 FilePath default_user_data_dir;
grt (UTC plus 2) 2012/10/11 03:26:06 unused, please remove
gab 2012/10/11 03:57:08 How did you see that far in this CL?! Eagle eyes c
258 // For Windows 8 and above check if we need to relaunch into Windows 8 263 // For Windows 8 and above check if we need to relaunch into Windows 8
259 // immersive mode. 264 // immersive mode.
260 if (ShouldLaunchInWindows8ImmersiveMode(user_data_dir)) { 265 if (ShouldLaunchInWindows8ImmersiveMode(user_data_dir)) {
261 bool immersive_chrome_launched = ActivateMetroChrome(); 266 bool immersive_chrome_launched = ActivateMetroChrome();
262 if (!immersive_chrome_launched) { 267 if (!immersive_chrome_launched) {
263 LOG(WARNING) << "Failed to launch immersive chrome"; 268 LOG(WARNING) << "Failed to launch immersive chrome";
264 } else { 269 } else {
265 // Sleep to allow the immersive chrome process to create its initial 270 // Sleep to allow the immersive chrome process to create its initial
266 // message window. 271 // message window.
267 SleepEx(kImmersiveChromeInitTimeout, FALSE); 272 SleepEx(kImmersiveChromeInitTimeout, FALSE);
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 switch (message) { 524 switch (message) {
520 case WM_COPYDATA: 525 case WM_COPYDATA:
521 return OnCopyData(reinterpret_cast<HWND>(wparam), 526 return OnCopyData(reinterpret_cast<HWND>(wparam),
522 reinterpret_cast<COPYDATASTRUCT*>(lparam)); 527 reinterpret_cast<COPYDATASTRUCT*>(lparam));
523 default: 528 default:
524 break; 529 break;
525 } 530 }
526 531
527 return ::DefWindowProc(hwnd, message, wparam, lparam); 532 return ::DefWindowProc(hwnd, message, wparam, lparam);
528 } 533 }
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