Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: chrome/installer/util/eula_util.cc

Issue 12035043: Implementing app command to query EULA acceptance state for Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Installation validator; adding user-level vs. system-level param; limit user-level checks for Chrom… Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/installer/util/eula_util.h ('k') | chrome/installer/util/installation_validator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/installer/util/eula_util.h"
6
7 #include "base/file_util.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/common/chrome_constants.h"
10 #include "chrome/installer/util/browser_distribution.h"
11 #include "chrome/installer/util/install_util.h"
12 #include "chrome/installer/util/installation_state.h"
13 #include "chrome/installer/util/master_preferences.h"
14 #include "chrome/installer/util/master_preferences_constants.h"
15 #include "chrome/installer/util/util_constants.h"
16
17 namespace installer {
18
19 namespace {
20
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 FilePath first_run_sentinel;
26 return InstallUtil::GetSentinelFilePath(chrome::kFirstRunSentinel,
27 dist,
28 &first_run_sentinel)
29 && !file_util::PathExists(first_run_sentinel);
30 }
31
32 bool IsEULAAcceptanceFlagged(BrowserDistribution* dist) {
33 // Chrome creates the EULA sentinel after the EULA has been accepted when
34 // doing so is required by master_preferences. Assume the EULA has not been
35 // accepted if the path to the sentinel cannot be determined.
36 FilePath eula_sentinel;
37 return InstallUtil::GetSentinelFilePath(kEULASentinelFile,
38 dist,
39 &eula_sentinel)
40 && file_util::PathExists(eula_sentinel);
41 }
42
43 scoped_ptr<MasterPreferences> GetMasterPrefs(const ProductState& prod_state) {
44 // The standard location of the master prefs is next to the chrome binary.
45 FilePath master_prefs_path(
46 prod_state.GetSetupPath().DirName().DirName().DirName());
47 scoped_ptr<MasterPreferences> install_prefs(new MasterPreferences(
48 master_prefs_path.AppendASCII(kDefaultMasterPrefs)));
49 if (install_prefs && install_prefs->read_from_file())
50 return install_prefs.Pass();
51
52 return scoped_ptr<MasterPreferences>();
53 }
54
55 } // namespace
56
57 EULAAcceptanceResponse IsEULAAccepted(bool system_level) {
grt (UTC plus 2) 2013/01/28 02:12:58 is this expected to be called when !system_level?
huangs 2013/01/28 19:54:13 The main use case is for system-level, but since t
grt (UTC plus 2) 2013/01/29 15:25:18 Will the app command ever need to be invoked for a
58 ProductState prod_state;
59
60 if (!system_level) { // User-level case has seprate flow.
61 // Do not simply check Chrome binaries; go through list of products whose
62 // presence at user-level implies that EULA has been accepted.
63 return prod_state.Initialize(false, BrowserDistribution::CHROME_BROWSER)
64 || prod_state.Initialize(false, BrowserDistribution::CHROME_APP_HOST)
65 ? QUERY_EULA_ACCEPTED : QUERY_EULA_NOT_ACCEPTED;
66 }
67
68 // System-level. Try to use Chrome binaries product state.
69 if (!prod_state.Initialize(system_level,
grt (UTC plus 2) 2013/01/28 02:12:58 why use false up above and system_level here?
huangs 2013/01/28 19:54:13 Using "true" now, and eliminated wrapping.
70 BrowserDistribution::CHROME_BINARIES)) {
71 // Fall back to using Chrome product state.
72 if (!prod_state.Initialize(system_level,
73 BrowserDistribution::CHROME_BROWSER)) {
74 return QUERY_EULA_FAIL;
75 }
76
77 LOG_IF(DFATAL, prod_state.is_multi_install())
78 << "Binaries are not installed, but Chrome is multi-install.";
79 }
80 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution(
81 BrowserDistribution::CHROME_BROWSER);
82
83 // Is Google Update waiting for Chrome's EULA to be accepted?
84 DWORD eula_accepted = 0;
85 if (prod_state.GetEulaAccepted(&eula_accepted) && !eula_accepted)
86 return QUERY_EULA_NOT_ACCEPTED;
87
88 if (!IsChromeFirstRunPending(dist) || IsEULAAcceptanceFlagged(dist))
89 return QUERY_EULA_ACCEPTED;
90
91 // EULA acceptance not flagged. Now see if it is required.
92 scoped_ptr<MasterPreferences> install_prefs(GetMasterPrefs(prod_state));
93 // If we fail to get master preferences, assume that EULA is not required.
94 if (!install_prefs)
95 return QUERY_EULA_ACCEPTED;
96
97 bool eula_required = false;
98 // If kRequireEula value is absent, assume EULA is not required.
99 if (!install_prefs->GetBool(master_preferences::kRequireEula, &eula_required))
100 return QUERY_EULA_ACCEPTED;
101
102 return eula_required ? QUERY_EULA_NOT_ACCEPTED : QUERY_EULA_ACCEPTED;
103 }
104
105 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/installer/util/eula_util.h ('k') | chrome/installer/util/installation_validator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698