OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/installer/util/eula_util.h" | 5 #include "chrome/installer/util/eula_util.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/path_service.h" | |
9 #include "chrome/common/chrome_constants.h" | 10 #include "chrome/common/chrome_constants.h" |
11 #include "chrome/common/chrome_paths.h" | |
10 #include "chrome/installer/util/browser_distribution.h" | 12 #include "chrome/installer/util/browser_distribution.h" |
11 #include "chrome/installer/util/install_util.h" | 13 #include "chrome/installer/util/install_util.h" |
12 #include "chrome/installer/util/installation_state.h" | 14 #include "chrome/installer/util/installation_state.h" |
13 #include "chrome/installer/util/master_preferences.h" | 15 #include "chrome/installer/util/master_preferences.h" |
14 #include "chrome/installer/util/master_preferences_constants.h" | 16 #include "chrome/installer/util/master_preferences_constants.h" |
15 #include "chrome/installer/util/util_constants.h" | 17 #include "chrome/installer/util/util_constants.h" |
16 | 18 |
17 namespace installer { | 19 namespace installer { |
18 | 20 |
19 namespace { | 21 namespace { |
20 | 22 |
21 bool IsChromeFirstRunPending(BrowserDistribution* dist) { | 23 bool IsChromeFirstRunPending() { |
22 // Chrome creates the first run sentinel after the user has gone through the | 24 // Chrome creates the first run sentinel after the user has gone through the |
23 // first-run flow. Assume Chrome has been run if the path to the sentinel | 25 // first-run flow. Assume Chrome has been run if the path to the sentinel |
24 // cannot be determined. | 26 // cannot be determined. |
25 base::FilePath first_run_sentinel; | 27 base::FilePath first_run_sentinel; |
grt (UTC plus 2)
2014/03/25 17:37:06
first_run_sentinel -> user_data_dir
| |
26 return InstallUtil::GetSentinelFilePath(chrome::kFirstRunSentinel, dist, | 28 return PathService::Get(chrome::DIR_USER_DATA, &first_run_sentinel) && |
27 &first_run_sentinel) && | 29 !base::PathExists(first_run_sentinel.Append(chrome::kFirstRunSentinel)); |
28 !base::PathExists(first_run_sentinel); | |
29 } | 30 } |
30 | 31 |
31 bool IsEULAAcceptanceFlagged(BrowserDistribution* dist) { | 32 bool IsEULAAcceptanceFlagged(BrowserDistribution* dist) { |
32 // Chrome creates the EULA sentinel after the EULA has been accepted when | 33 // Chrome creates the EULA sentinel after the EULA has been accepted when |
33 // doing so is required by master_preferences. Assume the EULA has not been | 34 // doing so is required by master_preferences. Assume the EULA has not been |
34 // accepted if the path to the sentinel cannot be determined. | 35 // accepted if the path to the sentinel cannot be determined. |
35 base::FilePath eula_sentinel; | 36 base::FilePath eula_sentinel; |
36 return InstallUtil::GetSentinelFilePath(kEULASentinelFile, dist, | 37 return InstallUtil::GetSentinelFilePath(kEULASentinelFile, dist, |
37 &eula_sentinel) && | 38 &eula_sentinel) && |
38 base::PathExists(eula_sentinel); | 39 base::PathExists(eula_sentinel); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 << "Binaries are not installed, but Chrome is multi-install."; | 82 << "Binaries are not installed, but Chrome is multi-install."; |
82 } | 83 } |
83 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( | 84 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( |
84 BrowserDistribution::CHROME_BROWSER); | 85 BrowserDistribution::CHROME_BROWSER); |
85 | 86 |
86 // Is Google Update waiting for Chrome's EULA to be accepted? | 87 // Is Google Update waiting for Chrome's EULA to be accepted? |
87 DWORD eula_accepted = 0; | 88 DWORD eula_accepted = 0; |
88 if (prod_state.GetEulaAccepted(&eula_accepted) && !eula_accepted) | 89 if (prod_state.GetEulaAccepted(&eula_accepted) && !eula_accepted) |
89 return QUERY_EULA_NOT_ACCEPTED; | 90 return QUERY_EULA_NOT_ACCEPTED; |
90 | 91 |
91 if (!IsChromeFirstRunPending(dist) || IsEULAAcceptanceFlagged(dist)) | 92 if (!IsChromeFirstRunPending() || IsEULAAcceptanceFlagged(dist)) |
92 return QUERY_EULA_ACCEPTED; | 93 return QUERY_EULA_ACCEPTED; |
93 | 94 |
94 // EULA acceptance not flagged. Now see if it is required. | 95 // EULA acceptance not flagged. Now see if it is required. |
95 scoped_ptr<MasterPreferences> install_prefs(GetMasterPrefs(prod_state)); | 96 scoped_ptr<MasterPreferences> install_prefs(GetMasterPrefs(prod_state)); |
96 // If we fail to get master preferences, assume that EULA is not required. | 97 // If we fail to get master preferences, assume that EULA is not required. |
97 if (!install_prefs) | 98 if (!install_prefs) |
98 return QUERY_EULA_ACCEPTED; | 99 return QUERY_EULA_ACCEPTED; |
99 | 100 |
100 bool eula_required = false; | 101 bool eula_required = false; |
101 // If kRequireEula value is absent, assume EULA is not required. | 102 // If kRequireEula value is absent, assume EULA is not required. |
102 if (!install_prefs->GetBool(master_preferences::kRequireEula, &eula_required)) | 103 if (!install_prefs->GetBool(master_preferences::kRequireEula, &eula_required)) |
103 return QUERY_EULA_ACCEPTED; | 104 return QUERY_EULA_ACCEPTED; |
104 | 105 |
105 return eula_required ? QUERY_EULA_NOT_ACCEPTED : QUERY_EULA_ACCEPTED; | 106 return eula_required ? QUERY_EULA_NOT_ACCEPTED : QUERY_EULA_ACCEPTED; |
106 } | 107 } |
107 | 108 |
108 } // namespace installer | 109 } // namespace installer |
OLD | NEW |