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

Side by Side Diff: chrome/browser/extensions/api/permissions/permissions_api.cc

Issue 11348335: Revert 170514 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/api/permissions/permissions_api.h" 5 #include "chrome/browser/extensions/api/permissions/permissions_api.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/extensions/api/permissions/permissions_api_helpers.h" 8 #include "chrome/browser/extensions/api/permissions/permissions_api_helpers.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/permissions_updater.h" 10 #include "chrome/browser/extensions/permissions_updater.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 APIPermissionSet apis = requested_permissions_->apis(); 162 APIPermissionSet apis = requested_permissions_->apis();
163 for (APIPermissionSet::const_iterator i = apis.begin(); 163 for (APIPermissionSet::const_iterator i = apis.begin();
164 i != apis.end(); ++i) { 164 i != apis.end(); ++i) {
165 if (!i->info()->supports_optional()) { 165 if (!i->info()->supports_optional()) {
166 error_ = ErrorUtils::FormatErrorMessage( 166 error_ = ErrorUtils::FormatErrorMessage(
167 kNotWhitelistedError, i->name()); 167 kNotWhitelistedError, i->name());
168 return false; 168 return false;
169 } 169 }
170 } 170 }
171 171
172 // Filter out permissions that do not need to be listed in the optional
173 // section of the manifest.
174 scoped_refptr<extensions::PermissionSet>
175 manifest_required_requested_permissions =
176 PermissionSet::ExcludeNotInManifestPermissions(
177 requested_permissions_.get());
178
179 // The requested permissions must be defined as optional in the manifest. 172 // The requested permissions must be defined as optional in the manifest.
180 if (!GetExtension()->optional_permission_set()->Contains( 173 if (!GetExtension()->optional_permission_set()->Contains(
181 *manifest_required_requested_permissions)) { 174 *requested_permissions_)) {
182 error_ = kNotInOptionalPermissionsError; 175 error_ = kNotInOptionalPermissionsError;
183 results_ = Request::Results::Create(false); 176 results_ = Request::Results::Create(false);
184 return false; 177 return false;
185 } 178 }
186 179
187 // We don't need to prompt the user if the requested permissions are a subset 180 // We don't need to prompt the user if the requested permissions are a subset
188 // of the granted permissions set. 181 // of the granted permissions set.
189 scoped_refptr<const PermissionSet> granted = 182 scoped_refptr<const PermissionSet> granted =
190 prefs->GetGrantedPermissions(GetExtension()->id()); 183 prefs->GetGrantedPermissions(GetExtension()->id());
191 if (granted.get() && granted->Contains(*requested_permissions_)) { 184 if (granted.get() && granted->Contains(*requested_permissions_)) {
(...skipping 22 matching lines...) Expand all
214 InstallUIAbort(true); 207 InstallUIAbort(true);
215 } else { 208 } else {
216 CHECK_EQ(DO_NOT_SKIP, auto_confirm_for_tests); 209 CHECK_EQ(DO_NOT_SKIP, auto_confirm_for_tests);
217 install_ui_.reset(new ExtensionInstallPrompt(GetAssociatedWebContents())); 210 install_ui_.reset(new ExtensionInstallPrompt(GetAssociatedWebContents()));
218 install_ui_->ConfirmPermissions( 211 install_ui_->ConfirmPermissions(
219 this, GetExtension(), requested_permissions_.get()); 212 this, GetExtension(), requested_permissions_.get());
220 } 213 }
221 214
222 return true; 215 return true;
223 } 216 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698