| 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_prefs.h" | 7 #include "chrome/browser/extensions/extension_prefs.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // Disabled: http://crbug.com/125193 | 65 // Disabled: http://crbug.com/125193 |
| 66 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_AlwaysAllowed) { | 66 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_AlwaysAllowed) { |
| 67 ASSERT_TRUE(RunExtensionTest("permissions/always_allowed")) << message_; | 67 ASSERT_TRUE(RunExtensionTest("permissions/always_allowed")) << message_; |
| 68 } | 68 } |
| 69 | 69 |
| 70 // Tests that the optional permissions API works correctly. | 70 // Tests that the optional permissions API works correctly. |
| 71 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGranted) { | 71 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGranted) { |
| 72 // Mark all the tested APIs as granted to bypass the confirmation UI. | 72 // Mark all the tested APIs as granted to bypass the confirmation UI. |
| 73 APIPermissionSet apis; | 73 APIPermissionSet apis; |
| 74 apis.insert(APIPermission::kBookmark); | 74 apis.insert(APIPermission::kBookmark); |
| 75 ManifestPermissionSet manifest_permissions; |
| 75 URLPatternSet explicit_hosts; | 76 URLPatternSet explicit_hosts; |
| 76 AddPattern(&explicit_hosts, "http://*.c.com/*"); | 77 AddPattern(&explicit_hosts, "http://*.c.com/*"); |
| 77 scoped_refptr<PermissionSet> granted_permissions = | 78 scoped_refptr<PermissionSet> granted_permissions = |
| 78 new PermissionSet(apis, explicit_hosts, URLPatternSet()); | 79 new PermissionSet(apis, manifest_permissions, |
| 80 explicit_hosts, URLPatternSet()); |
| 79 | 81 |
| 80 ExtensionPrefs* prefs = | 82 ExtensionPrefs* prefs = |
| 81 browser()->profile()->GetExtensionService()->extension_prefs(); | 83 browser()->profile()->GetExtensionService()->extension_prefs(); |
| 82 prefs->AddGrantedPermissions("kjmkgkdkpedkejedfhmfcenooemhbpbo", | 84 prefs->AddGrantedPermissions("kjmkgkdkpedkejedfhmfcenooemhbpbo", |
| 83 granted_permissions.get()); | 85 granted_permissions.get()); |
| 84 | 86 |
| 85 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); | 87 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); |
| 86 host_resolver()->AddRule("*.com", "127.0.0.1"); | 88 host_resolver()->AddRule("*.com", "127.0.0.1"); |
| 87 ASSERT_TRUE(StartEmbeddedTestServer()); | 89 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 88 EXPECT_TRUE(RunExtensionTest("permissions/optional")) << message_; | 90 EXPECT_TRUE(RunExtensionTest("permissions/optional")) << message_; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 147 |
| 146 // Test requesting, querying, and removing host permissions for host | 148 // Test requesting, querying, and removing host permissions for host |
| 147 // permissions that are a subset of the optional permissions. | 149 // permissions that are a subset of the optional permissions. |
| 148 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, HostSubsets) { | 150 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, HostSubsets) { |
| 149 PermissionsRequestFunction::SetAutoConfirmForTests(true); | 151 PermissionsRequestFunction::SetAutoConfirmForTests(true); |
| 150 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); | 152 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); |
| 151 EXPECT_TRUE(RunExtensionTest("permissions/host_subsets")) << message_; | 153 EXPECT_TRUE(RunExtensionTest("permissions/host_subsets")) << message_; |
| 152 } | 154 } |
| 153 | 155 |
| 154 } // namespace extensions | 156 } // namespace extensions |
| OLD | NEW |