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/first_run/upgrade_util.h" | 5 #include "chrome/browser/first_run/upgrade_util.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <psapi.h> | 8 #include <psapi.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/base_paths.h" | 14 #include "base/base_paths.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/environment.h" | 16 #include "base/environment.h" |
17 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
18 #include "base/files/file_util.h" | 18 #include "base/files/file_util.h" |
19 #include "base/logging.h" | 19 #include "base/logging.h" |
20 #include "base/path_service.h" | 20 #include "base/path_service.h" |
21 #include "base/prefs/pref_service.h" | |
21 #include "base/process/launch.h" | 22 #include "base/process/launch.h" |
22 #include "base/process/process_handle.h" | 23 #include "base/process/process_handle.h" |
23 #include "base/strings/string_number_conversions.h" | 24 #include "base/strings/string_number_conversions.h" |
24 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
25 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
26 #include "base/win/metro.h" | 27 #include "base/win/metro.h" |
27 #include "base/win/registry.h" | 28 #include "base/win/registry.h" |
28 #include "base/win/scoped_comptr.h" | 29 #include "base/win/scoped_comptr.h" |
29 #include "base/win/windows_version.h" | 30 #include "base/win/windows_version.h" |
31 #include "chrome/browser/browser_process.h" | |
30 #include "chrome/browser/first_run/upgrade_util_win.h" | 32 #include "chrome/browser/first_run/upgrade_util_win.h" |
31 #include "chrome/browser/shell_integration.h" | 33 #include "chrome/browser/shell_integration.h" |
32 #include "chrome/common/chrome_constants.h" | 34 #include "chrome/common/chrome_constants.h" |
33 #include "chrome/common/chrome_switches.h" | 35 #include "chrome/common/chrome_switches.h" |
36 #include "chrome/common/pref_names.h" | |
34 #include "chrome/installer/util/browser_distribution.h" | 37 #include "chrome/installer/util/browser_distribution.h" |
35 #include "chrome/installer/util/google_update_constants.h" | 38 #include "chrome/installer/util/google_update_constants.h" |
36 #include "chrome/installer/util/install_util.h" | 39 #include "chrome/installer/util/install_util.h" |
37 #include "chrome/installer/util/shell_util.h" | 40 #include "chrome/installer/util/shell_util.h" |
38 #include "chrome/installer/util/util_constants.h" | 41 #include "chrome/installer/util/util_constants.h" |
39 #include "google_update/google_update_idl.h" | 42 #include "google_update/google_update_idl.h" |
43 #include "ui/base/ui_base_switches.h" | |
40 | 44 |
41 namespace { | 45 namespace { |
42 | 46 |
43 bool GetNewerChromeFile(base::FilePath* path) { | 47 bool GetNewerChromeFile(base::FilePath* path) { |
44 if (!PathService::Get(base::DIR_EXE, path)) | 48 if (!PathService::Get(base::DIR_EXE, path)) |
45 return false; | 49 return false; |
46 *path = path->Append(installer::kChromeNewExe); | 50 *path = path->Append(installer::kChromeNewExe); |
47 return true; | 51 return true; |
48 } | 52 } |
49 | 53 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 return kRelaunchModeDefault; | 107 return kRelaunchModeDefault; |
104 } | 108 } |
105 | 109 |
106 RelaunchMode RelaunchModeStringToEnum(const std::string& relaunch_mode) { | 110 RelaunchMode RelaunchModeStringToEnum(const std::string& relaunch_mode) { |
107 if (relaunch_mode == kRelaunchModeMetro) | 111 if (relaunch_mode == kRelaunchModeMetro) |
108 return RELAUNCH_MODE_METRO; | 112 return RELAUNCH_MODE_METRO; |
109 | 113 |
110 if (relaunch_mode == kRelaunchModeDesktop) | 114 if (relaunch_mode == kRelaunchModeDesktop) |
111 return RELAUNCH_MODE_DESKTOP; | 115 return RELAUNCH_MODE_DESKTOP; |
112 | 116 |
117 // On Windows 7 if the current browser is in Chrome OS mode, then restart | |
118 // into Chrome OS mode. | |
119 if ((base::win::GetVersion() == base::win::VERSION_WIN7) && | |
120 CommandLine::ForCurrentProcess()->HasSwitch(switches::kViewerConnect) && | |
121 g_browser_process->local_state()->HasPrefPath(prefs::kRelaunchMode)) { | |
122 // TODO(ananta) | |
123 // On Windows 8, the delegate execute process looks up the previously | |
124 // launched mode from the registry and relaunches into that mode. We need | |
125 // something similar on Windows 7. For now, set the pref to ensure that | |
126 // we get relaunched into Chrome OS mode. | |
127 g_browser_process->local_state()->SetString( | |
128 prefs::kRelaunchMode, upgrade_util::kRelaunchModeMetro); | |
129 return RELAUNCH_MODE_METRO; | |
130 } | |
131 | |
Shrikant Kelkar
2014/09/12 21:53:28
Why temporary patch here? Why not make it uniform
ananta
2014/09/12 23:49:58
We don't know yet what we want to do with the laun
| |
113 return RELAUNCH_MODE_DEFAULT; | 132 return RELAUNCH_MODE_DEFAULT; |
114 } | 133 } |
115 | 134 |
116 bool RelaunchChromeHelper(const CommandLine& command_line, | 135 bool RelaunchChromeHelper(const CommandLine& command_line, |
117 const RelaunchMode& relaunch_mode) { | 136 const RelaunchMode& relaunch_mode) { |
118 scoped_ptr<base::Environment> env(base::Environment::Create()); | 137 scoped_ptr<base::Environment> env(base::Environment::Create()); |
119 std::string version_str; | 138 std::string version_str; |
120 | 139 |
121 // Get the version variable and remove it from the environment. | 140 // Get the version variable and remove it from the environment. |
122 if (env->GetVar(chrome::kChromeVersionEnvVar, &version_str)) | 141 if (env->GetVar(chrome::kChromeVersionEnvVar, &version_str)) |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
285 return false; | 304 return false; |
286 // At this point the chrome.exe has been swapped with the new one. | 305 // At this point the chrome.exe has been swapped with the new one. |
287 if (!RelaunchChromeBrowser(command_line)) { | 306 if (!RelaunchChromeBrowser(command_line)) { |
288 // The re-launch fails. Feel free to panic now. | 307 // The re-launch fails. Feel free to panic now. |
289 NOTREACHED(); | 308 NOTREACHED(); |
290 } | 309 } |
291 return true; | 310 return true; |
292 } | 311 } |
293 | 312 |
294 } // namespace upgrade_util | 313 } // namespace upgrade_util |
OLD | NEW |