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_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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 194 |
195 // Filter out the granted permissions so we only prompt for new ones. | 195 // Filter out the granted permissions so we only prompt for new ones. |
196 requested_permissions_ = PermissionSet::CreateDifference( | 196 requested_permissions_ = PermissionSet::CreateDifference( |
197 requested_permissions_.get(), granted.get()); | 197 requested_permissions_.get(), granted.get()); |
198 | 198 |
199 AddRef(); // Balanced in InstallUIProceed() / InstallUIAbort(). | 199 AddRef(); // Balanced in InstallUIProceed() / InstallUIAbort(). |
200 | 200 |
201 // We don't need to show the prompt if there are no new warnings, or if | 201 // We don't need to show the prompt if there are no new warnings, or if |
202 // we're skipping the confirmation UI. All extension types but INTERNAL | 202 // we're skipping the confirmation UI. All extension types but INTERNAL |
203 // are allowed to silently increase their permission level. | 203 // are allowed to silently increase their permission level. |
204 if (auto_confirm_for_tests == PROCEED || | 204 bool has_no_warnings = requested_permissions_->GetWarningMessages( |
205 requested_permissions_->GetWarningMessages().size() == 0) { | 205 GetExtension()->GetType()).size() == 0; |
| 206 if (auto_confirm_for_tests == PROCEED || has_no_warnings) { |
206 InstallUIProceed(); | 207 InstallUIProceed(); |
207 } else if (auto_confirm_for_tests == ABORT) { | 208 } else if (auto_confirm_for_tests == ABORT) { |
208 // Pretend the user clicked cancel. | 209 // Pretend the user clicked cancel. |
209 InstallUIAbort(true); | 210 InstallUIAbort(true); |
210 } else { | 211 } else { |
211 CHECK_EQ(DO_NOT_SKIP, auto_confirm_for_tests); | 212 CHECK_EQ(DO_NOT_SKIP, auto_confirm_for_tests); |
212 install_ui_.reset( | 213 install_ui_.reset( |
213 chrome::CreateExtensionInstallPromptWithBrowser(GetCurrentBrowser())); | 214 chrome::CreateExtensionInstallPromptWithBrowser(GetCurrentBrowser())); |
214 install_ui_->ConfirmPermissions( | 215 install_ui_->ConfirmPermissions( |
215 this, GetExtension(), requested_permissions_.get()); | 216 this, GetExtension(), requested_permissions_.get()); |
216 } | 217 } |
217 | 218 |
218 return true; | 219 return true; |
219 } | 220 } |
OLD | NEW |