summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorvasilii@chromium.org <vasilii@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-24 13:16:06 +0000
committervasilii@chromium.org <vasilii@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-24 13:16:06 +0000
commitd8fd0fdd98c40468a5715fc0d6da37b8cd0033cf (patch)
treea61f02299399d0f1550514988a160933d046012c /extensions
parent9cfa98378aeb762634dd1e39510bbca38a4b22b0 (diff)
downloadchromium_src-d8fd0fdd98c40468a5715fc0d6da37b8cd0033cf.zip
chromium_src-d8fd0fdd98c40468a5715fc0d6da37b8cd0033cf.tar.gz
chromium_src-d8fd0fdd98c40468a5715fc0d6da37b8cd0033cf.tar.bz2
Introduce an extension parameter which is used to customize the extension. It's available for external extensions on Windows by using a registry key. The installer can set this parameter per user.
BUG=267510 TBR=nkostylev@chromium.org,estade@chromium.org Review URL: https://codereview.chromium.org/196663003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258919 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions')
-rw-r--r--extensions/browser/extension_prefs.cc48
-rw-r--r--extensions/browser/extension_prefs.h14
-rw-r--r--extensions/browser/external_provider_interface.h1
3 files changed, 54 insertions, 9 deletions
diff --git a/extensions/browser/extension_prefs.cc b/extensions/browser/extension_prefs.cc
index 23513c8..67e5f73 100644
--- a/extensions/browser/extension_prefs.cc
+++ b/extensions/browser/extension_prefs.cc
@@ -184,6 +184,9 @@ const char kPrefLastLaunchTime[] = "last_launch_time";
// of time.
const char kPrefEvictedEphemeralApp[] = "evicted_ephemeral_app";
+// Am installation parameter bundled with an extension.
+const char kPrefInstallParam[] = "install_parameter";
+
// A list of installed ids and a signature.
const char kInstallSignature[] = "extensions.install_signature";
@@ -1117,12 +1120,17 @@ void ExtensionPrefs::OnExtensionInstalled(
const Extension* extension,
Extension::State initial_state,
bool blacklisted_for_malware,
- const syncer::StringOrdinal& page_ordinal) {
+ const syncer::StringOrdinal& page_ordinal,
+ const std::string& install_parameter) {
ScopedExtensionPrefUpdate update(prefs_, extension->id());
base::DictionaryValue* extension_dict = update.Get();
const base::Time install_time = time_provider_->GetCurrentTime();
- PopulateExtensionInfoPrefs(extension, install_time, initial_state,
- blacklisted_for_malware, extension_dict);
+ PopulateExtensionInfoPrefs(extension,
+ install_time,
+ initial_state,
+ blacklisted_for_malware,
+ install_parameter,
+ extension_dict);
FinishExtensionInfoPrefs(extension->id(), install_time,
extension->RequiresSortOrdinal(),
page_ordinal, extension_dict);
@@ -1340,10 +1348,14 @@ void ExtensionPrefs::SetDelayedInstallInfo(
Extension::State initial_state,
bool blacklisted_for_malware,
DelayReason delay_reason,
- const syncer::StringOrdinal& page_ordinal) {
+ const syncer::StringOrdinal& page_ordinal,
+ const std::string& install_parameter) {
base::DictionaryValue* extension_dict = new base::DictionaryValue();
- PopulateExtensionInfoPrefs(extension, time_provider_->GetCurrentTime(),
- initial_state, blacklisted_for_malware,
+ PopulateExtensionInfoPrefs(extension,
+ time_provider_->GetCurrentTime(),
+ initial_state,
+ blacklisted_for_malware,
+ install_parameter,
extension_dict);
// Add transient data that is needed by FinishDelayedInstallInfo(), but
@@ -1767,6 +1779,25 @@ void ExtensionPrefs::SetInstallSignature(
}
}
+std::string ExtensionPrefs::GetInstallParam(
+ const std::string& extension_id) const {
+ const base::DictionaryValue* extension = GetExtensionPref(extension_id);
+ if (!extension) {
+ NOTREACHED();
+ return std::string();
+ }
+ std::string install_parameter;
+ if (!extension->GetString(kPrefInstallParam, &install_parameter))
+ return std::string();
+ return install_parameter;
+}
+
+void ExtensionPrefs::SetInstallParam(const std::string& extension_id,
+ const std::string& install_parameter) {
+ UpdateExtensionPref(extension_id,
+ kPrefInstallParam,
+ new base::StringValue(install_parameter));
+}
ExtensionPrefs::ExtensionPrefs(
PrefService* prefs,
@@ -1902,6 +1933,7 @@ void ExtensionPrefs::PopulateExtensionInfoPrefs(
const base::Time install_time,
Extension::State initial_state,
bool blacklisted_for_malware,
+ const std::string& install_parameter,
base::DictionaryValue* extension_dict) {
// Leave the state blank for component extensions so that old chrome versions
// loading new profiles do not fail in GetInstalledExtensionInfo. Older
@@ -1932,6 +1964,10 @@ void ExtensionPrefs::PopulateExtensionInfoPrefs(
base::FilePath::StringType path = MakePathRelative(install_directory_,
extension->path());
extension_dict->Set(kPrefPath, new base::StringValue(path));
+ if (!install_parameter.empty()) {
+ extension_dict->Set(kPrefInstallParam,
+ new base::StringValue(install_parameter));
+ }
// We store prefs about LOAD extensions, but don't cache their manifest
// since it may change on disk.
if (!Manifest::IsUnpackedLocation(extension->location())) {
diff --git a/extensions/browser/extension_prefs.h b/extensions/browser/extension_prefs.h
index e288f94..5fc2f83 100644
--- a/extensions/browser/extension_prefs.h
+++ b/extensions/browser/extension_prefs.h
@@ -180,7 +180,8 @@ class ExtensionPrefs : public ExtensionScopedPrefs, public KeyedService {
void OnExtensionInstalled(const Extension* extension,
Extension::State initial_state,
bool blacklisted_for_malware,
- const syncer::StringOrdinal& page_ordinal);
+ const syncer::StringOrdinal& page_ordinal,
+ const std::string& install_parameter);
// Called when an extension is uninstalled, so that prefs get cleaned up.
void OnExtensionUninstalled(const std::string& extension_id,
@@ -417,7 +418,8 @@ class ExtensionPrefs : public ExtensionScopedPrefs, public KeyedService {
Extension::State initial_state,
bool blacklisted_for_malware,
DelayReason delay_reason,
- const syncer::StringOrdinal& page_ordinal);
+ const syncer::StringOrdinal& page_ordinal,
+ const std::string& install_parameter);
// Removes any delayed install information we have for the given
// |extension_id|. Returns true if there was info to remove; false otherwise.
@@ -491,7 +493,7 @@ class ExtensionPrefs : public ExtensionScopedPrefs, public KeyedService {
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
- bool extensions_disabled() { return extensions_disabled_; }
+ bool extensions_disabled() const { return extensions_disabled_; }
ContentSettingsStore* content_settings_store() {
return content_settings_store_.get();
@@ -525,6 +527,11 @@ class ExtensionPrefs : public ExtensionScopedPrefs, public KeyedService {
const base::DictionaryValue* GetInstallSignature();
void SetInstallSignature(const base::DictionaryValue* signature);
+ // The installation parameter associated with the extension.
+ std::string GetInstallParam(const std::string& extension_id) const;
+ void SetInstallParam(const std::string& extension_id,
+ const std::string& install_parameter);
+
private:
friend class ExtensionPrefsBlacklistedExtensions; // Unit test.
friend class ExtensionPrefsUninstallExtension; // Unit test.
@@ -625,6 +632,7 @@ class ExtensionPrefs : public ExtensionScopedPrefs, public KeyedService {
const base::Time install_time,
Extension::State initial_state,
bool blacklisted_for_malware,
+ const std::string& install_parameter,
base::DictionaryValue* extension_dict);
// Helper function to complete initialization of the values in
diff --git a/extensions/browser/external_provider_interface.h b/extensions/browser/external_provider_interface.h
index 5c96773..dd80e31 100644
--- a/extensions/browser/external_provider_interface.h
+++ b/extensions/browser/external_provider_interface.h
@@ -46,6 +46,7 @@ class ExternalProviderInterface {
// location.
virtual bool OnExternalExtensionUpdateUrlFound(
const std::string& id,
+ const std::string& install_parameter,
const GURL& update_url,
Manifest::Location location,
int creation_flags,