Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: chrome/browser/extensions/api/permissions/permissions_apitest.cc

Issue 10649003: Move each permission classes to its own files in extensions/permissions (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase on HEAD Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "chrome/common/chrome_switches.h" 11 #include "chrome/common/chrome_switches.h"
12 #include "chrome/common/extensions/extension_permission_set.h" 12 #include "chrome/common/extensions/permissions/permission_set.h"
13 #include "net/base/mock_host_resolver.h" 13 #include "net/base/mock_host_resolver.h"
14 14
15 using extensions::APIPermission;
16 using extensions::APIPermissionSet;
17 using extensions::PermissionSet;
18
15 namespace { 19 namespace {
16 20
17 static void AddPattern(URLPatternSet* extent, const std::string& pattern) { 21 static void AddPattern(URLPatternSet* extent, const std::string& pattern) {
18 int schemes = URLPattern::SCHEME_ALL; 22 int schemes = URLPattern::SCHEME_ALL;
19 extent->AddPattern(URLPattern(schemes, pattern)); 23 extent->AddPattern(URLPattern(schemes, pattern));
20 } 24 }
21 25
22 } // namespace 26 } // namespace
23 27
24 class ExperimentalApiTest : public ExtensionApiTest { 28 class ExperimentalApiTest : public ExtensionApiTest {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 // Test functions and APIs that are always allowed (even if you ask for no 65 // Test functions and APIs that are always allowed (even if you ask for no
62 // permissions). 66 // permissions).
63 // Disabled: http://crbug.com/125193 67 // Disabled: http://crbug.com/125193
64 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_AlwaysAllowed) { 68 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_AlwaysAllowed) {
65 ASSERT_TRUE(RunExtensionTest("permissions/always_allowed")) << message_; 69 ASSERT_TRUE(RunExtensionTest("permissions/always_allowed")) << message_;
66 } 70 }
67 71
68 // Tests that the optional permissions API works correctly. 72 // Tests that the optional permissions API works correctly.
69 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGranted) { 73 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGranted) {
70 // 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.
71 ExtensionAPIPermissionSet apis; 75 APIPermissionSet apis;
72 apis.insert(ExtensionAPIPermission::kTab); 76 apis.insert(APIPermission::kTab);
73 URLPatternSet explicit_hosts; 77 URLPatternSet explicit_hosts;
74 AddPattern(&explicit_hosts, "http://*.c.com/*"); 78 AddPattern(&explicit_hosts, "http://*.c.com/*");
75 scoped_refptr<ExtensionPermissionSet> granted_permissions = 79 scoped_refptr<PermissionSet> granted_permissions =
76 new ExtensionPermissionSet(apis, explicit_hosts, URLPatternSet()); 80 new PermissionSet(apis, explicit_hosts, URLPatternSet());
77 81
78 ExtensionPrefs* prefs = 82 ExtensionPrefs* prefs =
79 browser()->profile()->GetExtensionService()->extension_prefs(); 83 browser()->profile()->GetExtensionService()->extension_prefs();
80 prefs->AddGrantedPermissions("kjmkgkdkpedkejedfhmfcenooemhbpbo", 84 prefs->AddGrantedPermissions("kjmkgkdkpedkejedfhmfcenooemhbpbo",
81 granted_permissions); 85 granted_permissions);
82 86
83 RequestPermissionsFunction::SetIgnoreUserGestureForTests(true); 87 RequestPermissionsFunction::SetIgnoreUserGestureForTests(true);
84 host_resolver()->AddRule("*.com", "127.0.0.1"); 88 host_resolver()->AddRule("*.com", "127.0.0.1");
85 ASSERT_TRUE(StartTestServer()); 89 ASSERT_TRUE(StartTestServer());
86 EXPECT_TRUE(RunExtensionTest("permissions/optional")) << message_; 90 EXPECT_TRUE(RunExtensionTest("permissions/optional")) << message_;
(...skipping 20 matching lines...) Expand all
107 } 111 }
108 112
109 // 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
110 // user gesture. 114 // user gesture.
111 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGesture) { 115 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGesture) {
112 RequestPermissionsFunction::SetIgnoreUserGestureForTests(false); 116 RequestPermissionsFunction::SetIgnoreUserGestureForTests(false);
113 host_resolver()->AddRule("*.com", "127.0.0.1"); 117 host_resolver()->AddRule("*.com", "127.0.0.1");
114 ASSERT_TRUE(StartTestServer()); 118 ASSERT_TRUE(StartTestServer());
115 EXPECT_TRUE(RunExtensionTest("permissions/optional_gesture")) << message_; 119 EXPECT_TRUE(RunExtensionTest("permissions/optional_gesture")) << message_;
116 } 120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698