| Index: chrome/installer/util/master_preferences.h
|
| ===================================================================
|
| --- chrome/installer/util/master_preferences.h (revision 64604)
|
| +++ chrome/installer/util/master_preferences.h (working copy)
|
| @@ -12,8 +12,8 @@
|
| #include <vector>
|
|
|
| #include "base/command_line.h"
|
| +#include "base/scoped_ptr.h"
|
| #include "googleurl/src/gurl.h"
|
| -#include "chrome/installer/util/master_preferences_constants.h"
|
|
|
| class DictionaryValue;
|
| class FilePath;
|
| @@ -24,30 +24,6 @@
|
| // values in the user profile at first run.
|
| const char kDefaultMasterPrefs[] = "master_preferences";
|
|
|
| -// Parse command line and read master preferences, if present, to get
|
| -// distribution related install options. Merge them if any command line
|
| -// options present (command line value takes precedence).
|
| -DictionaryValue* GetInstallPreferences(const CommandLine& cmd_line);
|
| -
|
| -// Gets the value of given boolean preference |name| from |prefs| dictionary
|
| -// which is assumed to contain a dictionary named "distribution". Returns
|
| -// true if the value is read successfully, otherwise false.
|
| -bool GetDistroBooleanPreference(const DictionaryValue* prefs,
|
| - const std::string& name,
|
| - bool* value);
|
| -
|
| -// This function gets value of a string preference from master
|
| -// preferences. Returns true if the value is read successfully, otherwise false.
|
| -bool GetDistroStringPreference(const DictionaryValue* prefs,
|
| - const std::string& name,
|
| - std::string* value);
|
| -
|
| -// This function gets value of an integer preference from master
|
| -// preferences. Returns true if the value is read successfully, otherwise false.
|
| -bool GetDistroIntegerPreference(const DictionaryValue* prefs,
|
| - const std::string& name,
|
| - int* value);
|
| -
|
| // The master preferences is a JSON file with the same entries as the
|
| // 'Default\Preferences' file. This function parses the distribution
|
| // section of the preferences file.
|
| @@ -93,69 +69,95 @@
|
| // installation properties. This entry will be ignored at other times.
|
| // This function parses the 'distribution' entry and returns a combination
|
| // of MasterPrefResult.
|
| -DictionaryValue* ParseDistributionPreferences(
|
| - const FilePath& master_prefs_path);
|
| +class MasterPreferences {
|
| + public:
|
| + // Parses the command line and optionally reads the master preferences file
|
| + // to get distribution related install options (if the "installerdata" switch
|
| + // is present in the command line.
|
| + // The options from the preference file and command line are merged, with the
|
| + // ones from the command line taking precedence in case of a conflict.
|
| + explicit MasterPreferences(const CommandLine& cmd_line);
|
|
|
| -// As part of the master preferences an optional section indicates the tabs
|
| -// to open during first run. An example is the following:
|
| -//
|
| -// {
|
| -// "first_run_tabs": [
|
| -// "http://google.com/f1",
|
| -// "https://google.com/f2"
|
| -// ]
|
| -// }
|
| -//
|
| -// Note that the entries are usually urls but they don't have to.
|
| -//
|
| -// This function retuns the list as a vector of GURLs. If the master
|
| -// preferences file does not contain such list the vector is empty.
|
| -std::vector<GURL> GetFirstRunTabs(const DictionaryValue* prefs);
|
| + // Parses a specific preferences file and does not merge any command line
|
| + // switches with the distribution dictionary.
|
| + explicit MasterPreferences(const FilePath& prefs_path);
|
|
|
| -// Sets the value of given boolean preference |name| in "distribution"
|
| -// dictionary inside |prefs| dictionary.
|
| -bool SetDistroBooleanPreference(DictionaryValue* prefs,
|
| - const std::string& name,
|
| - bool value);
|
| + ~MasterPreferences();
|
|
|
| -// The master preferences can also contain a regular extensions
|
| -// preference block. If so, the extensions referenced there will be
|
| -// installed during the first run experience.
|
| -// An extension can go in the master prefs needs just the basic
|
| -// elements such as:
|
| -// 1- An extension entry under settings, assigned by the gallery
|
| -// 2- The "location" : 1 entry
|
| -// 3- A minimal "manifest" block with key, name, permissions, update url
|
| -// and version. The version needs to be lower than the version of
|
| -// the extension that is hosted in the gallery.
|
| -// 4- The "path" entry with the version as last component
|
| -// 5- The "state" : 1 entry
|
| -//
|
| -// The following is an example of a master pref file that installs
|
| -// Google XYZ:
|
| -//
|
| -// {
|
| -// "extensions": {
|
| -// "settings": {
|
| -// "ppflmjolhbonpkbkooiamcnenbmbjcbb": {
|
| -// "location": 1,
|
| -// "manifest": {
|
| -// "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4<rest of key ommited>",
|
| -// "name": "Google XYZ (Installing...)",
|
| -// "permissions": [ "tabs", "http://xyz.google.com/" ],
|
| -// "update_url": "http://fixme.com/fixme/fixme/crx",
|
| -// "version": "0.0"
|
| -// },
|
| -// "path": "ppflmjolhbonpkbkooiamcnenbmbjcbb\\0.0",
|
| -// "state": 1
|
| -// }
|
| -// }
|
| -// }
|
| -// }
|
| -//
|
| -bool HasExtensionsBlock(const DictionaryValue* prefs,
|
| - DictionaryValue** extensions);
|
| + // Each of the Get methods below returns true if the named value was found in
|
| + // the distribution dictionary and its value assigned to the 'value'
|
| + // parameter. If the value wasn't found, the return value is false.
|
| + bool GetBool(const std::string& name, bool* value) const;
|
| + bool GetInt(const std::string& name, int* value) const;
|
| + bool GetString(const std::string& name, std::string* value) const;
|
|
|
| + // As part of the master preferences an optional section indicates the tabs
|
| + // to open during first run. An example is the following:
|
| + //
|
| + // {
|
| + // "first_run_tabs": [
|
| + // "http://google.com/f1",
|
| + // "https://google.com/f2"
|
| + // ]
|
| + // }
|
| + //
|
| + // Note that the entries are usually urls but they don't have to be.
|
| + //
|
| + // This function returns the list as a vector of GURLs. If the master
|
| + // preferences file does not contain such a list the vector is empty.
|
| + std::vector<GURL> GetFirstRunTabs() const;
|
| +
|
| + // The master preferences can also contain a regular extensions
|
| + // preference block. If so, the extensions referenced there will be
|
| + // installed during the first run experience.
|
| + // An extension can go in the master prefs needs just the basic
|
| + // elements such as:
|
| + // 1- An extension entry under settings, assigned by the gallery
|
| + // 2- The "location" : 1 entry
|
| + // 3- A minimal "manifest" block with key, name, permissions, update url
|
| + // and version. The version needs to be lower than the version of
|
| + // the extension that is hosted in the gallery.
|
| + // 4- The "path" entry with the version as last component
|
| + // 5- The "state" : 1 entry
|
| + //
|
| + // The following is an example of a master pref file that installs
|
| + // Google XYZ:
|
| + //
|
| + // {
|
| + // "extensions": {
|
| + // "settings": {
|
| + // "ppflmjolhbonpkbkooiamcnenbmbjcbb": {
|
| + // "location": 1,
|
| + // "manifest": {
|
| + // "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4<rest of key ommited>",
|
| + // "name": "Google XYZ (Installing...)",
|
| + // "permissions": [ "tabs", "http://xyz.google.com/" ],
|
| + // "update_url": "http://fixme.com/fixme/fixme/crx",
|
| + // "version": "0.0"
|
| + // },
|
| + // "path": "ppflmjolhbonpkbkooiamcnenbmbjcbb\\0.0",
|
| + // "state": 1
|
| + // }
|
| + // }
|
| + // }
|
| + // }
|
| + //
|
| + bool GetExtensionsBlock(DictionaryValue** extensions) const;
|
| +
|
| + // Returns true iff the master preferences were successfully read from a file.
|
| + bool read_from_file() const {
|
| + return preferences_read_from_file_;
|
| + }
|
| +
|
| + protected:
|
| + scoped_ptr<DictionaryValue> master_dictionary_;
|
| + DictionaryValue* distribution_;
|
| + bool preferences_read_from_file_;
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(MasterPreferences);
|
| +};
|
| +
|
| } // namespace installer_util
|
|
|
| #endif // CHROME_INSTALLER_UTIL_MASTER_PREFERENCES_H_
|
|
|