| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "extensions/common/permissions/permissions_data.h" | 5 #include "extensions/common/permissions/permissions_data.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 return active_permissions_unsafe_->HasEffectiveAccessToAllHosts(); | 290 return active_permissions_unsafe_->HasEffectiveAccessToAllHosts(); |
| 291 } | 291 } |
| 292 | 292 |
| 293 PermissionMessages PermissionsData::GetPermissionMessages() const { | 293 PermissionMessages PermissionsData::GetPermissionMessages() const { |
| 294 base::AutoLock auto_lock(runtime_lock_); | 294 base::AutoLock auto_lock(runtime_lock_); |
| 295 return PermissionMessageProvider::Get()->GetPermissionMessages( | 295 return PermissionMessageProvider::Get()->GetPermissionMessages( |
| 296 PermissionMessageProvider::Get()->GetAllPermissionIDs( | 296 PermissionMessageProvider::Get()->GetAllPermissionIDs( |
| 297 *active_permissions_unsafe_, manifest_type_)); | 297 *active_permissions_unsafe_, manifest_type_)); |
| 298 } | 298 } |
| 299 | 299 |
| 300 PermissionMessages PermissionsData::GetNewPermissionMessages( |
| 301 const PermissionSet& granted_permissions) const { |
| 302 base::AutoLock auto_lock(runtime_lock_); |
| 303 |
| 304 std::unique_ptr<const PermissionSet> new_permissions = |
| 305 PermissionSet::CreateDifference(*active_permissions_unsafe_, |
| 306 granted_permissions); |
| 307 |
| 308 return PermissionMessageProvider::Get()->GetPermissionMessages( |
| 309 PermissionMessageProvider::Get()->GetAllPermissionIDs(*new_permissions, |
| 310 manifest_type_)); |
| 311 } |
| 312 |
| 300 bool PermissionsData::HasWithheldImpliedAllHosts() const { | 313 bool PermissionsData::HasWithheldImpliedAllHosts() const { |
| 301 base::AutoLock auto_lock(runtime_lock_); | 314 base::AutoLock auto_lock(runtime_lock_); |
| 302 // Since we currently only withhold all_hosts, it's sufficient to check | 315 // Since we currently only withhold all_hosts, it's sufficient to check |
| 303 // that either set is not empty. | 316 // that either set is not empty. |
| 304 return !withheld_permissions_unsafe_->explicit_hosts().is_empty() || | 317 return !withheld_permissions_unsafe_->explicit_hosts().is_empty() || |
| 305 !withheld_permissions_unsafe_->scriptable_hosts().is_empty(); | 318 !withheld_permissions_unsafe_->scriptable_hosts().is_empty(); |
| 306 } | 319 } |
| 307 | 320 |
| 308 bool PermissionsData::CanAccessPage(const Extension* extension, | 321 bool PermissionsData::CanAccessPage(const Extension* extension, |
| 309 const GURL& document_url, | 322 const GURL& document_url, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 manifest_errors::kCannotAccessPageWithUrl, document_url.spec()); | 458 manifest_errors::kCannotAccessPageWithUrl, document_url.spec()); |
| 446 } else { | 459 } else { |
| 447 *error = manifest_errors::kCannotAccessPage; | 460 *error = manifest_errors::kCannotAccessPage; |
| 448 } | 461 } |
| 449 } | 462 } |
| 450 | 463 |
| 451 return ACCESS_DENIED; | 464 return ACCESS_DENIED; |
| 452 } | 465 } |
| 453 | 466 |
| 454 } // namespace extensions | 467 } // namespace extensions |
| OLD | NEW |