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/api/permissions/permissions_api.h" | 5 #include "chrome/browser/extensions/api/permissions/permissions_api.h" |
6 #include "chrome/browser/extensions/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
7 #include "chrome/browser/extensions/extension_management_test_util.h" | 7 #include "chrome/browser/extensions/extension_management_test_util.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "components/policy/core/browser/browser_policy_connector.h" | 10 #include "components/policy/core/browser/browser_policy_connector.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } | 85 } |
86 | 86 |
87 // Tests that the optional permissions API works correctly. | 87 // Tests that the optional permissions API works correctly. |
88 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGranted) { | 88 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGranted) { |
89 // Mark all the tested APIs as granted to bypass the confirmation UI. | 89 // Mark all the tested APIs as granted to bypass the confirmation UI. |
90 APIPermissionSet apis; | 90 APIPermissionSet apis; |
91 apis.insert(APIPermission::kBookmark); | 91 apis.insert(APIPermission::kBookmark); |
92 ManifestPermissionSet manifest_permissions; | 92 ManifestPermissionSet manifest_permissions; |
93 URLPatternSet explicit_hosts; | 93 URLPatternSet explicit_hosts; |
94 AddPattern(&explicit_hosts, "http://*.c.com/*"); | 94 AddPattern(&explicit_hosts, "http://*.c.com/*"); |
95 scoped_refptr<const PermissionSet> granted_permissions = new PermissionSet( | 95 PermissionSet granted_permissions(apis, manifest_permissions, explicit_hosts, |
96 apis, manifest_permissions, explicit_hosts, URLPatternSet()); | 96 URLPatternSet()); |
97 | 97 |
98 ExtensionPrefs* prefs = ExtensionPrefs::Get(browser()->profile()); | 98 ExtensionPrefs* prefs = ExtensionPrefs::Get(browser()->profile()); |
99 prefs->AddGrantedPermissions("kjmkgkdkpedkejedfhmfcenooemhbpbo", | 99 prefs->AddGrantedPermissions("kjmkgkdkpedkejedfhmfcenooemhbpbo", |
100 granted_permissions.get()); | 100 &granted_permissions); |
101 | 101 |
102 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); | 102 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); |
103 host_resolver()->AddRule("*.com", "127.0.0.1"); | 103 host_resolver()->AddRule("*.com", "127.0.0.1"); |
104 ASSERT_TRUE(StartEmbeddedTestServer()); | 104 ASSERT_TRUE(StartEmbeddedTestServer()); |
105 EXPECT_TRUE(RunExtensionTest("permissions/optional")) << message_; | 105 EXPECT_TRUE(RunExtensionTest("permissions/optional")) << message_; |
106 } | 106 } |
107 | 107 |
108 // Tests that the optional permissions API works correctly. | 108 // Tests that the optional permissions API works correctly. |
109 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsAutoConfirm) { | 109 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsAutoConfirm) { |
110 // Rather than setting the granted permissions, set the UI autoconfirm flag | 110 // Rather than setting the granted permissions, set the UI autoconfirm flag |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 // Tests that requesting an optional permission from a background page, with | 197 // Tests that requesting an optional permission from a background page, with |
198 // another window open, grants the permission and updates the bindings | 198 // another window open, grants the permission and updates the bindings |
199 // (chrome.whatever, in this case chrome.alarms). Regression test for | 199 // (chrome.whatever, in this case chrome.alarms). Regression test for |
200 // crbug.com/435141, see details there for trickiness. | 200 // crbug.com/435141, see details there for trickiness. |
201 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsUpdatesBindings) { | 201 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsUpdatesBindings) { |
202 ASSERT_TRUE(RunExtensionTest("permissions/optional_updates_bindings")) | 202 ASSERT_TRUE(RunExtensionTest("permissions/optional_updates_bindings")) |
203 << message_; | 203 << message_; |
204 } | 204 } |
205 | 205 |
206 } // namespace extensions | 206 } // namespace extensions |
OLD | NEW |