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 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include "base/base_paths.h" | 11 #include "base/base_paths.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
17 #include "base/process/kill.h" | 17 #include "base/process/kill.h" |
18 #include "base/process/launch.h" | 18 #include "base/process/launch.h" |
19 #include "base/process/process.h" | 19 #include "base/process/process.h" |
20 #include "base/threading/sequenced_worker_pool.h" | 20 #include "base/threading/sequenced_worker_pool.h" |
21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
22 #include "base/win/metro.h" | |
23 #include "chrome/common/chrome_constants.h" | 22 #include "chrome/common/chrome_constants.h" |
24 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
25 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/grit/locale_settings.h" | 25 #include "chrome/grit/locale_settings.h" |
27 #include "chrome/installer/util/google_update_settings.h" | 26 #include "chrome/installer/util/google_update_settings.h" |
28 #include "chrome/installer/util/install_util.h" | 27 #include "chrome/installer/util/install_util.h" |
29 #include "chrome/installer/util/master_preferences.h" | 28 #include "chrome/installer/util/master_preferences.h" |
30 #include "chrome/installer/util/master_preferences_constants.h" | 29 #include "chrome/installer/util/master_preferences_constants.h" |
31 #include "chrome/installer/util/util_constants.h" | 30 #include "chrome/installer/util/util_constants.h" |
32 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
(...skipping 11 matching lines...) Expand all Loading... |
44 int* ret_code) { | 43 int* ret_code) { |
45 base::FilePath exe_dir; | 44 base::FilePath exe_dir; |
46 if (!PathService::Get(base::DIR_MODULE, &exe_dir)) | 45 if (!PathService::Get(base::DIR_MODULE, &exe_dir)) |
47 return false; | 46 return false; |
48 exe_dir = exe_dir.Append(installer::kInstallerDir); | 47 exe_dir = exe_dir.Append(installer::kInstallerDir); |
49 base::FilePath exe_path = exe_dir.Append(installer::kSetupExe); | 48 base::FilePath exe_path = exe_dir.Append(installer::kSetupExe); |
50 | 49 |
51 base::CommandLine cl(base::CommandLine::NO_PROGRAM); | 50 base::CommandLine cl(base::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 base::CommandLine setup_path(exe_path); |
55 cl.AppendSwitch(installer::switches::kShowEulaForMetro); | 54 setup_path.AppendArguments(cl, false); |
56 | 55 |
57 // This obscure use of the 'log usage' mask for windows 8 is documented here | 56 base::Process process = |
58 // http://go.microsoft.com/fwlink/?LinkID=243079. It causes the desktop | 57 base::LaunchProcess(setup_path, base::LaunchOptions()); |
59 // process to receive focus. Pass SEE_MASK_FLAG_NO_UI to avoid hangs if an | 58 int exit_code = 0; |
60 // error occurs since the UI can't be shown from a metro process. | 59 if (!process.IsValid() || !process.WaitForExit(&exit_code)) |
61 ui::win::OpenAnyViaShell(exe_path.value(), | |
62 exe_dir.value(), | |
63 cl.GetCommandLineString(), | |
64 SEE_MASK_FLAG_LOG_USAGE | SEE_MASK_FLAG_NO_UI); | |
65 return false; | 60 return false; |
66 } else { | |
67 base::CommandLine setup_path(exe_path); | |
68 setup_path.AppendArguments(cl, false); | |
69 | 61 |
70 base::Process process = | 62 *ret_code = exit_code; |
71 base::LaunchProcess(setup_path, base::LaunchOptions()); | 63 return true; |
72 int exit_code = 0; | |
73 if (!process.IsValid() || !process.WaitForExit(&exit_code)) | |
74 return false; | |
75 | |
76 *ret_code = exit_code; | |
77 return true; | |
78 } | |
79 } | 64 } |
80 | 65 |
81 // Returns true if the EULA is required but has not been accepted by this user. | 66 // 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 | 67 // The EULA is considered having been accepted if the user has gotten past |
83 // first run in the "other" environment (desktop or metro). | 68 // first run in the "other" environment (desktop or metro). |
84 bool IsEULANotAccepted(installer::MasterPreferences* install_prefs) { | 69 bool IsEULANotAccepted(installer::MasterPreferences* install_prefs) { |
85 bool value = false; | 70 bool value = false; |
86 if (install_prefs->GetBool(installer::master_preferences::kRequireEula, | 71 if (install_prefs->GetBool(installer::master_preferences::kRequireEula, |
87 &value) && value) { | 72 &value) && value) { |
88 base::FilePath eula_sentinel; | 73 base::FilePath eula_sentinel; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 base::FilePath MasterPrefsPath() { | 180 base::FilePath MasterPrefsPath() { |
196 // The standard location of the master prefs is next to the chrome binary. | 181 // The standard location of the master prefs is next to the chrome binary. |
197 base::FilePath master_prefs; | 182 base::FilePath master_prefs; |
198 if (!PathService::Get(base::DIR_EXE, &master_prefs)) | 183 if (!PathService::Get(base::DIR_EXE, &master_prefs)) |
199 return base::FilePath(); | 184 return base::FilePath(); |
200 return master_prefs.AppendASCII(installer::kDefaultMasterPrefs); | 185 return master_prefs.AppendASCII(installer::kDefaultMasterPrefs); |
201 } | 186 } |
202 | 187 |
203 } // namespace internal | 188 } // namespace internal |
204 } // namespace first_run | 189 } // namespace first_run |
OLD | NEW |