| OLD | NEW |
| 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/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/installer/util/browser_distribution.h" | 31 #include "chrome/installer/util/browser_distribution.h" |
| 31 #include "chrome/installer/util/install_util.h" | 32 #include "chrome/installer/util/install_util.h" |
| 32 #include "chrome/installer/util/shell_util.h" | 33 #include "chrome/installer/util/shell_util.h" |
| 33 #include "chrome/installer/util/wmi.h" | 34 #include "chrome/installer/util/wmi.h" |
| 34 #include "content/public/common/result_codes.h" | 35 #include "content/public/common/result_codes.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 NOTREACHED() << "Failed to activate metro chrome. Error: " << hr; | 166 NOTREACHED() << "Failed to activate metro chrome. Error: " << hr; |
| 166 return false; | 167 return false; |
| 167 } | 168 } |
| 168 return true; | 169 return true; |
| 169 } | 170 } |
| 170 | 171 |
| 171 // Returns true if Chrome needs to be relaunched into Windows 8 immersive mode. | 172 // Returns true if Chrome needs to be relaunched into Windows 8 immersive mode. |
| 172 // Following conditions apply:- | 173 // Following conditions apply:- |
| 173 // 1. Windows 8 or greater. | 174 // 1. Windows 8 or greater. |
| 174 // 2. Not in Windows 8 immersive mode. | 175 // 2. Not in Windows 8 immersive mode. |
| 175 // 3. Process integrity level is not high. | 176 // 3. Chrome is default browser. |
| 176 // 4. The profile data directory is the default directory . | 177 // 4. Process integrity level is not high. |
| 177 // 5. Last used mode was immersive/machine is a tablet. | 178 // 5. The profile data directory is the default directory. |
| 179 // 6. Last used mode was immersive/machine is a tablet. |
| 178 // TODO(ananta) | 180 // TODO(ananta) |
| 179 // Move this function to a common place as the Windows 8 delegate_execute | 181 // Move this function to a common place as the Windows 8 delegate_execute |
| 180 // handler can possibly use this. | 182 // handler can possibly use this. |
| 181 bool ShouldLaunchInWindows8ImmersiveMode(const FilePath& user_data_dir) { | 183 bool ShouldLaunchInWindows8ImmersiveMode(const FilePath& user_data_dir) { |
| 182 #if defined(USE_AURA) | 184 #if defined(USE_AURA) |
| 183 return false; | 185 return false; |
| 184 #endif | 186 #endif |
| 185 | 187 |
| 186 if (base::win::GetVersion() < base::win::VERSION_WIN8) | 188 if (base::win::GetVersion() < base::win::VERSION_WIN8) |
| 187 return false; | 189 return false; |
| 188 | 190 |
| 189 if (base::win::IsProcessImmersive(base::GetCurrentProcessHandle())) | 191 if (base::win::IsProcessImmersive(base::GetCurrentProcessHandle())) |
| 190 return false; | 192 return false; |
| 191 | 193 |
| 194 if (!ShellIntegration::IsDefaultBrowser()) |
| 195 return false; |
| 196 |
| 192 base::IntegrityLevel integrity_level = base::INTEGRITY_UNKNOWN; | 197 base::IntegrityLevel integrity_level = base::INTEGRITY_UNKNOWN; |
| 193 base::GetProcessIntegrityLevel(base::GetCurrentProcessHandle(), | 198 base::GetProcessIntegrityLevel(base::GetCurrentProcessHandle(), |
| 194 &integrity_level); | 199 &integrity_level); |
| 195 if (integrity_level == base::HIGH_INTEGRITY) | 200 if (integrity_level == base::HIGH_INTEGRITY) |
| 196 return false; | 201 return false; |
| 197 | 202 |
| 198 FilePath default_user_data_dir; | 203 FilePath default_user_data_dir; |
| 199 if (!chrome::GetDefaultUserDataDirectory(&default_user_data_dir)) | 204 if (!chrome::GetDefaultUserDataDirectory(&default_user_data_dir)) |
| 200 return false; | 205 return false; |
| 201 | 206 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 } | 256 } |
| 252 return false; | 257 return false; |
| 253 } | 258 } |
| 254 | 259 |
| 255 // Look for a Chrome instance that uses the same profile directory. | 260 // Look for a Chrome instance that uses the same profile directory. |
| 256 // If there isn't one, create a message window with its title set to | 261 // If there isn't one, create a message window with its title set to |
| 257 // the profile directory path. | 262 // the profile directory path. |
| 258 ProcessSingleton::ProcessSingleton(const FilePath& user_data_dir) | 263 ProcessSingleton::ProcessSingleton(const FilePath& user_data_dir) |
| 259 : window_(NULL), locked_(false), foreground_window_(NULL), | 264 : window_(NULL), locked_(false), foreground_window_(NULL), |
| 260 is_virtualized_(false), lock_file_(INVALID_HANDLE_VALUE) { | 265 is_virtualized_(false), lock_file_(INVALID_HANDLE_VALUE) { |
| 261 FilePath default_user_data_dir; | |
| 262 // For Windows 8 and above check if we need to relaunch into Windows 8 | 266 // For Windows 8 and above check if we need to relaunch into Windows 8 |
| 263 // immersive mode. | 267 // immersive mode. |
| 264 if (ShouldLaunchInWindows8ImmersiveMode(user_data_dir)) { | 268 if (ShouldLaunchInWindows8ImmersiveMode(user_data_dir)) { |
| 265 bool immersive_chrome_launched = ActivateMetroChrome(); | 269 bool immersive_chrome_launched = ActivateMetroChrome(); |
| 266 if (!immersive_chrome_launched) { | 270 if (!immersive_chrome_launched) { |
| 267 LOG(WARNING) << "Failed to launch immersive chrome"; | 271 LOG(WARNING) << "Failed to launch immersive chrome"; |
| 268 } else { | 272 } else { |
| 269 // Sleep to allow the immersive chrome process to create its initial | 273 // Sleep to allow the immersive chrome process to create its initial |
| 270 // message window. | 274 // message window. |
| 271 SleepEx(kImmersiveChromeInitTimeout, FALSE); | 275 SleepEx(kImmersiveChromeInitTimeout, FALSE); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 switch (message) { | 527 switch (message) { |
| 524 case WM_COPYDATA: | 528 case WM_COPYDATA: |
| 525 return OnCopyData(reinterpret_cast<HWND>(wparam), | 529 return OnCopyData(reinterpret_cast<HWND>(wparam), |
| 526 reinterpret_cast<COPYDATASTRUCT*>(lparam)); | 530 reinterpret_cast<COPYDATASTRUCT*>(lparam)); |
| 527 default: | 531 default: |
| 528 break; | 532 break; |
| 529 } | 533 } |
| 530 | 534 |
| 531 return ::DefWindowProc(hwnd, message, wparam, lparam); | 535 return ::DefWindowProc(hwnd, message, wparam, lparam); |
| 532 } | 536 } |
| OLD | NEW |