| OLD | NEW |
| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } | 75 } |
| 76 | 76 |
| 77 } // namespace | 77 } // namespace |
| 78 | 78 |
| 79 namespace installer { | 79 namespace installer { |
| 80 | 80 |
| 81 MasterPreferences::MasterPreferences() : distribution_(NULL), | 81 MasterPreferences::MasterPreferences() : distribution_(NULL), |
| 82 preferences_read_from_file_(false), | 82 preferences_read_from_file_(false), |
| 83 chrome_(true), | 83 chrome_(true), |
| 84 chrome_app_host_(false), | 84 chrome_app_host_(false), |
| 85 chrome_app_launcher_(false), |
| 85 chrome_frame_(false), | 86 chrome_frame_(false), |
| 86 multi_install_(false) { | 87 multi_install_(false) { |
| 87 InitializeFromCommandLine(*CommandLine::ForCurrentProcess()); | 88 InitializeFromCommandLine(*CommandLine::ForCurrentProcess()); |
| 88 } | 89 } |
| 89 | 90 |
| 90 MasterPreferences::MasterPreferences(const CommandLine& cmd_line) | 91 MasterPreferences::MasterPreferences(const CommandLine& cmd_line) |
| 91 : distribution_(NULL), | 92 : distribution_(NULL), |
| 92 preferences_read_from_file_(false), | 93 preferences_read_from_file_(false), |
| 93 chrome_(true), | 94 chrome_(true), |
| 94 chrome_app_host_(false), | 95 chrome_app_host_(false), |
| 96 chrome_app_launcher_(false), |
| 95 chrome_frame_(false), | 97 chrome_frame_(false), |
| 96 multi_install_(false) { | 98 multi_install_(false) { |
| 97 InitializeFromCommandLine(cmd_line); | 99 InitializeFromCommandLine(cmd_line); |
| 98 } | 100 } |
| 99 | 101 |
| 100 MasterPreferences::MasterPreferences(const FilePath& prefs_path) | 102 MasterPreferences::MasterPreferences(const FilePath& prefs_path) |
| 101 : distribution_(NULL), preferences_read_from_file_(false), | 103 : distribution_(NULL), |
| 102 chrome_(true), chrome_app_host_(false), chrome_frame_(false), | 104 preferences_read_from_file_(false), |
| 105 chrome_(true), |
| 106 chrome_app_host_(false), |
| 107 chrome_app_launcher_(false), |
| 108 chrome_frame_(false), |
| 103 multi_install_(false) { | 109 multi_install_(false) { |
| 104 master_dictionary_.reset(ParseDistributionPreferences(prefs_path)); | 110 master_dictionary_.reset(ParseDistributionPreferences(prefs_path)); |
| 105 | 111 |
| 106 if (!master_dictionary_.get()) { | 112 if (!master_dictionary_.get()) { |
| 107 master_dictionary_.reset(new DictionaryValue()); | 113 master_dictionary_.reset(new DictionaryValue()); |
| 108 } else { | 114 } else { |
| 109 preferences_read_from_file_ = true; | 115 preferences_read_from_file_ = true; |
| 110 // Cache a pointer to the distribution dictionary. | 116 // Cache a pointer to the distribution dictionary. |
| 111 master_dictionary_->GetDictionary( | 117 master_dictionary_->GetDictionary( |
| 112 installer::master_preferences::kDistroDict, &distribution_); | 118 installer::master_preferences::kDistroDict, &distribution_); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 134 // distribution dictionary. Currently all switches added will be set to | 140 // distribution dictionary. Currently all switches added will be set to |
| 135 // 'true'. | 141 // 'true'. |
| 136 static const struct CmdLineSwitchToDistributionSwitch { | 142 static const struct CmdLineSwitchToDistributionSwitch { |
| 137 const char* cmd_line_switch; | 143 const char* cmd_line_switch; |
| 138 const char* distribution_switch; | 144 const char* distribution_switch; |
| 139 } translate_switches[] = { | 145 } translate_switches[] = { |
| 140 { installer::switches::kAutoLaunchChrome, | 146 { installer::switches::kAutoLaunchChrome, |
| 141 installer::master_preferences::kAutoLaunchChrome }, | 147 installer::master_preferences::kAutoLaunchChrome }, |
| 142 { installer::switches::kChromeAppHost, | 148 { installer::switches::kChromeAppHost, |
| 143 installer::master_preferences::kChromeAppHost }, | 149 installer::master_preferences::kChromeAppHost }, |
| 150 { installer::switches::kChromeAppLauncher, |
| 151 installer::master_preferences::kChromeAppLauncher }, |
| 144 { installer::switches::kChrome, | 152 { installer::switches::kChrome, |
| 145 installer::master_preferences::kChrome }, | 153 installer::master_preferences::kChrome }, |
| 146 { installer::switches::kChromeFrame, | 154 { installer::switches::kChromeFrame, |
| 147 installer::master_preferences::kChromeFrame }, | 155 installer::master_preferences::kChromeFrame }, |
| 148 { installer::switches::kChromeFrameReadyMode, | 156 { installer::switches::kChromeFrameReadyMode, |
| 149 installer::master_preferences::kChromeFrameReadyMode }, | 157 installer::master_preferences::kChromeFrameReadyMode }, |
| 150 { installer::switches::kCreateAllShortcuts, | 158 { installer::switches::kCreateAllShortcuts, |
| 151 installer::master_preferences::kCreateAllShortcuts }, | 159 installer::master_preferences::kCreateAllShortcuts }, |
| 152 { installer::switches::kDisableLogging, | 160 { installer::switches::kDisableLogging, |
| 153 installer::master_preferences::kDisableLogging }, | 161 installer::master_preferences::kDisableLogging }, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 215 |
| 208 InitializeProductFlags(); | 216 InitializeProductFlags(); |
| 209 #endif | 217 #endif |
| 210 } | 218 } |
| 211 | 219 |
| 212 void MasterPreferences::InitializeProductFlags() { | 220 void MasterPreferences::InitializeProductFlags() { |
| 213 // Make sure we start out with the correct defaults. | 221 // Make sure we start out with the correct defaults. |
| 214 multi_install_ = false; | 222 multi_install_ = false; |
| 215 chrome_frame_ = false; | 223 chrome_frame_ = false; |
| 216 chrome_app_host_ = false; | 224 chrome_app_host_ = false; |
| 225 chrome_app_launcher_ = false; |
| 217 chrome_ = true; | 226 chrome_ = true; |
| 218 | 227 |
| 219 GetBool(installer::master_preferences::kMultiInstall, &multi_install_); | 228 GetBool(installer::master_preferences::kMultiInstall, &multi_install_); |
| 220 GetBool(installer::master_preferences::kChromeFrame, &chrome_frame_); | 229 GetBool(installer::master_preferences::kChromeFrame, &chrome_frame_); |
| 221 GetBool(installer::master_preferences::kChromeAppHost, &chrome_app_host_); | 230 GetBool(installer::master_preferences::kChromeAppHost, &chrome_app_host_); |
| 231 GetBool(installer::master_preferences::kChromeAppLauncher, |
| 232 &chrome_app_launcher_); |
| 222 | 233 |
| 223 // When multi-install is specified, the checks are pretty simple (in theory): | 234 // When multi-install is specified, the checks are pretty simple (in theory): |
| 224 // In order to be installed/uninstalled, each product must have its switch | 235 // In order to be installed/uninstalled, each product must have its switch |
| 225 // present on the command line. | 236 // present on the command line. |
| 226 // Before multi-install was introduced however, we only supported installing | 237 // Before multi-install was introduced however, we only supported installing |
| 227 // two products, Chrome and Chrome Frame. For the time being we need to | 238 // two products, Chrome and Chrome Frame. For the time being we need to |
| 228 // continue to support this mode where multi-install is not set. | 239 // continue to support this mode where multi-install is not set. |
| 229 // So, when multi-install is not set, we continue to support mutually | 240 // So, when multi-install is not set, we continue to support mutually |
| 230 // exclusive installation of Chrome and Chrome Frame. | 241 // exclusive installation of Chrome and Chrome Frame. |
| 231 if (multi_install_) { | 242 if (multi_install_) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 bool MasterPreferences::GetExtensionsBlock(DictionaryValue** extensions) const { | 277 bool MasterPreferences::GetExtensionsBlock(DictionaryValue** extensions) const { |
| 267 return master_dictionary_->GetDictionary( | 278 return master_dictionary_->GetDictionary( |
| 268 master_preferences::kExtensionsBlock, extensions); | 279 master_preferences::kExtensionsBlock, extensions); |
| 269 } | 280 } |
| 270 | 281 |
| 271 // static | 282 // static |
| 272 const MasterPreferences& MasterPreferences::ForCurrentProcess() { | 283 const MasterPreferences& MasterPreferences::ForCurrentProcess() { |
| 273 return g_master_preferences.Get(); | 284 return g_master_preferences.Get(); |
| 274 } | 285 } |
| 275 } // installer_util | 286 } // installer_util |
| OLD | NEW |