| 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 26 matching lines...) Expand all Loading... |
| 37 namespace extensions { | 37 namespace extensions { |
| 38 | 38 |
| 39 namespace { | 39 namespace { |
| 40 | 40 |
| 41 scoped_refptr<const Extension> CreateExtensionWithOptionalPermissions( | 41 scoped_refptr<const Extension> CreateExtensionWithOptionalPermissions( |
| 42 scoped_ptr<base::Value> optional_permissions, | 42 scoped_ptr<base::Value> optional_permissions, |
| 43 scoped_ptr<base::Value> permissions, | 43 scoped_ptr<base::Value> permissions, |
| 44 const std::string& name) { | 44 const std::string& name) { |
| 45 return ExtensionBuilder() | 45 return ExtensionBuilder() |
| 46 .SetLocation(Manifest::INTERNAL) | 46 .SetLocation(Manifest::INTERNAL) |
| 47 .SetManifest(std::move( | 47 .SetManifest( |
| 48 DictionaryBuilder() | 48 DictionaryBuilder() |
| 49 .Set("name", name) | 49 .Set("name", name) |
| 50 .Set("description", "foo") | 50 .Set("description", "foo") |
| 51 .Set("manifest_version", 2) | 51 .Set("manifest_version", 2) |
| 52 .Set("version", "0.1.2.3") | 52 .Set("version", "0.1.2.3") |
| 53 .Set("permissions", std::move(permissions)) | 53 .Set("permissions", std::move(permissions)) |
| 54 .Set("optional_permissions", std::move(optional_permissions)))) | 54 .Set("optional_permissions", std::move(optional_permissions)) |
| 55 .Build()) |
| 55 .SetID(crx_file::id_util::GenerateId(name)) | 56 .SetID(crx_file::id_util::GenerateId(name)) |
| 56 .Build(); | 57 .Build(); |
| 57 } | 58 } |
| 58 | 59 |
| 59 // A helper class that listens for NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED. | 60 // A helper class that listens for NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED. |
| 60 class PermissionsUpdaterListener : public content::NotificationObserver { | 61 class PermissionsUpdaterListener : public content::NotificationObserver { |
| 61 public: | 62 public: |
| 62 PermissionsUpdaterListener() | 63 PermissionsUpdaterListener() |
| 63 : received_notification_(false), waiting_(false) { | 64 : received_notification_(false), waiting_(false) { |
| 64 registrar_.Add(this, | 65 registrar_.Add(this, |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 ->active_permissions() | 357 ->active_permissions() |
| 357 .HasExplicitAccessToOrigin(kOrigin)); | 358 .HasExplicitAccessToOrigin(kOrigin)); |
| 358 EXPECT_TRUE(extension->permissions_data() | 359 EXPECT_TRUE(extension->permissions_data() |
| 359 ->withheld_permissions() | 360 ->withheld_permissions() |
| 360 .HasExplicitAccessToOrigin(kOrigin)); | 361 .HasExplicitAccessToOrigin(kOrigin)); |
| 361 EXPECT_TRUE(updater.GetRevokablePermissions(extension.get())->IsEmpty()); | 362 EXPECT_TRUE(updater.GetRevokablePermissions(extension.get())->IsEmpty()); |
| 362 } | 363 } |
| 363 } | 364 } |
| 364 | 365 |
| 365 } // namespace extensions | 366 } // namespace extensions |
| OLD | NEW |