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

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: Updated ProductState logic on system/user level, Binaries/Chrome. 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
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) {
erikwright (departed) 2013/01/24 19:09:54 Comment something like: // Chrome creates a senti
huangs 2013/01/24 19:45:22 Done. Please note the subsequent comment is about
22 // If we fail to get the sentinel path, assume Chrome has been run.
23 FilePath first_run_sentinel;
24 return InstallUtil::GetSentinelFilePath(chrome::kFirstRunSentinel,
25 dist,
26 &first_run_sentinel)
27 && !file_util::PathExists(first_run_sentinel);
28 }
29
30 bool IsEULASentinelPresent(BrowserDistribution* dist) {
erikwright (departed) 2013/01/24 19:09:54 Something like: // Chrome creates a sentinel afte
huangs 2013/01/24 19:45:22 Renamed to IsEULAAcceptanceFlagged().
31 // If we fail to get sentinel path, assume EULA not accepted.
32 FilePath eula_sentinel;
33 return InstallUtil::GetSentinelFilePath(kEULASentinelFile,
34 dist,
35 &eula_sentinel)
36 && file_util::PathExists(eula_sentinel);
37 }
38
39 scoped_ptr<MasterPreferences> GetMasterPrefs(const ProductState& prod_state) {
40 // The standard location of the master prefs is next to the chrome binary.
41 FilePath master_prefs_path(
42 prod_state.GetSetupPath().DirName().DirName().DirName());
43 scoped_ptr<MasterPreferences> install_prefs(new MasterPreferences(
44 master_prefs_path.AppendASCII(kDefaultMasterPrefs)));
45 if (install_prefs && install_prefs->read_from_file())
46 return install_prefs.Pass();
47
48 return scoped_ptr<MasterPreferences>();
49 }
50
51 } // namespace
52
53 EULAAcceptanceResponse IsEULAAccepted() {
54 ProductState prod_state;
55 // Try to use system-level Chrome binaries product state first.
56 if (!prod_state.Initialize(true, BrowserDistribution::CHROME_BINARIES)) {
57 // Fall back to using Chrome product state.
58 if (prod_state.Initialize(true, BrowserDistribution::CHROME_BROWSER)) {
59 LOG_IF(DFATAL, prod_state.is_multi_install())
60 << "Binaries are not installed yet Chrome thinks it's multi-install.";
61 } else {
62 // Test user-level, and return EULA_YES if successful.
63 return prod_state.Initialize(false, BrowserDistribution::CHROME_BINARIES)
erikwright (departed) 2013/01/24 19:09:54 If we accept the presence of a user-level Chrome o
huangs 2013/01/24 19:45:22 Done.
64 || prod_state.Initialize(false, BrowserDistribution::CHROME_BROWSER)
65 ? EULA_YES : EULA_FAIL;
66 }
67 }
68 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution(
69 BrowserDistribution::CHROME_BROWSER);
70
71 // Is Omaha waiting for Chrome's EULA to be accepted?
72 DWORD eula_accepted = 0;
73 if (prod_state.GetEulaAccepted(&eula_accepted) && !eula_accepted)
74 return EULA_NO;
75
76 if (!IsChromeFirstRunPending(dist) || IsEULASentinelPresent(dist))
77 return EULA_YES;
78
79 // Sentinel is absent. Now see if it was required in the first place.
80 scoped_ptr<MasterPreferences> install_prefs(GetMasterPrefs(prod_state));
81 // If we fail to get master preferences, assume EULA is not accepted.
erikwright (departed) 2013/01/24 19:09:54 I think master preferences can reasonably be absen
grt (UTC plus 2) 2013/01/24 21:07:03 absolutely. no master preferences file should be t
huangs 2013/01/25 01:13:23 !!! In this case, we should return EULA_YES, since
82 if (!install_prefs)
83 return EULA_NO;
84
85 bool eula_required = false;
86 // If kRequireEula value is absent, assume EULA is not required.
87 if (!install_prefs->GetBool(master_preferences::kRequireEula, &eula_required))
88 return EULA_YES;
89
90 return eula_required ? EULA_NO : EULA_YES;
91 }
92
93 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698