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

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

Issue 8654001: Reland restrict extension features based on the extension type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser/extensions/extension_prefs.h" 5 #include "chrome/browser/extensions/extension_prefs.h"
6 6
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/extensions/extension_pref_store.h" 10 #include "chrome/browser/extensions/extension_pref_store.h"
11 #include "chrome/browser/prefs/pref_notifier.h" 11 #include "chrome/browser/prefs/pref_notifier.h"
12 #include "chrome/browser/prefs/scoped_user_pref_update.h" 12 #include "chrome/browser/prefs/scoped_user_pref_update.h"
13 #include "chrome/common/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
14 #include "chrome/common/extensions/extension.h" 14 #include "chrome/common/extensions/extension.h"
15 #include "chrome/common/extensions/manifest.h"
15 #include "chrome/common/extensions/url_pattern.h" 16 #include "chrome/common/extensions/url_pattern.h"
16 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
17 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
18 #include "content/public/browser/notification_service.h" 19 #include "content/public/browser/notification_service.h"
19 20
20 using base::Time; 21 using base::Time;
21 22
22 namespace { 23 namespace {
23 24
24 // The number of apps per page. This isn't a hard limit, but new apps installed 25 // The number of apps per page. This isn't a hard limit, but new apps installed
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 extension_dict->Set(kPrefContentSettings, new ListValue()); 1094 extension_dict->Set(kPrefContentSettings, new ListValue());
1094 extension_dict->Set(kPrefIncognitoContentSettings, new ListValue()); 1095 extension_dict->Set(kPrefIncognitoContentSettings, new ListValue());
1095 1096
1096 FilePath::StringType path = MakePathRelative(install_directory_, 1097 FilePath::StringType path = MakePathRelative(install_directory_,
1097 extension->path()); 1098 extension->path());
1098 extension_dict->Set(kPrefPath, Value::CreateStringValue(path)); 1099 extension_dict->Set(kPrefPath, Value::CreateStringValue(path));
1099 // We store prefs about LOAD extensions, but don't cache their manifest 1100 // We store prefs about LOAD extensions, but don't cache their manifest
1100 // since it may change on disk. 1101 // since it may change on disk.
1101 if (extension->location() != Extension::LOAD) { 1102 if (extension->location() != Extension::LOAD) {
1102 extension_dict->Set(kPrefManifest, 1103 extension_dict->Set(kPrefManifest,
1103 extension->manifest_value()->DeepCopy()); 1104 extension->manifest()->value()->DeepCopy());
1104 } 1105 }
1105 1106
1106 if (extension->is_app()) { 1107 if (extension->is_app()) {
1107 if (page_index == -1) 1108 if (page_index == -1)
1108 page_index = GetNaturalAppPageIndex(); 1109 page_index = GetNaturalAppPageIndex();
1109 extension_dict->Set(kPrefPageIndex, 1110 extension_dict->Set(kPrefPageIndex,
1110 Value::CreateIntegerValue(page_index)); 1111 Value::CreateIntegerValue(page_index));
1111 extension_dict->Set(kPrefAppLaunchIndex, 1112 extension_dict->Set(kPrefAppLaunchIndex,
1112 Value::CreateIntegerValue(GetNextAppLaunchIndex(page_index))); 1113 Value::CreateIntegerValue(GetNextAppLaunchIndex(page_index)));
1113 } 1114 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 } 1184 }
1184 1185
1185 void ExtensionPrefs::UpdateManifest(const Extension* extension) { 1186 void ExtensionPrefs::UpdateManifest(const Extension* extension) {
1186 if (extension->location() != Extension::LOAD) { 1187 if (extension->location() != Extension::LOAD) {
1187 const DictionaryValue* extension_dict = GetExtensionPref(extension->id()); 1188 const DictionaryValue* extension_dict = GetExtensionPref(extension->id());
1188 if (!extension_dict) 1189 if (!extension_dict)
1189 return; 1190 return;
1190 DictionaryValue* old_manifest = NULL; 1191 DictionaryValue* old_manifest = NULL;
1191 bool update_required = 1192 bool update_required =
1192 !extension_dict->GetDictionary(kPrefManifest, &old_manifest) || 1193 !extension_dict->GetDictionary(kPrefManifest, &old_manifest) ||
1193 !extension->manifest_value()->Equals(old_manifest); 1194 !extension->manifest()->value()->Equals(old_manifest);
1194 if (update_required) { 1195 if (update_required) {
1195 UpdateExtensionPref(extension->id(), kPrefManifest, 1196 UpdateExtensionPref(extension->id(), kPrefManifest,
1196 extension->manifest_value()->DeepCopy()); 1197 extension->manifest()->value()->DeepCopy());
1197 } 1198 }
1198 } 1199 }
1199 } 1200 }
1200 1201
1201 FilePath ExtensionPrefs::GetExtensionPath(const std::string& extension_id) { 1202 FilePath ExtensionPrefs::GetExtensionPath(const std::string& extension_id) {
1202 const DictionaryValue* dict = GetExtensionPref(extension_id); 1203 const DictionaryValue* dict = GetExtensionPref(extension_id);
1203 if (!dict) 1204 if (!dict)
1204 return FilePath(); 1205 return FilePath();
1205 1206
1206 std::string path; 1207 std::string path;
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
1822 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, 1823 prefs->RegisterListPref(prefs::kExtensionInstallAllowList,
1823 PrefService::UNSYNCABLE_PREF); 1824 PrefService::UNSYNCABLE_PREF);
1824 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, 1825 prefs->RegisterListPref(prefs::kExtensionInstallDenyList,
1825 PrefService::UNSYNCABLE_PREF); 1826 PrefService::UNSYNCABLE_PREF);
1826 prefs->RegisterListPref(prefs::kExtensionInstallForceList, 1827 prefs->RegisterListPref(prefs::kExtensionInstallForceList,
1827 PrefService::UNSYNCABLE_PREF); 1828 PrefService::UNSYNCABLE_PREF);
1828 prefs->RegisterStringPref(kWebStoreLogin, 1829 prefs->RegisterStringPref(kWebStoreLogin,
1829 std::string() /* default_value */, 1830 std::string() /* default_value */,
1830 PrefService::UNSYNCABLE_PREF); 1831 PrefService::UNSYNCABLE_PREF);
1831 } 1832 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698