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/extension_prefs.h" | 10 #include "chrome/browser/extensions/extension_prefs.h" |
11 #include "chrome/browser/extensions/permissions_updater.h" | 11 #include "chrome/browser/extensions/permissions_updater.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/common/extensions/api/permissions.h" | 13 #include "chrome/common/extensions/api/permissions.h" |
14 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
15 #include "chrome/common/extensions/permissions/permissions_data.h" | 15 #include "chrome/common/extensions/permissions/permissions_data.h" |
16 #include "extensions/common/error_utils.h" | 16 #include "extensions/common/error_utils.h" |
| 17 #include "extensions/common/permissions/permission_message_provider.h" |
17 #include "extensions/common/permissions/permissions_info.h" | 18 #include "extensions/common/permissions/permissions_info.h" |
18 #include "extensions/common/url_pattern_set.h" | 19 #include "extensions/common/url_pattern_set.h" |
19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
20 | 21 |
21 namespace extensions { | 22 namespace extensions { |
22 | 23 |
23 using api::permissions::Permissions; | 24 using api::permissions::Permissions; |
24 | 25 |
25 namespace Contains = api::permissions::Contains; | 26 namespace Contains = api::permissions::Contains; |
26 namespace GetAll = api::permissions::GetAll; | 27 namespace GetAll = api::permissions::GetAll; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 199 |
199 // Filter out the granted permissions so we only prompt for new ones. | 200 // Filter out the granted permissions so we only prompt for new ones. |
200 requested_permissions_ = PermissionSet::CreateDifference( | 201 requested_permissions_ = PermissionSet::CreateDifference( |
201 requested_permissions_.get(), granted.get()); | 202 requested_permissions_.get(), granted.get()); |
202 | 203 |
203 AddRef(); // Balanced in InstallUIProceed() / InstallUIAbort(). | 204 AddRef(); // Balanced in InstallUIProceed() / InstallUIAbort(). |
204 | 205 |
205 // We don't need to show the prompt if there are no new warnings, or if | 206 // We don't need to show the prompt if there are no new warnings, or if |
206 // we're skipping the confirmation UI. All extension types but INTERNAL | 207 // we're skipping the confirmation UI. All extension types but INTERNAL |
207 // are allowed to silently increase their permission level. | 208 // are allowed to silently increase their permission level. |
208 bool has_no_warnings = requested_permissions_->GetWarningMessages( | 209 bool has_no_warnings = |
209 GetExtension()->GetType()).empty(); | 210 PermissionMessageProvider::Get()->GetWarningMessages( |
| 211 requested_permissions_, GetExtension()->GetType()).empty(); |
210 if (auto_confirm_for_tests == PROCEED || has_no_warnings || | 212 if (auto_confirm_for_tests == PROCEED || has_no_warnings || |
211 extension_->location() == Manifest::COMPONENT) { | 213 extension_->location() == Manifest::COMPONENT) { |
212 InstallUIProceed(); | 214 InstallUIProceed(); |
213 } else if (auto_confirm_for_tests == ABORT) { | 215 } else if (auto_confirm_for_tests == ABORT) { |
214 // Pretend the user clicked cancel. | 216 // Pretend the user clicked cancel. |
215 InstallUIAbort(true); | 217 InstallUIAbort(true); |
216 } else { | 218 } else { |
217 CHECK_EQ(DO_NOT_SKIP, auto_confirm_for_tests); | 219 CHECK_EQ(DO_NOT_SKIP, auto_confirm_for_tests); |
218 install_ui_.reset(new ExtensionInstallPrompt(GetAssociatedWebContents())); | 220 install_ui_.reset(new ExtensionInstallPrompt(GetAssociatedWebContents())); |
219 install_ui_->ConfirmPermissions( | 221 install_ui_->ConfirmPermissions( |
220 this, GetExtension(), requested_permissions_.get()); | 222 this, GetExtension(), requested_permissions_.get()); |
221 } | 223 } |
222 | 224 |
223 return true; | 225 return true; |
224 } | 226 } |
225 | 227 |
226 } // namespace extensions | 228 } // namespace extensions |
OLD | NEW |