| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 listener.Wait(); | 179 listener.Wait(); |
| 180 | 180 |
| 181 // Verify that the permission notification was sent correctly. | 181 // Verify that the permission notification was sent correctly. |
| 182 ASSERT_TRUE(listener.received_notification()); | 182 ASSERT_TRUE(listener.received_notification()); |
| 183 ASSERT_EQ(extension.get(), listener.extension()); | 183 ASSERT_EQ(extension.get(), listener.extension()); |
| 184 ASSERT_EQ(UpdatedExtensionPermissionsInfo::ADDED, listener.reason()); | 184 ASSERT_EQ(UpdatedExtensionPermissionsInfo::ADDED, listener.reason()); |
| 185 ASSERT_EQ(delta, *listener.permissions()); | 185 ASSERT_EQ(delta, *listener.permissions()); |
| 186 | 186 |
| 187 // Make sure the extension's active permissions reflect the change. | 187 // Make sure the extension's active permissions reflect the change. |
| 188 active_permissions = PermissionSet::CreateUnion(default_permissions, delta); | 188 active_permissions = PermissionSet::CreateUnion(default_permissions, delta); |
| 189 ASSERT_EQ(*active_permissions.get(), | 189 ASSERT_EQ(*active_permissions, |
| 190 extension->permissions_data()->active_permissions()); | 190 extension->permissions_data()->active_permissions()); |
| 191 | 191 |
| 192 // Verify that the new granted and active permissions were also stored | 192 // Verify that the new granted and active permissions were also stored |
| 193 // in the extension preferences. In this case, the granted permissions should | 193 // in the extension preferences. In this case, the granted permissions should |
| 194 // be equal to the active permissions. | 194 // be equal to the active permissions. |
| 195 ASSERT_EQ(*active_permissions.get(), | 195 ASSERT_EQ(*active_permissions, *prefs->GetActivePermissions(extension->id())); |
| 196 *prefs->GetActivePermissions(extension->id())); | |
| 197 granted_permissions = active_permissions->Clone(); | 196 granted_permissions = active_permissions->Clone(); |
| 198 ASSERT_EQ(*granted_permissions, | 197 ASSERT_EQ(*granted_permissions, |
| 199 *prefs->GetGrantedPermissions(extension->id())); | 198 *prefs->GetGrantedPermissions(extension->id())); |
| 200 } | 199 } |
| 201 | 200 |
| 202 { | 201 { |
| 203 // In the second part of the test, we'll remove the permissions that we | 202 // In the second part of the test, we'll remove the permissions that we |
| 204 // just added except for 'notifications'. | 203 // just added except for 'notifications'. |
| 205 apis.erase(APIPermission::kNotifications); | 204 apis.erase(APIPermission::kNotifications); |
| 206 PermissionSet delta(apis, empty_manifest_permissions, hosts, URLPatternSet()); | 205 PermissionSet delta(apis, empty_manifest_permissions, hosts, URLPatternSet()); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 ->active_permissions() | 357 ->active_permissions() |
| 359 .HasExplicitAccessToOrigin(kOrigin)); | 358 .HasExplicitAccessToOrigin(kOrigin)); |
| 360 EXPECT_TRUE(extension->permissions_data() | 359 EXPECT_TRUE(extension->permissions_data() |
| 361 ->withheld_permissions() | 360 ->withheld_permissions() |
| 362 .HasExplicitAccessToOrigin(kOrigin)); | 361 .HasExplicitAccessToOrigin(kOrigin)); |
| 363 EXPECT_TRUE(updater.GetRevokablePermissions(extension.get())->IsEmpty()); | 362 EXPECT_TRUE(updater.GetRevokablePermissions(extension.get())->IsEmpty()); |
| 364 } | 363 } |
| 365 } | 364 } |
| 366 | 365 |
| 367 } // namespace extensions | 366 } // namespace extensions |
| OLD | NEW |