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

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

Issue 8827013: Move/replace/rename URL-based extension getters from ExtensionService to/in ExtensionSet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: id Created 9 years 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/json/json_value_serializer.h" 5 #include "base/json/json_value_serializer.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "chrome/browser/extensions/extension_info_map.h" 8 #include "chrome/browser/extensions/extension_info_map.h"
9 #include "chrome/common/chrome_paths.h" 9 #include "chrome/common/chrome_paths.h"
10 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 WebSecurityOrigin app_origin = WebSecurityOrigin::create( 137 WebSecurityOrigin app_origin = WebSecurityOrigin::create(
138 GURL("http://www.google.com/mail/foo.html")); 138 GURL("http://www.google.com/mail/foo.html"));
139 ASSERT_TRUE(app->is_app()); 139 ASSERT_TRUE(app->is_app());
140 ASSERT_TRUE(app->web_extent().MatchesURL(app_url)); 140 ASSERT_TRUE(app->web_extent().MatchesURL(app_url));
141 141
142 info_map->AddExtension(app, base::Time(), false); 142 info_map->AddExtension(app, base::Time(), false);
143 info_map->AddExtension(extension, base::Time(), false); 143 info_map->AddExtension(extension, base::Time(), false);
144 144
145 // The app should have the notifications permission, either from a 145 // The app should have the notifications permission, either from a
146 // chrome-extension URL or from its web extent. 146 // chrome-extension URL or from its web extent.
147 const Extension* match = info_map->extensions().GetByURL( 147 const Extension* match = info_map->extensions().GetExtensionOrAppByURL(
148 ExtensionURLInfo(app_origin, app->GetResourceURL("a.html"))); 148 ExtensionURLInfo(app_origin, app->GetResourceURL("a.html")));
149 EXPECT_TRUE(match && 149 EXPECT_TRUE(match &&
150 match->HasAPIPermission(ExtensionAPIPermission::kNotification)); 150 match->HasAPIPermission(ExtensionAPIPermission::kNotification));
151 match = info_map->extensions().GetByURL( 151 match = info_map->extensions().GetExtensionOrAppByURL(
152 ExtensionURLInfo(app_origin, app_url)); 152 ExtensionURLInfo(app_origin, app_url));
153 EXPECT_TRUE(match && 153 EXPECT_TRUE(match &&
154 match->HasAPIPermission(ExtensionAPIPermission::kNotification)); 154 match->HasAPIPermission(ExtensionAPIPermission::kNotification));
155 EXPECT_FALSE(match && 155 EXPECT_FALSE(match &&
156 match->HasAPIPermission(ExtensionAPIPermission::kTab)); 156 match->HasAPIPermission(ExtensionAPIPermission::kTab));
157 157
158 // The extension should have the tabs permission. 158 // The extension should have the tabs permission.
159 match = info_map->extensions().GetByURL( 159 match = info_map->extensions().GetExtensionOrAppByURL(
160 ExtensionURLInfo(app_origin, extension->GetResourceURL("a.html"))); 160 ExtensionURLInfo(app_origin, extension->GetResourceURL("a.html")));
161 EXPECT_TRUE(match && 161 EXPECT_TRUE(match &&
162 match->HasAPIPermission(ExtensionAPIPermission::kTab)); 162 match->HasAPIPermission(ExtensionAPIPermission::kTab));
163 EXPECT_FALSE(match && 163 EXPECT_FALSE(match &&
164 match->HasAPIPermission(ExtensionAPIPermission::kNotification)); 164 match->HasAPIPermission(ExtensionAPIPermission::kNotification));
165 165
166 // Random URL should not have any permissions. 166 // Random URL should not have any permissions.
167 GURL evil_url("http://evil.com/a.html"); 167 GURL evil_url("http://evil.com/a.html");
168 match = info_map->extensions().GetByURL( 168 match = info_map->extensions().GetExtensionOrAppByURL(
169 ExtensionURLInfo(WebSecurityOrigin::create(evil_url), evil_url)); 169 ExtensionURLInfo(WebSecurityOrigin::create(evil_url), evil_url));
170 EXPECT_FALSE(match); 170 EXPECT_FALSE(match);
171 171
172 // Sandboxed origins should not have any permissions. 172 // Sandboxed origins should not have any permissions.
173 match = info_map->extensions().GetByURL(ExtensionURLInfo( 173 match = info_map->extensions().GetExtensionOrAppByURL(ExtensionURLInfo(
174 WebSecurityOrigin::createFromString(WebString::fromUTF8("null")), 174 WebSecurityOrigin::createFromString(WebString::fromUTF8("null")),
175 app_url)); 175 app_url));
176 EXPECT_FALSE(match); 176 EXPECT_FALSE(match);
177 } 177 }
178 178
179 } // namespace 179 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_function_dispatcher.cc ('k') | chrome/browser/extensions/extension_navigation_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698