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" |
| 6 |
| 7 #include <utility> |
| 8 |
5 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
6 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
7 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
8 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
9 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
10 #include "base/values.h" | 14 #include "base/values.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/extensions/extension_service_test_base.h" | 17 #include "chrome/browser/extensions/extension_service_test_base.h" |
14 #include "chrome/browser/extensions/extension_util.h" | 18 #include "chrome/browser/extensions/extension_util.h" |
15 #include "chrome/browser/extensions/permissions_updater.h" | |
16 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
17 #include "chrome/common/extensions/extension_test_util.h" | 20 #include "chrome/common/extensions/extension_test_util.h" |
18 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
19 #include "components/crx_file/id_util.h" | 22 #include "components/crx_file/id_util.h" |
20 #include "content/public/browser/notification_observer.h" | 23 #include "content/public/browser/notification_observer.h" |
21 #include "content/public/browser/notification_registrar.h" | 24 #include "content/public/browser/notification_registrar.h" |
22 #include "content/public/browser/notification_service.h" | 25 #include "content/public/browser/notification_service.h" |
23 #include "extensions/browser/extension_prefs.h" | 26 #include "extensions/browser/extension_prefs.h" |
24 #include "extensions/common/extension.h" | 27 #include "extensions/common/extension.h" |
25 #include "extensions/common/extension_builder.h" | 28 #include "extensions/common/extension_builder.h" |
(...skipping 14 matching lines...) Expand all Loading... |
40 scoped_ptr<base::Value> permissions, | 43 scoped_ptr<base::Value> permissions, |
41 const std::string& name) { | 44 const std::string& name) { |
42 return ExtensionBuilder() | 45 return ExtensionBuilder() |
43 .SetLocation(Manifest::INTERNAL) | 46 .SetLocation(Manifest::INTERNAL) |
44 .SetManifest(std::move( | 47 .SetManifest(std::move( |
45 DictionaryBuilder() | 48 DictionaryBuilder() |
46 .Set("name", name) | 49 .Set("name", name) |
47 .Set("description", "foo") | 50 .Set("description", "foo") |
48 .Set("manifest_version", 2) | 51 .Set("manifest_version", 2) |
49 .Set("version", "0.1.2.3") | 52 .Set("version", "0.1.2.3") |
50 .Set("permissions", permissions.Pass()) | 53 .Set("permissions", std::move(permissions)) |
51 .Set("optional_permissions", std::move(optional_permissions)))) | 54 .Set("optional_permissions", std::move(optional_permissions)))) |
52 .SetID(crx_file::id_util::GenerateId(name)) | 55 .SetID(crx_file::id_util::GenerateId(name)) |
53 .Build(); | 56 .Build(); |
54 } | 57 } |
55 | 58 |
56 // A helper class that listens for NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED. | 59 // A helper class that listens for NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED. |
57 class PermissionsUpdaterListener : public content::NotificationObserver { | 60 class PermissionsUpdaterListener : public content::NotificationObserver { |
58 public: | 61 public: |
59 PermissionsUpdaterListener() | 62 PermissionsUpdaterListener() |
60 : received_notification_(false), waiting_(false) { | 63 : received_notification_(false), waiting_(false) { |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 ->active_permissions() | 356 ->active_permissions() |
354 .HasExplicitAccessToOrigin(kOrigin)); | 357 .HasExplicitAccessToOrigin(kOrigin)); |
355 EXPECT_TRUE(extension->permissions_data() | 358 EXPECT_TRUE(extension->permissions_data() |
356 ->withheld_permissions() | 359 ->withheld_permissions() |
357 .HasExplicitAccessToOrigin(kOrigin)); | 360 .HasExplicitAccessToOrigin(kOrigin)); |
358 EXPECT_TRUE(updater.GetRevokablePermissions(extension.get())->IsEmpty()); | 361 EXPECT_TRUE(updater.GetRevokablePermissions(extension.get())->IsEmpty()); |
359 } | 362 } |
360 } | 363 } |
361 | 364 |
362 } // namespace extensions | 365 } // namespace extensions |
OLD | NEW |