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

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

Issue 595363002: Add policy controlled permission block list for extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ext-fix
Patch Set: more minor format fix Created 6 years, 2 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
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 "chrome/browser/extensions/extension_management_internal.h" 5 #include "chrome/browser/extensions/extension_management_internal.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/extensions/extension_management_constants.h" 9 #include "chrome/browser/extensions/extension_management_constants.h"
10 #include "extensions/common/url_pattern_set.h" 10 #include "extensions/common/url_pattern_set.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 GURL(update_url_str).is_valid()) { 60 GURL(update_url_str).is_valid()) {
61 update_url = update_url_str; 61 update_url = update_url_str;
62 } else { 62 } else {
63 // No valid update URL for extension. 63 // No valid update URL for extension.
64 LOG(WARNING) << kMalformedPreferenceWarning; 64 LOG(WARNING) << kMalformedPreferenceWarning;
65 return false; 65 return false;
66 } 66 }
67 } 67 }
68 } 68 }
69 69
70 // Parses the blocked permission settings.
71 const base::ListValue* list_value;
Joao da Silva 2014/10/15 14:39:25 = NULL
binjin 2014/10/16 18:13:58 Done.
72 base::string16 error;
73
74 // If applicable, inherit from global block list and remove all explicitly
75 // allowed permissions.
76 if (scope != SCOPE_DEFAULT &&
77 dict->GetListWithoutPathExpansion(schema_constants::kAllowedPermissions,
78 &list_value)) {
79 APIPermissionSet globally_blocked_permissions = blocked_permissions;
Joao da Silva 2014/10/15 14:39:25 This is extremely subtle. If I understood it corr
binjin 2014/10/16 18:13:58 Done.
80 APIPermissionSet explicitly_allowed_permissions;
81 // Reuses code for parsing API permissions from manifest. But note that we
82 // only support list of strings type.
83 if (!APIPermissionSet::ParseFromJSON(
84 list_value,
85 APIPermissionSet::kDisallowInternalPermissions,
86 &explicitly_allowed_permissions,
87 &error,
88 NULL)) {
89 // There might be unknown permissions, warn and just ignore them;
90 LOG(WARNING) << error;
91 }
92 APIPermissionSet::Difference(globally_blocked_permissions,
93 explicitly_allowed_permissions,
94 &blocked_permissions);
95 }
96
97 // Then add all newly blocked permissions to the list.
98 if (dict->GetListWithoutPathExpansion(schema_constants::kBlockedPermissions,
99 &list_value)) {
100 APIPermissionSet permissions_to_merge_from = blocked_permissions;
Joao da Silva 2014/10/15 14:39:25 Same here.
binjin 2014/10/16 18:13:58 Done. But note that it's slightly different: |bloc
101 APIPermissionSet permissions_parsed;
102 if (!APIPermissionSet::ParseFromJSON(
103 list_value,
104 APIPermissionSet::kDisallowInternalPermissions,
105 &permissions_parsed,
106 &error,
107 NULL)) {
108 LOG(WARNING) << error;
109 }
110 APIPermissionSet::Union(
111 permissions_to_merge_from, permissions_parsed, &blocked_permissions);
112 }
113
70 return true; 114 return true;
71 } 115 }
72 116
73 void IndividualSettings::Reset() { 117 void IndividualSettings::Reset() {
74 installation_mode = ExtensionManagement::INSTALLATION_ALLOWED; 118 installation_mode = ExtensionManagement::INSTALLATION_ALLOWED;
75 update_url.clear(); 119 update_url.clear();
120 blocked_permissions.clear();
76 } 121 }
77 122
78 GlobalSettings::GlobalSettings() { 123 GlobalSettings::GlobalSettings() {
79 Reset(); 124 Reset();
80 } 125 }
81 126
82 GlobalSettings::~GlobalSettings() { 127 GlobalSettings::~GlobalSettings() {
83 } 128 }
84 129
85 void GlobalSettings::Reset() { 130 void GlobalSettings::Reset() {
86 has_restricted_install_sources = false; 131 has_restricted_install_sources = false;
87 install_sources.ClearPatterns(); 132 install_sources.ClearPatterns();
88 has_restricted_allowed_types = false; 133 has_restricted_allowed_types = false;
89 allowed_types.clear(); 134 allowed_types.clear();
90 } 135 }
91 136
92 } // namespace internal 137 } // namespace internal
93 138
94 } // namespace extensions 139 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698