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

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

Issue 811283002: [Installer] Cleaning up dead code for App Launcher / App Host installs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove query-eula-acceptance; changing ChannelInfo cleanup approach. Created 5 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
OLDNEW
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/installer/util/master_preferences.h" 5 #include "chrome/installer/util/master_preferences.h"
6 6
7 #include "base/environment.h" 7 #include "base/environment.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/json/json_string_value_serializer.h" 9 #include "base/json/json_string_value_serializer.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 return static_cast<base::DictionaryValue*>(root.release()); 66 return static_cast<base::DictionaryValue*>(root.release());
67 } 67 }
68 68
69 } // namespace 69 } // namespace
70 70
71 namespace installer { 71 namespace installer {
72 72
73 MasterPreferences::MasterPreferences() : distribution_(NULL), 73 MasterPreferences::MasterPreferences() : distribution_(NULL),
74 preferences_read_from_file_(false), 74 preferences_read_from_file_(false),
75 chrome_(true), 75 chrome_(true),
76 chrome_app_launcher_(false),
77 multi_install_(false) { 76 multi_install_(false) {
78 InitializeFromCommandLine(*CommandLine::ForCurrentProcess()); 77 InitializeFromCommandLine(*CommandLine::ForCurrentProcess());
79 } 78 }
80 79
81 MasterPreferences::MasterPreferences(const CommandLine& cmd_line) 80 MasterPreferences::MasterPreferences(const CommandLine& cmd_line)
82 : distribution_(NULL), 81 : distribution_(NULL),
83 preferences_read_from_file_(false), 82 preferences_read_from_file_(false),
84 chrome_(true), 83 chrome_(true),
85 chrome_app_launcher_(false),
86 multi_install_(false) { 84 multi_install_(false) {
87 InitializeFromCommandLine(cmd_line); 85 InitializeFromCommandLine(cmd_line);
88 } 86 }
89 87
90 MasterPreferences::MasterPreferences(const base::FilePath& prefs_path) 88 MasterPreferences::MasterPreferences(const base::FilePath& prefs_path)
91 : distribution_(NULL), 89 : distribution_(NULL),
92 preferences_read_from_file_(false), 90 preferences_read_from_file_(false),
93 chrome_(true), 91 chrome_(true),
94 chrome_app_launcher_(false),
95 multi_install_(false) { 92 multi_install_(false) {
96 std::string json_data; 93 std::string json_data;
97 // Failure to read the file is ignored as |json_data| will be the empty string 94 // Failure to read the file is ignored as |json_data| will be the empty string
98 // and the remainder of this MasterPreferences object should still be 95 // and the remainder of this MasterPreferences object should still be
99 // initialized as best as possible. 96 // initialized as best as possible.
100 if (base::PathExists(prefs_path) && 97 if (base::PathExists(prefs_path) &&
101 !base::ReadFileToString(prefs_path, &json_data)) { 98 !base::ReadFileToString(prefs_path, &json_data)) {
102 LOG(ERROR) << "Failed to read preferences from " << prefs_path.value(); 99 LOG(ERROR) << "Failed to read preferences from " << prefs_path.value();
103 } 100 }
104 if (InitializeFromString(json_data)) 101 if (InitializeFromString(json_data))
105 preferences_read_from_file_ = true; 102 preferences_read_from_file_ = true;
106 } 103 }
107 104
108 MasterPreferences::MasterPreferences(const std::string& prefs) 105 MasterPreferences::MasterPreferences(const std::string& prefs)
109 : distribution_(NULL), 106 : distribution_(NULL),
110 preferences_read_from_file_(false), 107 preferences_read_from_file_(false),
111 chrome_(true), 108 chrome_(true),
112 chrome_app_launcher_(false),
113 multi_install_(false) { 109 multi_install_(false) {
114 InitializeFromString(prefs); 110 InitializeFromString(prefs);
115 } 111 }
116 112
117 MasterPreferences::~MasterPreferences() { 113 MasterPreferences::~MasterPreferences() {
118 } 114 }
119 115
120 void MasterPreferences::InitializeFromCommandLine(const CommandLine& cmd_line) { 116 void MasterPreferences::InitializeFromCommandLine(const CommandLine& cmd_line) {
121 #if defined(OS_WIN) 117 #if defined(OS_WIN)
122 if (cmd_line.HasSwitch(installer::switches::kInstallerData)) { 118 if (cmd_line.HasSwitch(installer::switches::kInstallerData)) {
123 base::FilePath prefs_path(cmd_line.GetSwitchValuePath( 119 base::FilePath prefs_path(cmd_line.GetSwitchValuePath(
124 installer::switches::kInstallerData)); 120 installer::switches::kInstallerData));
125 this->MasterPreferences::MasterPreferences(prefs_path); 121 this->MasterPreferences::MasterPreferences(prefs_path);
126 } else { 122 } else {
127 master_dictionary_.reset(new base::DictionaryValue()); 123 master_dictionary_.reset(new base::DictionaryValue());
128 } 124 }
129 125
130 DCHECK(master_dictionary_.get()); 126 DCHECK(master_dictionary_.get());
131 127
132 // A simple map from command line switches to equivalent switches in the 128 // A simple map from command line switches to equivalent switches in the
133 // distribution dictionary. Currently all switches added will be set to 129 // distribution dictionary. Currently all switches added will be set to
134 // 'true'. 130 // 'true'.
135 static const struct CmdLineSwitchToDistributionSwitch { 131 static const struct CmdLineSwitchToDistributionSwitch {
136 const char* cmd_line_switch; 132 const char* cmd_line_switch;
137 const char* distribution_switch; 133 const char* distribution_switch;
138 } translate_switches[] = { 134 } translate_switches[] = {
139 { installer::switches::kAutoLaunchChrome, 135 { installer::switches::kAutoLaunchChrome,
140 installer::master_preferences::kAutoLaunchChrome }, 136 installer::master_preferences::kAutoLaunchChrome },
141 { installer::switches::kChromeAppHostDeprecated,
142 installer::master_preferences::kChromeAppHostDeprecated },
143 { installer::switches::kChromeAppLauncher,
144 installer::master_preferences::kChromeAppLauncher },
145 { installer::switches::kChrome, 137 { installer::switches::kChrome,
146 installer::master_preferences::kChrome }, 138 installer::master_preferences::kChrome },
147 { installer::switches::kDisableLogging, 139 { installer::switches::kDisableLogging,
148 installer::master_preferences::kDisableLogging }, 140 installer::master_preferences::kDisableLogging },
149 { installer::switches::kMsi, 141 { installer::switches::kMsi,
150 installer::master_preferences::kMsi }, 142 installer::master_preferences::kMsi },
151 { installer::switches::kMultiInstall, 143 { installer::switches::kMultiInstall,
152 installer::master_preferences::kMultiInstall }, 144 installer::master_preferences::kMultiInstall },
153 { installer::switches::kDoNotRegisterForUpdateLaunch, 145 { installer::switches::kDoNotRegisterForUpdateLaunch,
154 installer::master_preferences::kDoNotRegisterForUpdateLaunch }, 146 installer::master_preferences::kDoNotRegisterForUpdateLaunch },
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 } 209 }
218 210
219 InitializeProductFlags(); 211 InitializeProductFlags();
220 EnforceLegacyPreferences(); 212 EnforceLegacyPreferences();
221 return data_is_valid; 213 return data_is_valid;
222 } 214 }
223 215
224 void MasterPreferences::InitializeProductFlags() { 216 void MasterPreferences::InitializeProductFlags() {
225 // Make sure we start out with the correct defaults. 217 // Make sure we start out with the correct defaults.
226 multi_install_ = false; 218 multi_install_ = false;
227 chrome_app_launcher_ = false;
228 chrome_ = true; 219 chrome_ = true;
229 220
230 GetBool(installer::master_preferences::kMultiInstall, &multi_install_); 221 GetBool(installer::master_preferences::kMultiInstall, &multi_install_);
231 222
232 GetBool(installer::master_preferences::kChromeAppLauncher,
233 &chrome_app_launcher_);
234
235 // The deprecated switch --app-host behaves like --app-launcher.
236 bool chrome_app_host = false;
237 GetBool(installer::master_preferences::kChromeAppHostDeprecated,
238 &chrome_app_host);
239 chrome_app_launcher_ = chrome_app_launcher_ || chrome_app_host;
240
241 // When multi-install is specified, the checks are pretty simple (in theory): 223 // When multi-install is specified, the checks are pretty simple (in theory):
242 // In order to be installed/uninstalled, each product must have its switch 224 // In order to be installed/uninstalled, each product must have its switch
243 // present on the command line. 225 // present on the command line.
244 // When multi-install is not set, operate on Chrome. 226 // When multi-install is not set, operate on Chrome.
245 if (multi_install_) { 227 if (multi_install_) {
246 if (!GetBool(installer::master_preferences::kChrome, &chrome_)) 228 if (!GetBool(installer::master_preferences::kChrome, &chrome_))
247 chrome_ = false; 229 chrome_ = false;
248 } else { 230 } else {
249 chrome_ = true; 231 chrome_ = true;
250 } 232 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 } 309 }
328 return result; 310 return result;
329 } 311 }
330 312
331 // static 313 // static
332 const MasterPreferences& MasterPreferences::ForCurrentProcess() { 314 const MasterPreferences& MasterPreferences::ForCurrentProcess() {
333 return g_master_preferences.Get(); 315 return g_master_preferences.Get();
334 } 316 }
335 317
336 } // namespace installer 318 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698