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

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

Issue 16085006: Allowing component extensions to request permissions NOT only from user's gestures (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mpcomplete@ notes Created 7 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
« no previous file with comments | « no previous file | 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 (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_prefs.h" 9 #include "chrome/browser/extensions/extension_prefs.h"
10 #include "chrome/browser/extensions/permissions_updater.h" 10 #include "chrome/browser/extensions/permissions_updater.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 SendResponse(true); 140 SendResponse(true);
141 141
142 Release(); // Balanced in RunImpl(). 142 Release(); // Balanced in RunImpl().
143 } 143 }
144 144
145 PermissionsRequestFunction::~PermissionsRequestFunction() {} 145 PermissionsRequestFunction::~PermissionsRequestFunction() {}
146 146
147 bool PermissionsRequestFunction::RunImpl() { 147 bool PermissionsRequestFunction::RunImpl() {
148 results_ = Request::Results::Create(false); 148 results_ = Request::Results::Create(false);
149 149
150 if (!user_gesture() && !ignore_user_gesture_for_tests) { 150 if (!user_gesture() &&
151 !ignore_user_gesture_for_tests &&
152 extension_->location() != Manifest::COMPONENT) {
151 error_ = kUserGestureRequiredError; 153 error_ = kUserGestureRequiredError;
152 return false; 154 return false;
153 } 155 }
154 156
155 scoped_ptr<Request::Params> params(Request::Params::Create(*args_)); 157 scoped_ptr<Request::Params> params(Request::Params::Create(*args_));
156 EXTENSION_FUNCTION_VALIDATE(params); 158 EXTENSION_FUNCTION_VALIDATE(params);
157 159
158 requested_permissions_ = 160 requested_permissions_ =
159 helpers::UnpackPermissionSet( 161 helpers::UnpackPermissionSet(
160 params->permissions, 162 params->permissions,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 204
203 // Filter out the granted permissions so we only prompt for new ones. 205 // Filter out the granted permissions so we only prompt for new ones.
204 requested_permissions_ = PermissionSet::CreateDifference( 206 requested_permissions_ = PermissionSet::CreateDifference(
205 requested_permissions_.get(), granted.get()); 207 requested_permissions_.get(), granted.get());
206 208
207 AddRef(); // Balanced in InstallUIProceed() / InstallUIAbort(). 209 AddRef(); // Balanced in InstallUIProceed() / InstallUIAbort().
208 210
209 // We don't need to show the prompt if there are no new warnings, or if 211 // We don't need to show the prompt if there are no new warnings, or if
210 // we're skipping the confirmation UI. All extension types but INTERNAL 212 // we're skipping the confirmation UI. All extension types but INTERNAL
211 // are allowed to silently increase their permission level. 213 // are allowed to silently increase their permission level.
212 bool has_no_warnings = requested_permissions_->GetWarningMessages( 214 bool has_no_warnings = extension_->location() == Manifest::COMPONENT ||
Matt Perry 2013/06/05 00:26:52 nit: this really belongs on the if statement below
vadimt 2013/06/05 00:33:07 Done.
213 GetExtension()->GetType()).empty(); 215 requested_permissions_->GetWarningMessages(
216 GetExtension()->GetType()).empty();
214 if (auto_confirm_for_tests == PROCEED || has_no_warnings) { 217 if (auto_confirm_for_tests == PROCEED || has_no_warnings) {
215 InstallUIProceed(); 218 InstallUIProceed();
216 } else if (auto_confirm_for_tests == ABORT) { 219 } else if (auto_confirm_for_tests == ABORT) {
217 // Pretend the user clicked cancel. 220 // Pretend the user clicked cancel.
218 InstallUIAbort(true); 221 InstallUIAbort(true);
219 } else { 222 } else {
220 CHECK_EQ(DO_NOT_SKIP, auto_confirm_for_tests); 223 CHECK_EQ(DO_NOT_SKIP, auto_confirm_for_tests);
221 install_ui_.reset(new ExtensionInstallPrompt(GetAssociatedWebContents())); 224 install_ui_.reset(new ExtensionInstallPrompt(GetAssociatedWebContents()));
222 install_ui_->ConfirmPermissions( 225 install_ui_->ConfirmPermissions(
223 this, GetExtension(), requested_permissions_.get()); 226 this, GetExtension(), requested_permissions_.get());
224 } 227 }
225 228
226 return true; 229 return true;
227 } 230 }
228 231
229 } // namespace extensions 232 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698