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

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

Issue 131763004: Merge 242400 "Remove installation of Chrome Frame." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1750/src/
Patch Set: Created 6 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
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/file_util.h" 8 #include "base/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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 68 }
69 69
70 } // namespace 70 } // namespace
71 71
72 namespace installer { 72 namespace installer {
73 73
74 MasterPreferences::MasterPreferences() : distribution_(NULL), 74 MasterPreferences::MasterPreferences() : distribution_(NULL),
75 preferences_read_from_file_(false), 75 preferences_read_from_file_(false),
76 chrome_(true), 76 chrome_(true),
77 chrome_app_launcher_(false), 77 chrome_app_launcher_(false),
78 chrome_frame_(false),
79 multi_install_(false) { 78 multi_install_(false) {
80 InitializeFromCommandLine(*CommandLine::ForCurrentProcess()); 79 InitializeFromCommandLine(*CommandLine::ForCurrentProcess());
81 } 80 }
82 81
83 MasterPreferences::MasterPreferences(const CommandLine& cmd_line) 82 MasterPreferences::MasterPreferences(const CommandLine& cmd_line)
84 : distribution_(NULL), 83 : distribution_(NULL),
85 preferences_read_from_file_(false), 84 preferences_read_from_file_(false),
86 chrome_(true), 85 chrome_(true),
87 chrome_app_launcher_(false), 86 chrome_app_launcher_(false),
88 chrome_frame_(false),
89 multi_install_(false) { 87 multi_install_(false) {
90 InitializeFromCommandLine(cmd_line); 88 InitializeFromCommandLine(cmd_line);
91 } 89 }
92 90
93 MasterPreferences::MasterPreferences(const base::FilePath& prefs_path) 91 MasterPreferences::MasterPreferences(const base::FilePath& prefs_path)
94 : distribution_(NULL), 92 : distribution_(NULL),
95 preferences_read_from_file_(false), 93 preferences_read_from_file_(false),
96 chrome_(true), 94 chrome_(true),
97 chrome_app_launcher_(false), 95 chrome_app_launcher_(false),
98 chrome_frame_(false),
99 multi_install_(false) { 96 multi_install_(false) {
100 std::string json_data; 97 std::string json_data;
101 // Failure to read the file is ignored as |json_data| will be the empty string 98 // Failure to read the file is ignored as |json_data| will be the empty string
102 // and the remainder of this MasterPreferences object should still be 99 // and the remainder of this MasterPreferences object should still be
103 // initialized as best as possible. 100 // initialized as best as possible.
104 if (base::PathExists(prefs_path) && 101 if (base::PathExists(prefs_path) &&
105 !base::ReadFileToString(prefs_path, &json_data)) { 102 !base::ReadFileToString(prefs_path, &json_data)) {
106 LOG(ERROR) << "Failed to read preferences from " << prefs_path.value(); 103 LOG(ERROR) << "Failed to read preferences from " << prefs_path.value();
107 } 104 }
108 if (InitializeFromString(json_data)) 105 if (InitializeFromString(json_data))
109 preferences_read_from_file_ = true; 106 preferences_read_from_file_ = true;
110 } 107 }
111 108
112 MasterPreferences::MasterPreferences(const std::string& prefs) 109 MasterPreferences::MasterPreferences(const std::string& prefs)
113 : distribution_(NULL), 110 : distribution_(NULL),
114 preferences_read_from_file_(false), 111 preferences_read_from_file_(false),
115 chrome_(true), 112 chrome_(true),
116 chrome_app_launcher_(false), 113 chrome_app_launcher_(false),
117 chrome_frame_(false),
118 multi_install_(false) { 114 multi_install_(false) {
119 InitializeFromString(prefs); 115 InitializeFromString(prefs);
120 } 116 }
121 117
122 MasterPreferences::~MasterPreferences() { 118 MasterPreferences::~MasterPreferences() {
123 } 119 }
124 120
125 void MasterPreferences::InitializeFromCommandLine(const CommandLine& cmd_line) { 121 void MasterPreferences::InitializeFromCommandLine(const CommandLine& cmd_line) {
126 #if defined(OS_WIN) 122 #if defined(OS_WIN)
127 if (cmd_line.HasSwitch(installer::switches::kInstallerData)) { 123 if (cmd_line.HasSwitch(installer::switches::kInstallerData)) {
(...skipping 14 matching lines...) Expand all
142 const char* distribution_switch; 138 const char* distribution_switch;
143 } translate_switches[] = { 139 } translate_switches[] = {
144 { installer::switches::kAutoLaunchChrome, 140 { installer::switches::kAutoLaunchChrome,
145 installer::master_preferences::kAutoLaunchChrome }, 141 installer::master_preferences::kAutoLaunchChrome },
146 { installer::switches::kChromeAppHostDeprecated, 142 { installer::switches::kChromeAppHostDeprecated,
147 installer::master_preferences::kChromeAppHostDeprecated }, 143 installer::master_preferences::kChromeAppHostDeprecated },
148 { installer::switches::kChromeAppLauncher, 144 { installer::switches::kChromeAppLauncher,
149 installer::master_preferences::kChromeAppLauncher }, 145 installer::master_preferences::kChromeAppLauncher },
150 { installer::switches::kChrome, 146 { installer::switches::kChrome,
151 installer::master_preferences::kChrome }, 147 installer::master_preferences::kChrome },
152 { installer::switches::kChromeFrame,
153 installer::master_preferences::kChromeFrame },
154 { installer::switches::kDisableLogging, 148 { installer::switches::kDisableLogging,
155 installer::master_preferences::kDisableLogging }, 149 installer::master_preferences::kDisableLogging },
156 { installer::switches::kMsi, 150 { installer::switches::kMsi,
157 installer::master_preferences::kMsi }, 151 installer::master_preferences::kMsi },
158 { installer::switches::kMultiInstall, 152 { installer::switches::kMultiInstall,
159 installer::master_preferences::kMultiInstall }, 153 installer::master_preferences::kMultiInstall },
160 { installer::switches::kDoNotRegisterForUpdateLaunch, 154 { installer::switches::kDoNotRegisterForUpdateLaunch,
161 installer::master_preferences::kDoNotRegisterForUpdateLaunch }, 155 installer::master_preferences::kDoNotRegisterForUpdateLaunch },
162 { installer::switches::kDoNotLaunchChrome, 156 { installer::switches::kDoNotLaunchChrome,
163 installer::master_preferences::kDoNotLaunchChrome }, 157 installer::master_preferences::kDoNotLaunchChrome },
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 } 218 }
225 219
226 InitializeProductFlags(); 220 InitializeProductFlags();
227 EnforceLegacyPreferences(); 221 EnforceLegacyPreferences();
228 return data_is_valid; 222 return data_is_valid;
229 } 223 }
230 224
231 void MasterPreferences::InitializeProductFlags() { 225 void MasterPreferences::InitializeProductFlags() {
232 // Make sure we start out with the correct defaults. 226 // Make sure we start out with the correct defaults.
233 multi_install_ = false; 227 multi_install_ = false;
234 chrome_frame_ = false;
235 chrome_app_launcher_ = false; 228 chrome_app_launcher_ = false;
236 chrome_ = true; 229 chrome_ = true;
237 230
238 GetBool(installer::master_preferences::kMultiInstall, &multi_install_); 231 GetBool(installer::master_preferences::kMultiInstall, &multi_install_);
239 GetBool(installer::master_preferences::kChromeFrame, &chrome_frame_);
240 232
241 GetBool(installer::master_preferences::kChromeAppLauncher, 233 GetBool(installer::master_preferences::kChromeAppLauncher,
242 &chrome_app_launcher_); 234 &chrome_app_launcher_);
243 235
244 // The deprecated switch --app-host behaves like --app-launcher. 236 // The deprecated switch --app-host behaves like --app-launcher.
245 bool chrome_app_host = false; 237 bool chrome_app_host = false;
246 GetBool(installer::master_preferences::kChromeAppHostDeprecated, 238 GetBool(installer::master_preferences::kChromeAppHostDeprecated,
247 &chrome_app_host); 239 &chrome_app_host);
248 chrome_app_launcher_ = chrome_app_launcher_ || chrome_app_host; 240 chrome_app_launcher_ = chrome_app_launcher_ || chrome_app_host;
249 241
250 // When multi-install is specified, the checks are pretty simple (in theory): 242 // When multi-install is specified, the checks are pretty simple (in theory):
251 // In order to be installed/uninstalled, each product must have its switch 243 // In order to be installed/uninstalled, each product must have its switch
252 // present on the command line. 244 // present on the command line.
253 // Before multi-install was introduced however, we only supported installing 245 // When multi-install is not set, operate on Chrome.
254 // two products, Chrome and Chrome Frame. For the time being we need to
255 // continue to support this mode where multi-install is not set.
256 // So, when multi-install is not set, we continue to support mutually
257 // exclusive installation of Chrome and Chrome Frame.
258 if (multi_install_) { 246 if (multi_install_) {
259 if (!GetBool(installer::master_preferences::kChrome, &chrome_)) 247 if (!GetBool(installer::master_preferences::kChrome, &chrome_))
260 chrome_ = false; 248 chrome_ = false;
261 } else { 249 } else {
262 // If chrome-frame is on the command line however, we only install CF. 250 chrome_ = true;
263 chrome_ = !chrome_frame_;
264 } 251 }
265 } 252 }
266 253
267 void MasterPreferences::EnforceLegacyPreferences() { 254 void MasterPreferences::EnforceLegacyPreferences() {
268 // If create_all_shortcuts was explicitly set to false, set 255 // If create_all_shortcuts was explicitly set to false, set
269 // do_not_create_(desktop|quick_launch)_shortcut to true. 256 // do_not_create_(desktop|quick_launch)_shortcut to true.
270 bool create_all_shortcuts = true; 257 bool create_all_shortcuts = true;
271 GetBool(installer::master_preferences::kCreateAllShortcuts, 258 GetBool(installer::master_preferences::kCreateAllShortcuts,
272 &create_all_shortcuts); 259 &create_all_shortcuts);
273 if (!create_all_shortcuts) { 260 if (!create_all_shortcuts) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 master_dictionary_->GetString(prefs::kVariationsSeed, &variations_seed); 315 master_dictionary_->GetString(prefs::kVariationsSeed, &variations_seed);
329 return variations_seed; 316 return variations_seed;
330 } 317 }
331 318
332 // static 319 // static
333 const MasterPreferences& MasterPreferences::ForCurrentProcess() { 320 const MasterPreferences& MasterPreferences::ForCurrentProcess() {
334 return g_master_preferences.Get(); 321 return g_master_preferences.Get();
335 } 322 }
336 323
337 } // namespace installer 324 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/installer/util/master_preferences.h ('k') | chrome/installer/util/master_preferences_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698