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

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

Issue 149213003: Cleanup: Fix some lint/style errors in extensions code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 10 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
« no previous file with comments | « chrome/renderer/resources/extensions/permissions_custom_bindings.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 void ExtensionPrefs::SetActiveBit(const std::string& extension_id, 862 void ExtensionPrefs::SetActiveBit(const std::string& extension_id,
863 bool active) { 863 bool active) {
864 UpdateExtensionPref(extension_id, kActiveBit, 864 UpdateExtensionPref(extension_id, kActiveBit,
865 new base::FundamentalValue(active)); 865 new base::FundamentalValue(active));
866 } 866 }
867 867
868 void ExtensionPrefs::MigratePermissions(const ExtensionIdList& extension_ids) { 868 void ExtensionPrefs::MigratePermissions(const ExtensionIdList& extension_ids) {
869 PermissionsInfo* info = PermissionsInfo::GetInstance(); 869 PermissionsInfo* info = PermissionsInfo::GetInstance();
870 for (ExtensionIdList::const_iterator ext_id = 870 for (ExtensionIdList::const_iterator ext_id =
871 extension_ids.begin(); ext_id != extension_ids.end(); ++ext_id) { 871 extension_ids.begin(); ext_id != extension_ids.end(); ++ext_id) {
872
873 // An extension's granted permissions need to be migrated if the 872 // An extension's granted permissions need to be migrated if the
874 // full_access bit is present. This bit was always present in the previous 873 // full_access bit is present. This bit was always present in the previous
875 // scheme and is never present now. 874 // scheme and is never present now.
876 bool full_access; 875 bool full_access;
877 const base::DictionaryValue* ext = GetExtensionPref(*ext_id); 876 const base::DictionaryValue* ext = GetExtensionPref(*ext_id);
878 if (!ext || !ext->GetBoolean(kPrefOldGrantedFullAccess, &full_access)) 877 if (!ext || !ext->GetBoolean(kPrefOldGrantedFullAccess, &full_access))
879 continue; 878 continue;
880 879
881 // Remove the full access bit (empty list will get trimmed). 880 // Remove the full access bit (empty list will get trimmed).
882 UpdateExtensionPref( 881 UpdateExtensionPref(
883 *ext_id, kPrefOldGrantedFullAccess, new base::ListValue()); 882 *ext_id, kPrefOldGrantedFullAccess, new base::ListValue());
884 883
885 // Add the plugin permission if the full access bit was set. 884 // Add the plugin permission if the full access bit was set.
886 if (full_access) { 885 if (full_access) {
887 const base::ListValue* apis = NULL; 886 const base::ListValue* apis = NULL;
888 base::ListValue* new_apis = NULL; 887 base::ListValue* new_apis = NULL;
889 888
890 std::string granted_apis = 889 std::string granted_apis = JoinPrefs(kPrefGrantedPermissions, kPrefAPIs);
891 JoinPrefs(kPrefGrantedPermissions, kPrefAPIs);
892 if (ext->GetList(kPrefOldGrantedAPIs, &apis)) 890 if (ext->GetList(kPrefOldGrantedAPIs, &apis))
893 new_apis = apis->DeepCopy(); 891 new_apis = apis->DeepCopy();
894 else 892 else
895 new_apis = new base::ListValue(); 893 new_apis = new base::ListValue();
896 894
897 std::string plugin_name = info->GetByID( 895 std::string plugin_name = info->GetByID(APIPermission::kPlugin)->name();
898 APIPermission::kPlugin)->name();
899 new_apis->Append(new base::StringValue(plugin_name)); 896 new_apis->Append(new base::StringValue(plugin_name));
900 UpdateExtensionPref(*ext_id, granted_apis, new_apis); 897 UpdateExtensionPref(*ext_id, granted_apis, new_apis);
901 } 898 }
902 899
903 // The granted permissions originally only held the effective hosts, 900 // The granted permissions originally only held the effective hosts,
904 // which are a combination of host and user script host permissions. 901 // which are a combination of host and user script host permissions.
905 // We now maintain these lists separately. For migration purposes, it 902 // We now maintain these lists separately. For migration purposes, it
906 // does not matter how we treat the old effective hosts as long as the 903 // does not matter how we treat the old effective hosts as long as the
907 // new effective hosts will be the same, so we move them to explicit 904 // new effective hosts will be the same, so we move them to explicit
908 // host permissions. 905 // host permissions.
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 return ext; 1661 return ext;
1665 } 1662 }
1666 1663
1667 void ExtensionPrefs::SetGeometryCache( 1664 void ExtensionPrefs::SetGeometryCache(
1668 const std::string& extension_id, 1665 const std::string& extension_id,
1669 scoped_ptr<base::DictionaryValue> cache) { 1666 scoped_ptr<base::DictionaryValue> cache) {
1670 UpdateExtensionPref(extension_id, kPrefGeometryCache, cache.release()); 1667 UpdateExtensionPref(extension_id, kPrefGeometryCache, cache.release());
1671 } 1668 }
1672 1669
1673 const base::DictionaryValue* ExtensionPrefs::GetInstallSignature() { 1670 const base::DictionaryValue* ExtensionPrefs::GetInstallSignature() {
1674 return prefs_->GetDictionary(kInstallSignature); 1671 return prefs_->GetDictionary(kInstallSignature);
1675 } 1672 }
1676 1673
1677 void ExtensionPrefs::SetInstallSignature( 1674 void ExtensionPrefs::SetInstallSignature(
1678 const base::DictionaryValue* signature) { 1675 const base::DictionaryValue* signature) {
1679 if (signature) { 1676 if (signature) {
1680 prefs_->Set(kInstallSignature, *signature); 1677 prefs_->Set(kInstallSignature, *signature);
1681 DVLOG(1) << "SetInstallSignature - saving"; 1678 DVLOG(1) << "SetInstallSignature - saving";
1682 } else { 1679 } else {
1683 DVLOG(1) << "SetInstallSignature - clearing"; 1680 DVLOG(1) << "SetInstallSignature - clearing";
1684 prefs_->ClearPref(kInstallSignature); 1681 prefs_->ClearPref(kInstallSignature);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1905 is_enabled = initial_state == Extension::ENABLED; 1902 is_enabled = initial_state == Extension::ENABLED;
1906 } 1903 }
1907 1904
1908 extension_pref_value_map_->RegisterExtension(extension_id, install_time, 1905 extension_pref_value_map_->RegisterExtension(extension_id, install_time,
1909 is_enabled); 1906 is_enabled);
1910 content_settings_store_->RegisterExtension(extension_id, install_time, 1907 content_settings_store_->RegisterExtension(extension_id, install_time,
1911 is_enabled); 1908 is_enabled);
1912 } 1909 }
1913 1910
1914 } // namespace extensions 1911 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extensions/permissions_custom_bindings.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698