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/first_run_internal.h" | 5 #include "chrome/browser/first_run/first_run_internal.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 | 9 |
10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 // in |*ret_code|, and returns true if the exit code is valid. | 39 // in |*ret_code|, and returns true if the exit code is valid. |
40 // For metro Windows, it launches setup via ShellExecuteEx and returns in order | 40 // For metro Windows, it launches setup via ShellExecuteEx and returns in order |
41 // to bounce the user back to the desktop, then returns immediately. | 41 // to bounce the user back to the desktop, then returns immediately. |
42 bool LaunchSetupForEula(const base::FilePath::StringType& value, | 42 bool LaunchSetupForEula(const base::FilePath::StringType& value, |
43 int* ret_code) { | 43 int* ret_code) { |
44 base::FilePath exe_dir; | 44 base::FilePath exe_dir; |
45 if (!PathService::Get(base::DIR_MODULE, &exe_dir)) | 45 if (!PathService::Get(base::DIR_MODULE, &exe_dir)) |
46 return false; | 46 return false; |
47 exe_dir = exe_dir.Append(installer::kInstallerDir); | 47 exe_dir = exe_dir.Append(installer::kInstallerDir); |
48 base::FilePath exe_path = exe_dir.Append(installer::kSetupExe); | 48 base::FilePath exe_path = exe_dir.Append(installer::kSetupExe); |
49 base::ProcessHandle ph; | |
50 | 49 |
51 CommandLine cl(CommandLine::NO_PROGRAM); | 50 CommandLine cl(CommandLine::NO_PROGRAM); |
52 cl.AppendSwitchNative(installer::switches::kShowEula, value); | 51 cl.AppendSwitchNative(installer::switches::kShowEula, value); |
53 | 52 |
54 if (base::win::IsMetroProcess()) { | 53 if (base::win::IsMetroProcess()) { |
55 cl.AppendSwitch(installer::switches::kShowEulaForMetro); | 54 cl.AppendSwitch(installer::switches::kShowEulaForMetro); |
56 | 55 |
57 // This obscure use of the 'log usage' mask for windows 8 is documented here | 56 // This obscure use of the 'log usage' mask for windows 8 is documented here |
58 // http://go.microsoft.com/fwlink/?LinkID=243079. It causes the desktop | 57 // http://go.microsoft.com/fwlink/?LinkID=243079. It causes the desktop |
59 // process to receive focus. Pass SEE_MASK_FLAG_NO_UI to avoid hangs if an | 58 // process to receive focus. Pass SEE_MASK_FLAG_NO_UI to avoid hangs if an |
60 // error occurs since the UI can't be shown from a metro process. | 59 // error occurs since the UI can't be shown from a metro process. |
61 ui::win::OpenAnyViaShell(exe_path.value(), | 60 ui::win::OpenAnyViaShell(exe_path.value(), |
62 exe_dir.value(), | 61 exe_dir.value(), |
63 cl.GetCommandLineString(), | 62 cl.GetCommandLineString(), |
64 SEE_MASK_FLAG_LOG_USAGE | SEE_MASK_FLAG_NO_UI); | 63 SEE_MASK_FLAG_LOG_USAGE | SEE_MASK_FLAG_NO_UI); |
65 return false; | 64 return false; |
66 } else { | 65 } else { |
67 CommandLine setup_path(exe_path); | 66 CommandLine setup_path(exe_path); |
68 setup_path.AppendArguments(cl, false); | 67 setup_path.AppendArguments(cl, false); |
69 | 68 |
| 69 base::Process process = |
| 70 base::LaunchProcess(setup_path, base::LaunchOptions()); |
70 int exit_code = 0; | 71 int exit_code = 0; |
71 if (!base::LaunchProcess(setup_path, base::LaunchOptions(), &ph) || | 72 if (!process.IsValid() || !process.WaitForExit(&exit_code)) |
72 !base::WaitForExitCode(ph, &exit_code)) { | |
73 return false; | 73 return false; |
74 } | |
75 | 74 |
76 *ret_code = exit_code; | 75 *ret_code = exit_code; |
77 return true; | 76 return true; |
78 } | 77 } |
79 } | 78 } |
80 | 79 |
81 // Returns true if the EULA is required but has not been accepted by this user. | 80 // Returns true if the EULA is required but has not been accepted by this user. |
82 // The EULA is considered having been accepted if the user has gotten past | 81 // The EULA is considered having been accepted if the user has gotten past |
83 // first run in the "other" environment (desktop or metro). | 82 // first run in the "other" environment (desktop or metro). |
84 bool IsEULANotAccepted(installer::MasterPreferences* install_prefs) { | 83 bool IsEULANotAccepted(installer::MasterPreferences* install_prefs) { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 base::FilePath MasterPrefsPath() { | 194 base::FilePath MasterPrefsPath() { |
196 // The standard location of the master prefs is next to the chrome binary. | 195 // The standard location of the master prefs is next to the chrome binary. |
197 base::FilePath master_prefs; | 196 base::FilePath master_prefs; |
198 if (!PathService::Get(base::DIR_EXE, &master_prefs)) | 197 if (!PathService::Get(base::DIR_EXE, &master_prefs)) |
199 return base::FilePath(); | 198 return base::FilePath(); |
200 return master_prefs.AppendASCII(installer::kDefaultMasterPrefs); | 199 return master_prefs.AppendASCII(installer::kDefaultMasterPrefs); |
201 } | 200 } |
202 | 201 |
203 } // namespace internal | 202 } // namespace internal |
204 } // namespace first_run | 203 } // namespace first_run |
OLD | NEW |