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/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/extensions/api/permissions/permissions_api_helpers.h" | 9 #include "chrome/browser/extensions/api/permissions/permissions_api_helpers.h" |
10 #include "chrome/browser/extensions/permissions_updater.h" | 10 #include "chrome/browser/extensions/permissions_updater.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 ignore_user_gesture_for_tests = ignore; | 122 ignore_user_gesture_for_tests = ignore; |
123 } | 123 } |
124 | 124 |
125 PermissionsRequestFunction::PermissionsRequestFunction() {} | 125 PermissionsRequestFunction::PermissionsRequestFunction() {} |
126 | 126 |
127 void PermissionsRequestFunction::InstallUIProceed() { | 127 void PermissionsRequestFunction::InstallUIProceed() { |
128 PermissionsUpdater perms_updater(GetProfile()); | 128 PermissionsUpdater perms_updater(GetProfile()); |
129 perms_updater.AddPermissions(GetExtension(), requested_permissions_.get()); | 129 perms_updater.AddPermissions(GetExtension(), requested_permissions_.get()); |
130 | 130 |
131 results_ = Request::Results::Create(true); | 131 results_ = Request::Results::Create(true); |
132 response_user_gesture_ = true; | |
132 SendResponse(true); | 133 SendResponse(true); |
133 | 134 |
134 Release(); // Balanced in RunImpl(). | 135 Release(); // Balanced in RunImpl(). |
135 } | 136 } |
136 | 137 |
137 void PermissionsRequestFunction::InstallUIAbort(bool user_initiated) { | 138 void PermissionsRequestFunction::InstallUIAbort(bool user_initiated) { |
138 SendResponse(true); | 139 SendResponse(true); |
139 | 140 |
140 Release(); // Balanced in RunImpl(). | 141 Release(); // Balanced in RunImpl(). |
141 } | 142 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 } | 182 } |
182 | 183 |
183 // We don't need to prompt the user if the requested permissions are a subset | 184 // We don't need to prompt the user if the requested permissions are a subset |
184 // of the granted permissions set. | 185 // of the granted permissions set. |
185 scoped_refptr<const PermissionSet> granted = ExtensionPrefs::Get( | 186 scoped_refptr<const PermissionSet> granted = ExtensionPrefs::Get( |
186 GetProfile())->GetGrantedPermissions(GetExtension()->id()); | 187 GetProfile())->GetGrantedPermissions(GetExtension()->id()); |
187 if (granted.get() && granted->Contains(*requested_permissions_.get())) { | 188 if (granted.get() && granted->Contains(*requested_permissions_.get())) { |
188 PermissionsUpdater perms_updater(GetProfile()); | 189 PermissionsUpdater perms_updater(GetProfile()); |
189 perms_updater.AddPermissions(GetExtension(), requested_permissions_.get()); | 190 perms_updater.AddPermissions(GetExtension(), requested_permissions_.get()); |
190 results_ = Request::Results::Create(true); | 191 results_ = Request::Results::Create(true); |
192 //response_user_gesture_ = true; | |
wjywbs
2014/04/07 21:46:37
This can cause security issues same as chrome.test
not at google - send to devlin
2014/04/07 22:09:09
how?
| |
191 SendResponse(true); | 193 SendResponse(true); |
192 return true; | 194 return true; |
193 } | 195 } |
194 | 196 |
195 // Filter out the granted permissions so we only prompt for new ones. | 197 // Filter out the granted permissions so we only prompt for new ones. |
196 requested_permissions_ = PermissionSet::CreateDifference( | 198 requested_permissions_ = PermissionSet::CreateDifference( |
197 requested_permissions_.get(), granted.get()); | 199 requested_permissions_.get(), granted.get()); |
198 | 200 |
199 AddRef(); // Balanced in InstallUIProceed() / InstallUIAbort(). | 201 AddRef(); // Balanced in InstallUIProceed() / InstallUIAbort(). |
200 | 202 |
(...skipping 13 matching lines...) Expand all Loading... | |
214 CHECK_EQ(DO_NOT_SKIP, auto_confirm_for_tests); | 216 CHECK_EQ(DO_NOT_SKIP, auto_confirm_for_tests); |
215 install_ui_.reset(new ExtensionInstallPrompt(GetAssociatedWebContents())); | 217 install_ui_.reset(new ExtensionInstallPrompt(GetAssociatedWebContents())); |
216 install_ui_->ConfirmPermissions( | 218 install_ui_->ConfirmPermissions( |
217 this, GetExtension(), requested_permissions_.get()); | 219 this, GetExtension(), requested_permissions_.get()); |
218 } | 220 } |
219 | 221 |
220 return true; | 222 return true; |
221 } | 223 } |
222 | 224 |
223 } // namespace extensions | 225 } // namespace extensions |
OLD | NEW |