| 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/permissions_updater.h" | 5 #include "chrome/browser/extensions/permissions_updater.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/extensions/api/permissions/permissions_api_helpers.h" | 10 #include "chrome/browser/extensions/api/permissions/permissions_api_helpers.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // the extension, not the user, removed the permissions. This allows the | 67 // the extension, not the user, removed the permissions. This allows the |
| 68 // extension to add them again without prompting the user. | 68 // extension to add them again without prompting the user. |
| 69 UpdateActivePermissions(extension, total.get()); | 69 UpdateActivePermissions(extension, total.get()); |
| 70 | 70 |
| 71 NotifyPermissionsUpdated(REMOVED, extension, removed.get()); | 71 NotifyPermissionsUpdated(REMOVED, extension, removed.get()); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void PermissionsUpdater::GrantActivePermissions(const Extension* extension) { | 74 void PermissionsUpdater::GrantActivePermissions(const Extension* extension) { |
| 75 CHECK(extension); | 75 CHECK(extension); |
| 76 | 76 |
| 77 // We only maintain the granted permissions prefs for extensions that can't | 77 // We only maintain the granted permissions prefs for INTERNAL and LOAD |
| 78 // silently increase their permissions. | 78 // extensions. |
| 79 if (extension->CanSilentlyIncreasePermissions()) | 79 if (extension->location() != Extension::LOAD && |
| 80 extension->location() != Extension::INTERNAL) |
| 80 return; | 81 return; |
| 81 | 82 |
| 82 GetExtensionPrefs()->AddGrantedPermissions( | 83 GetExtensionPrefs()->AddGrantedPermissions( |
| 83 extension->id(), extension->GetActivePermissions()); | 84 extension->id(), extension->GetActivePermissions()); |
| 84 } | 85 } |
| 85 | 86 |
| 86 void PermissionsUpdater::UpdateActivePermissions( | 87 void PermissionsUpdater::UpdateActivePermissions( |
| 87 const Extension* extension, const ExtensionPermissionSet* permissions) { | 88 const Extension* extension, const ExtensionPermissionSet* permissions) { |
| 88 GetExtensionPrefs()->SetActivePermissions(extension->id(), permissions); | 89 GetExtensionPrefs()->SetActivePermissions(extension->id(), permissions); |
| 89 extension->SetActivePermissions(permissions); | 90 extension->SetActivePermissions(permissions); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 150 |
| 150 // Trigger the onAdded and onRemoved events in the extension. | 151 // Trigger the onAdded and onRemoved events in the extension. |
| 151 DispatchEvent(extension->id(), event_name, changed); | 152 DispatchEvent(extension->id(), event_name, changed); |
| 152 } | 153 } |
| 153 | 154 |
| 154 ExtensionPrefs* PermissionsUpdater::GetExtensionPrefs() { | 155 ExtensionPrefs* PermissionsUpdater::GetExtensionPrefs() { |
| 155 return profile_->GetExtensionService()->extension_prefs(); | 156 return profile_->GetExtensionService()->extension_prefs(); |
| 156 } | 157 } |
| 157 | 158 |
| 158 } // namespace extensions | 159 } // namespace extensions |
| OLD | NEW |