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

Side by Side Diff: extensions/browser/extension_prefs.cc

Issue 308003005: app_list: Drive app integration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add a is_sycable prop and use it instead of installed_by_default Created 6 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/extension_prefs.h" 5 #include "extensions/browser/extension_prefs.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/prefs/pref_notifier.h" 10 #include "base/prefs/pref_notifier.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 196
197 // A preference that stores the next threshold for displaying a notification 197 // A preference that stores the next threshold for displaying a notification
198 // when an extension or app consumes excessive disk space. This will not be 198 // when an extension or app consumes excessive disk space. This will not be
199 // set until the extension/app reaches the initial threshold. 199 // set until the extension/app reaches the initial threshold.
200 const char kPrefNextStorageThreshold[] = "next_storage_threshold"; 200 const char kPrefNextStorageThreshold[] = "next_storage_threshold";
201 201
202 // If this preference is set to true, notifications will be suppressed when an 202 // If this preference is set to true, notifications will be suppressed when an
203 // extension or app consumes excessive disk space. 203 // extension or app consumes excessive disk space.
204 const char kPrefDisableStorageNotifications[] = "disable_storage_notifications"; 204 const char kPrefDisableStorageNotifications[] = "disable_storage_notifications";
205 205
206 // A boolean preference that indicates whether the extension is allowed to be
207 // synced. Default is true.
not at google - send to devlin 2014/06/06 01:26:29 pet peeve is optional boolean values whose default
Yoyo Zhou 2014/06/06 01:39:27 You mean this const char? It's fine to go here if
xiyuan 2014/06/06 04:12:37 Changed the pref to "do_not_sync".
208 const char kPrefIsSyncable[] = "is_syncable";
209
206 // Provider of write access to a dictionary storing extension prefs. 210 // Provider of write access to a dictionary storing extension prefs.
207 class ScopedExtensionPrefUpdate : public DictionaryPrefUpdate { 211 class ScopedExtensionPrefUpdate : public DictionaryPrefUpdate {
208 public: 212 public:
209 ScopedExtensionPrefUpdate(PrefService* service, 213 ScopedExtensionPrefUpdate(PrefService* service,
210 const std::string& extension_id) : 214 const std::string& extension_id) :
211 DictionaryPrefUpdate(service, pref_names::kExtensions), 215 DictionaryPrefUpdate(service, pref_names::kExtensions),
212 extension_id_(extension_id) {} 216 extension_id_(extension_id) {}
213 217
214 virtual ~ScopedExtensionPrefUpdate() { 218 virtual ~ScopedExtensionPrefUpdate() {
215 } 219 }
(...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1736 } 1740 }
1737 std::string install_time_str; 1741 std::string install_time_str;
1738 if (!extension->GetString(kPrefInstallTime, &install_time_str)) 1742 if (!extension->GetString(kPrefInstallTime, &install_time_str))
1739 return base::Time(); 1743 return base::Time();
1740 int64 install_time_i64 = 0; 1744 int64 install_time_i64 = 0;
1741 if (!base::StringToInt64(install_time_str, &install_time_i64)) 1745 if (!base::StringToInt64(install_time_str, &install_time_i64))
1742 return base::Time(); 1746 return base::Time();
1743 return base::Time::FromInternalValue(install_time_i64); 1747 return base::Time::FromInternalValue(install_time_i64);
1744 } 1748 }
1745 1749
1750 bool ExtensionPrefs::IsSyncable(const std::string& extension_id) const {
1751 bool is_syncable;
1752 if (!ReadPrefAsBoolean(extension_id, kPrefIsSyncable, &is_syncable))
1753 return true;
1754
1755 return is_syncable;
1756 }
1757
1746 base::Time ExtensionPrefs::GetLastLaunchTime( 1758 base::Time ExtensionPrefs::GetLastLaunchTime(
1747 const std::string& extension_id) const { 1759 const std::string& extension_id) const {
1748 const base::DictionaryValue* extension = GetExtensionPref(extension_id); 1760 const base::DictionaryValue* extension = GetExtensionPref(extension_id);
1749 if (!extension) 1761 if (!extension)
1750 return base::Time(); 1762 return base::Time();
1751 1763
1752 std::string launch_time_str; 1764 std::string launch_time_str;
1753 if (!extension->GetString(kPrefLastLaunchTime, &launch_time_str)) 1765 if (!extension->GetString(kPrefLastLaunchTime, &launch_time_str))
1754 return base::Time(); 1766 return base::Time();
1755 int64 launch_time_i64 = 0; 1767 int64 launch_time_i64 = 0;
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
2158 if (!install_parameter.empty()) { 2170 if (!install_parameter.empty()) {
2159 extension_dict->Set(kPrefInstallParam, 2171 extension_dict->Set(kPrefInstallParam,
2160 new base::StringValue(install_parameter)); 2172 new base::StringValue(install_parameter));
2161 } 2173 }
2162 // We store prefs about LOAD extensions, but don't cache their manifest 2174 // We store prefs about LOAD extensions, but don't cache their manifest
2163 // since it may change on disk. 2175 // since it may change on disk.
2164 if (!Manifest::IsUnpackedLocation(extension->location())) { 2176 if (!Manifest::IsUnpackedLocation(extension->location())) {
2165 extension_dict->Set(kPrefManifest, 2177 extension_dict->Set(kPrefManifest,
2166 extension->manifest()->value()->DeepCopy()); 2178 extension->manifest()->value()->DeepCopy());
2167 } 2179 }
2180
2181 extension_dict->Set(kPrefIsSyncable,
2182 new base::FundamentalValue(extension->is_syncable()));
not at google - send to devlin 2014/06/06 01:26:29 only set it if its value is non-default
xiyuan 2014/06/06 04:12:37 Done.
2168 } 2183 }
2169 2184
2170 void ExtensionPrefs::InitExtensionControlledPrefs( 2185 void ExtensionPrefs::InitExtensionControlledPrefs(
2171 ExtensionPrefValueMap* value_map) { 2186 ExtensionPrefValueMap* value_map) {
2172 ExtensionIdList extension_ids; 2187 ExtensionIdList extension_ids;
2173 GetExtensions(&extension_ids); 2188 GetExtensions(&extension_ids);
2174 2189
2175 for (ExtensionIdList::iterator extension_id = extension_ids.begin(); 2190 for (ExtensionIdList::iterator extension_id = extension_ids.begin();
2176 extension_id != extension_ids.end(); 2191 extension_id != extension_ids.end();
2177 ++extension_id) { 2192 ++extension_id) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2261 extension_pref_value_map_->RegisterExtension( 2276 extension_pref_value_map_->RegisterExtension(
2262 extension_id, install_time, is_enabled, is_incognito_enabled); 2277 extension_id, install_time, is_enabled, is_incognito_enabled);
2263 2278
2264 FOR_EACH_OBSERVER( 2279 FOR_EACH_OBSERVER(
2265 ExtensionPrefsObserver, 2280 ExtensionPrefsObserver,
2266 observer_list_, 2281 observer_list_,
2267 OnExtensionRegistered(extension_id, install_time, is_enabled)); 2282 OnExtensionRegistered(extension_id, install_time, is_enabled));
2268 } 2283 }
2269 2284
2270 } // namespace extensions 2285 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698