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 "chrome/common/chrome_constants.h" | |
10 #include "chrome/installer/util/browser_distribution.h" | 9 #include "chrome/installer/util/browser_distribution.h" |
11 #include "chrome/installer/util/install_util.h" | 10 #include "chrome/installer/util/install_util.h" |
12 #include "chrome/installer/util/installation_state.h" | 11 #include "chrome/installer/util/installation_state.h" |
13 #include "chrome/installer/util/master_preferences.h" | 12 #include "chrome/installer/util/master_preferences.h" |
14 #include "chrome/installer/util/master_preferences_constants.h" | 13 #include "chrome/installer/util/master_preferences_constants.h" |
15 #include "chrome/installer/util/util_constants.h" | 14 #include "chrome/installer/util/util_constants.h" |
16 | 15 |
17 namespace installer { | 16 namespace installer { |
18 | 17 |
19 namespace { | 18 namespace { |
20 | 19 |
21 bool IsChromeFirstRunPending(BrowserDistribution* dist) { | |
22 // 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 | |
24 // cannot be determined. | |
25 base::FilePath first_run_sentinel; | |
26 return InstallUtil::GetSentinelFilePath(chrome::kFirstRunSentinel, dist, | |
27 &first_run_sentinel) && | |
28 !base::PathExists(first_run_sentinel); | |
29 } | |
30 | |
31 bool IsEULAAcceptanceFlagged(BrowserDistribution* dist) { | 20 bool IsEULAAcceptanceFlagged(BrowserDistribution* dist) { |
32 // Chrome creates the EULA sentinel after the EULA has been accepted when | 21 // 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 | 22 // doing so is required by master_preferences. Assume the EULA has not been |
34 // accepted if the path to the sentinel cannot be determined. | 23 // accepted if the path to the sentinel cannot be determined. |
35 base::FilePath eula_sentinel; | 24 base::FilePath eula_sentinel; |
36 return InstallUtil::GetSentinelFilePath(kEULASentinelFile, dist, | 25 return InstallUtil::GetSentinelFilePath(kEULASentinelFile, dist, |
37 &eula_sentinel) && | 26 &eula_sentinel) && |
38 base::PathExists(eula_sentinel); | 27 base::PathExists(eula_sentinel); |
39 } | 28 } |
40 | 29 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 << "Binaries are not installed, but Chrome is multi-install."; | 70 << "Binaries are not installed, but Chrome is multi-install."; |
82 } | 71 } |
83 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( | 72 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( |
84 BrowserDistribution::CHROME_BROWSER); | 73 BrowserDistribution::CHROME_BROWSER); |
85 | 74 |
86 // Is Google Update waiting for Chrome's EULA to be accepted? | 75 // Is Google Update waiting for Chrome's EULA to be accepted? |
87 DWORD eula_accepted = 0; | 76 DWORD eula_accepted = 0; |
88 if (prod_state.GetEulaAccepted(&eula_accepted) && !eula_accepted) | 77 if (prod_state.GetEulaAccepted(&eula_accepted) && !eula_accepted) |
89 return QUERY_EULA_NOT_ACCEPTED; | 78 return QUERY_EULA_NOT_ACCEPTED; |
90 | 79 |
91 if (!IsChromeFirstRunPending(dist) || IsEULAAcceptanceFlagged(dist)) | 80 if (InstallUtil::IsFirstRunSentinelPresent() || IsEULAAcceptanceFlagged(dist)) |
92 return QUERY_EULA_ACCEPTED; | 81 return QUERY_EULA_ACCEPTED; |
93 | 82 |
94 // EULA acceptance not flagged. Now see if it is required. | 83 // EULA acceptance not flagged. Now see if it is required. |
95 scoped_ptr<MasterPreferences> install_prefs(GetMasterPrefs(prod_state)); | 84 scoped_ptr<MasterPreferences> install_prefs(GetMasterPrefs(prod_state)); |
96 // If we fail to get master preferences, assume that EULA is not required. | 85 // If we fail to get master preferences, assume that EULA is not required. |
97 if (!install_prefs) | 86 if (!install_prefs) |
98 return QUERY_EULA_ACCEPTED; | 87 return QUERY_EULA_ACCEPTED; |
99 | 88 |
100 bool eula_required = false; | 89 bool eula_required = false; |
101 // If kRequireEula value is absent, assume EULA is not required. | 90 // If kRequireEula value is absent, assume EULA is not required. |
102 if (!install_prefs->GetBool(master_preferences::kRequireEula, &eula_required)) | 91 if (!install_prefs->GetBool(master_preferences::kRequireEula, &eula_required)) |
103 return QUERY_EULA_ACCEPTED; | 92 return QUERY_EULA_ACCEPTED; |
104 | 93 |
105 return eula_required ? QUERY_EULA_NOT_ACCEPTED : QUERY_EULA_ACCEPTED; | 94 return eula_required ? QUERY_EULA_NOT_ACCEPTED : QUERY_EULA_ACCEPTED; |
106 } | 95 } |
107 | 96 |
108 } // namespace installer | 97 } // namespace installer |
OLD | NEW |