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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // Tests that the optional permissions API works correctly. | 72 // Tests that the optional permissions API works correctly. |
73 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGranted) { | 73 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGranted) { |
74 // Mark all the tested APIs as granted to bypass the confirmation UI. | 74 // Mark all the tested APIs as granted to bypass the confirmation UI. |
75 APIPermissionSet apis; | 75 APIPermissionSet apis; |
76 apis.insert(APIPermission::kTab); | 76 apis.insert(APIPermission::kTab); |
77 URLPatternSet explicit_hosts; | 77 URLPatternSet explicit_hosts; |
78 AddPattern(&explicit_hosts, "http://*.c.com/*"); | 78 AddPattern(&explicit_hosts, "http://*.c.com/*"); |
79 scoped_refptr<PermissionSet> granted_permissions = | 79 scoped_refptr<PermissionSet> granted_permissions = |
80 new PermissionSet(apis, explicit_hosts, URLPatternSet()); | 80 new PermissionSet(apis, explicit_hosts, URLPatternSet()); |
81 | 81 |
82 ExtensionPrefs* prefs = | 82 extensions::ExtensionPrefs* prefs = |
83 browser()->profile()->GetExtensionService()->extension_prefs(); | 83 browser()->profile()->GetExtensionService()->extension_prefs(); |
84 prefs->AddGrantedPermissions("kjmkgkdkpedkejedfhmfcenooemhbpbo", | 84 prefs->AddGrantedPermissions("kjmkgkdkpedkejedfhmfcenooemhbpbo", |
85 granted_permissions); | 85 granted_permissions); |
86 | 86 |
87 RequestPermissionsFunction::SetIgnoreUserGestureForTests(true); | 87 RequestPermissionsFunction::SetIgnoreUserGestureForTests(true); |
88 host_resolver()->AddRule("*.com", "127.0.0.1"); | 88 host_resolver()->AddRule("*.com", "127.0.0.1"); |
89 ASSERT_TRUE(StartTestServer()); | 89 ASSERT_TRUE(StartTestServer()); |
90 EXPECT_TRUE(RunExtensionTest("permissions/optional")) << message_; | 90 EXPECT_TRUE(RunExtensionTest("permissions/optional")) << message_; |
91 } | 91 } |
92 | 92 |
(...skipping 18 matching lines...) Expand all Loading... |
111 } | 111 } |
112 | 112 |
113 // Tests that the permissions.request function must be called from within a | 113 // Tests that the permissions.request function must be called from within a |
114 // user gesture. | 114 // user gesture. |
115 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGesture) { | 115 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGesture) { |
116 RequestPermissionsFunction::SetIgnoreUserGestureForTests(false); | 116 RequestPermissionsFunction::SetIgnoreUserGestureForTests(false); |
117 host_resolver()->AddRule("*.com", "127.0.0.1"); | 117 host_resolver()->AddRule("*.com", "127.0.0.1"); |
118 ASSERT_TRUE(StartTestServer()); | 118 ASSERT_TRUE(StartTestServer()); |
119 EXPECT_TRUE(RunExtensionTest("permissions/optional_gesture")) << message_; | 119 EXPECT_TRUE(RunExtensionTest("permissions/optional_gesture")) << message_; |
120 } | 120 } |
OLD | NEW |