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

Side by Side Diff: chrome/browser/extensions/extension_info_map_unittest.cc

Issue 7003098: Start refractoring extension permissions into ExtensionPermissionSet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix a bad merge Created 9 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "chrome/browser/extensions/extension_info_map.h" 7 #include "chrome/browser/extensions/extension_info_map.h"
8 #include "chrome/common/chrome_paths.h" 8 #include "chrome/common/chrome_paths.h"
9 #include "chrome/common/extensions/extension.h" 9 #include "chrome/common/extensions/extension.h"
10 #include "content/browser/browser_thread.h" 10 #include "content/browser/browser_thread.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 ASSERT_TRUE(app->web_extent().MatchesURL(app_url)); 131 ASSERT_TRUE(app->web_extent().MatchesURL(app_url));
132 132
133 info_map->AddExtension(app); 133 info_map->AddExtension(app);
134 info_map->AddExtension(extension); 134 info_map->AddExtension(extension);
135 135
136 // The app should have the notifications permission, either from a 136 // The app should have the notifications permission, either from a
137 // chrome-extension URL or from its web extent. 137 // chrome-extension URL or from its web extent.
138 const Extension* match = info_map->extensions().GetByURL( 138 const Extension* match = info_map->extensions().GetByURL(
139 app->GetResourceURL("a.html")); 139 app->GetResourceURL("a.html"));
140 EXPECT_TRUE(match && 140 EXPECT_TRUE(match &&
141 match->HasApiPermission(Extension::kNotificationPermission)); 141 match->HasApiPermission(ExtensionAPIPermission::Notification()));
142 match = info_map->extensions().GetByURL(app_url); 142 match = info_map->extensions().GetByURL(app_url);
143 EXPECT_TRUE(match && 143 EXPECT_TRUE(match &&
144 match->HasApiPermission(Extension::kNotificationPermission)); 144 match->HasApiPermission(ExtensionAPIPermission::Notification()));
145 EXPECT_FALSE(match && 145 EXPECT_FALSE(match &&
146 match->HasApiPermission(Extension::kTabPermission)); 146 match->HasApiPermission(ExtensionAPIPermission::Tab()));
147 147
148 // The extension should have the tabs permission. 148 // The extension should have the tabs permission.
149 match = info_map->extensions().GetByURL(extension->GetResourceURL("a.html")); 149 match = info_map->extensions().GetByURL(extension->GetResourceURL("a.html"));
150 EXPECT_TRUE(match && 150 EXPECT_TRUE(match &&
151 match->HasApiPermission(Extension::kTabPermission)); 151 match->HasApiPermission(ExtensionAPIPermission::Tab()));
152 EXPECT_FALSE(match && 152 EXPECT_FALSE(match &&
153 match->HasApiPermission(Extension::kNotificationPermission)); 153 match->HasApiPermission(ExtensionAPIPermission::Notification()));
154 154
155 // Random URL should not have any permissions. 155 // Random URL should not have any permissions.
156 match = info_map->extensions().GetByURL(GURL("http://evil.com/a.html")); 156 match = info_map->extensions().GetByURL(GURL("http://evil.com/a.html"));
157 EXPECT_FALSE(match); 157 EXPECT_FALSE(match);
158 } 158 }
159 159
160 } // namespace 160 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698