summaryrefslogtreecommitdiffstats
path: root/extensions/browser
diff options
context:
space:
mode:
authorxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-14 20:28:05 +0000
committerxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-14 20:28:05 +0000
commit658eae5c45ea3e7f99741d84962434ecc782a038 (patch)
tree21fea6d0ea56bd04b4348b0e327bec6bacde4af7 /extensions/browser
parent986dd0ea53fe19d2ff9ffe7a41b71c3d8bfbd926 (diff)
downloadchromium_src-658eae5c45ea3e7f99741d84962434ecc782a038.zip
chromium_src-658eae5c45ea3e7f99741d84962434ecc782a038.tar.gz
chromium_src-658eae5c45ea3e7f99741d84962434ecc782a038.tar.bz2
Add a do_not_sync pref to ExtensionPrefs.
Split from https://codereview.chromium.org/308003005/ for extensions system changes that allows to install a none syncable Extension. - Add a do_not_sync pref to ExtensionPrefs; - Add a kInstallFlagDoNotSync that CrxInstaller uses to initialize the pref; - Update util::ShouldSyncApp and add ShouldSyncExtension to use the pref to skip sync in ExtensionSyncService; BUG=358791 Review URL: https://codereview.chromium.org/323843003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277269 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions/browser')
-rw-r--r--extensions/browser/extension_prefs.cc18
-rw-r--r--extensions/browser/extension_prefs.h3
-rw-r--r--extensions/browser/install_flag.h9
3 files changed, 27 insertions, 3 deletions
diff --git a/extensions/browser/extension_prefs.cc b/extensions/browser/extension_prefs.cc
index 6741c62..2dc5c37 100644
--- a/extensions/browser/extension_prefs.cc
+++ b/extensions/browser/extension_prefs.cc
@@ -196,6 +196,10 @@ const char kPrefInstallParam[] = "install_parameter";
// A list of installed ids and a signature.
const char kInstallSignature[] = "extensions.install_signature";
+// A boolean preference that indicates whether the extension should not be
+// synced. Default value is false.
+const char kPrefDoNotSync[] = "do_not_sync";
+
// Provider of write access to a dictionary storing extension prefs.
class ScopedExtensionPrefUpdate : public DictionaryPrefUpdate {
public:
@@ -1745,6 +1749,14 @@ base::Time ExtensionPrefs::GetInstallTime(
return base::Time::FromInternalValue(install_time_i64);
}
+bool ExtensionPrefs::DoNotSync(const std::string& extension_id) const {
+ bool do_not_sync;
+ if (!ReadPrefAsBoolean(extension_id, kPrefDoNotSync, &do_not_sync))
+ return false;
+
+ return do_not_sync;
+}
+
base::Time ExtensionPrefs::GetLastLaunchTime(
const std::string& extension_id) const {
const base::DictionaryValue* extension = GetExtensionPref(extension_id);
@@ -2130,6 +2142,12 @@ void ExtensionPrefs::PopulateExtensionInfoPrefs(
extension_dict->Set(kPrefManifest,
extension->manifest()->value()->DeepCopy());
}
+
+ // Only writes kPrefDoNotSync when it is not the default.
+ if (install_flags & kInstallFlagDoNotSync)
+ extension_dict->Set(kPrefDoNotSync, new base::FundamentalValue(true));
+ else
+ extension_dict->Remove(kPrefDoNotSync, NULL);
}
void ExtensionPrefs::InitExtensionControlledPrefs(
diff --git a/extensions/browser/extension_prefs.h b/extensions/browser/extension_prefs.h
index dbd734d..ad1712d 100644
--- a/extensions/browser/extension_prefs.h
+++ b/extensions/browser/extension_prefs.h
@@ -534,6 +534,9 @@ class ExtensionPrefs : public ExtensionScopedPrefs, public KeyedService {
// found.
base::Time GetInstallTime(const std::string& extension_id) const;
+ // Returns true if the extension should not be synced.
+ bool DoNotSync(const std::string& extension_id) const;
+
// Gets/sets the last launch time of an extension.
base::Time GetLastLaunchTime(const std::string& extension_id) const;
void SetLastLaunchTime(const std::string& extension_id,
diff --git a/extensions/browser/install_flag.h b/extensions/browser/install_flag.h
index b8eac99..f157a6e 100644
--- a/extensions/browser/install_flag.h
+++ b/extensions/browser/install_flag.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_EXTENSIONS_INSTALL_FLAG_H_
-#define CHROME_BROWSER_EXTENSIONS_INSTALL_FLAG_H_
+#ifndef EXTENSIONS_BROWSER_INSTALL_FLAG_H_
+#define EXTENSIONS_BROWSER_INSTALL_FLAG_H_
namespace extensions {
@@ -24,8 +24,11 @@ enum InstallFlag {
// Install the extension immediately, don't wait until idle.
kInstallFlagInstallImmediately = 1 << 3,
+
+ // Do not sync the installed extension.
+ kInstallFlagDoNotSync = 1 << 4,
};
} // namespace extensions
-#endif // CHROME_BROWSER_EXTENSIONS_INSTALL_FLAG_H_
+#endif // EXTENSIONS_BROWSER_INSTALL_FLAG_H_