OLD | NEW |
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 Loading... |
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 = requested_permissions_->GetWarningMessages( |
213 GetExtension()->GetType()).empty(); | 215 GetExtension()->GetType()).empty(); |
214 if (auto_confirm_for_tests == PROCEED || has_no_warnings) { | 216 if (auto_confirm_for_tests == PROCEED || has_no_warnings || |
| 217 extension_->location() == Manifest::COMPONENT) { |
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 |
OLD | NEW |