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

Side by Side Diff: extensions/common/permissions/permissions_data_unittest.cc

Issue 503873002: Remove implicit conversions from scoped_refptr to T* in extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <vector> 5 #include <vector>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 SocketPermissionRequest::UDP_SEND_TO, 252 SocketPermissionRequest::UDP_SEND_TO,
253 "239.255.255.250", 1900)); 253 "239.255.255.250", 1900));
254 } 254 }
255 255
256 TEST(ExtensionPermissionsTest, IsRestrictedUrl) { 256 TEST(ExtensionPermissionsTest, IsRestrictedUrl) {
257 scoped_refptr<const Extension> extension = 257 scoped_refptr<const Extension> extension =
258 GetExtensionWithHostPermission("normal_extension", 258 GetExtensionWithHostPermission("normal_extension",
259 kAllHostsPermission, 259 kAllHostsPermission,
260 Manifest::INTERNAL); 260 Manifest::INTERNAL);
261 // Chrome urls should be blocked for normal extensions. 261 // Chrome urls should be blocked for normal extensions.
262 CheckRestrictedUrls(extension, true); 262 CheckRestrictedUrls(extension.get(), true);
263 263
264 scoped_refptr<const Extension> component = 264 scoped_refptr<const Extension> component =
265 GetExtensionWithHostPermission("component", 265 GetExtensionWithHostPermission("component",
266 kAllHostsPermission, 266 kAllHostsPermission,
267 Manifest::COMPONENT); 267 Manifest::COMPONENT);
268 // Chrome urls should be accessible by component extensions. 268 // Chrome urls should be accessible by component extensions.
269 CheckRestrictedUrls(component, false); 269 CheckRestrictedUrls(component.get(), false);
270 270
271 base::CommandLine::ForCurrentProcess()->AppendSwitch( 271 base::CommandLine::ForCurrentProcess()->AppendSwitch(
272 switches::kExtensionsOnChromeURLs); 272 switches::kExtensionsOnChromeURLs);
273 // Enabling the switch should allow all extensions to access chrome urls. 273 // Enabling the switch should allow all extensions to access chrome urls.
274 CheckRestrictedUrls(extension, false); 274 CheckRestrictedUrls(extension.get(), false);
275
276 } 275 }
277 276
278 TEST(ExtensionPermissionsTest, GetPermissionMessages_ManyAPIPermissions) { 277 TEST(ExtensionPermissionsTest, GetPermissionMessages_ManyAPIPermissions) {
279 scoped_refptr<Extension> extension; 278 scoped_refptr<Extension> extension;
280 extension = LoadManifest("permissions", "many-apis.json"); 279 extension = LoadManifest("permissions", "many-apis.json");
281 std::vector<base::string16> warnings = 280 std::vector<base::string16> warnings =
282 extension->permissions_data()->GetPermissionMessageStrings(); 281 extension->permissions_data()->GetPermissionMessageStrings();
283 // Warning for "tabs" is suppressed by "history" permission. 282 // Warning for "tabs" is suppressed by "history" permission.
284 ASSERT_EQ(5u, warnings.size()); 283 ASSERT_EQ(5u, warnings.size());
285 EXPECT_EQ("Read and change your data on api.flickr.com", 284 EXPECT_EQ("Read and change your data on api.flickr.com",
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 745
747 permissions_data->ClearTabSpecificPermissions(1); 746 permissions_data->ClearTabSpecificPermissions(1);
748 EXPECT_FALSE(permissions_data->GetTabSpecificPermissionsForTesting(1)); 747 EXPECT_FALSE(permissions_data->GetTabSpecificPermissionsForTesting(1));
749 748
750 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 0)); 749 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 0));
751 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 1)); 750 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 1));
752 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 2)); 751 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 2));
753 } 752 }
754 753
755 } // namespace extensions 754 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/permissions/permissions_data.cc ('k') | extensions/renderer/api/serial/data_receiver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698