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

Side by Side Diff: chrome/common/extensions/permissions/permission_set_unittest.cc

Issue 2152373003: [Extensions] Code Cleanup - Remove redundant smart-ptr get()s (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 AddPattern(&explicit_hosts1, "http://*.google.com/*"); 370 AddPattern(&explicit_hosts1, "http://*.google.com/*");
371 AddPattern(&expected_explicit_hosts, "http://*.google.com/*"); 371 AddPattern(&expected_explicit_hosts, "http://*.google.com/*");
372 AddPattern(&effective_hosts, "http://*.google.com/*"); 372 AddPattern(&effective_hosts, "http://*.google.com/*");
373 373
374 set1.reset(new PermissionSet(apis1, manifest_permissions, explicit_hosts1, 374 set1.reset(new PermissionSet(apis1, manifest_permissions, explicit_hosts1,
375 scriptable_hosts1)); 375 scriptable_hosts1));
376 set2.reset(new PermissionSet(apis2, manifest_permissions, explicit_hosts2, 376 set2.reset(new PermissionSet(apis2, manifest_permissions, explicit_hosts2,
377 scriptable_hosts2)); 377 scriptable_hosts2));
378 union_set = PermissionSet::CreateUnion(*set1, *set2); 378 union_set = PermissionSet::CreateUnion(*set1, *set2);
379 EXPECT_TRUE(set1->Contains(*set2)); 379 EXPECT_TRUE(set1->Contains(*set2));
380 EXPECT_TRUE(set1->Contains(*union_set.get())); 380 EXPECT_TRUE(set1->Contains(*union_set));
381 EXPECT_FALSE(set2->Contains(*set1)); 381 EXPECT_FALSE(set2->Contains(*set1));
382 EXPECT_FALSE(set2->Contains(*union_set.get())); 382 EXPECT_FALSE(set2->Contains(*union_set));
383 EXPECT_TRUE(union_set->Contains(*set1)); 383 EXPECT_TRUE(union_set->Contains(*set1));
384 EXPECT_TRUE(union_set->Contains(*set2)); 384 EXPECT_TRUE(union_set->Contains(*set2));
385 385
386 EXPECT_FALSE(union_set->HasEffectiveFullAccess()); 386 EXPECT_FALSE(union_set->HasEffectiveFullAccess());
387 EXPECT_EQ(expected_apis, union_set->apis()); 387 EXPECT_EQ(expected_apis, union_set->apis());
388 EXPECT_EQ(expected_explicit_hosts, union_set->explicit_hosts()); 388 EXPECT_EQ(expected_explicit_hosts, union_set->explicit_hosts());
389 EXPECT_EQ(expected_scriptable_hosts, union_set->scriptable_hosts()); 389 EXPECT_EQ(expected_scriptable_hosts, union_set->scriptable_hosts());
390 EXPECT_EQ(expected_explicit_hosts, union_set->effective_hosts()); 390 EXPECT_EQ(expected_explicit_hosts, union_set->effective_hosts());
391 391
392 // Now use a real second set. 392 // Now use a real second set.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 AddPattern(&expected_scriptable_hosts, "http://*.google.com/*"); 427 AddPattern(&expected_scriptable_hosts, "http://*.google.com/*");
428 428
429 effective_hosts = 429 effective_hosts =
430 URLPatternSet::CreateUnion(explicit_hosts2, scriptable_hosts2); 430 URLPatternSet::CreateUnion(explicit_hosts2, scriptable_hosts2);
431 431
432 set2.reset(new PermissionSet(apis2, manifest_permissions, explicit_hosts2, 432 set2.reset(new PermissionSet(apis2, manifest_permissions, explicit_hosts2,
433 scriptable_hosts2)); 433 scriptable_hosts2));
434 union_set = PermissionSet::CreateUnion(*set1, *set2); 434 union_set = PermissionSet::CreateUnion(*set1, *set2);
435 435
436 EXPECT_FALSE(set1->Contains(*set2)); 436 EXPECT_FALSE(set1->Contains(*set2));
437 EXPECT_FALSE(set1->Contains(*union_set.get())); 437 EXPECT_FALSE(set1->Contains(*union_set));
438 EXPECT_FALSE(set2->Contains(*set1)); 438 EXPECT_FALSE(set2->Contains(*set1));
439 EXPECT_FALSE(set2->Contains(*union_set.get())); 439 EXPECT_FALSE(set2->Contains(*union_set));
440 EXPECT_TRUE(union_set->Contains(*set1)); 440 EXPECT_TRUE(union_set->Contains(*set1));
441 EXPECT_TRUE(union_set->Contains(*set2)); 441 EXPECT_TRUE(union_set->Contains(*set2));
442 442
443 EXPECT_TRUE(union_set->HasEffectiveFullAccess()); 443 EXPECT_TRUE(union_set->HasEffectiveFullAccess());
444 EXPECT_TRUE(union_set->HasEffectiveAccessToAllHosts()); 444 EXPECT_TRUE(union_set->HasEffectiveAccessToAllHosts());
445 EXPECT_EQ(expected_apis, union_set->apis()); 445 EXPECT_EQ(expected_apis, union_set->apis());
446 EXPECT_EQ(expected_explicit_hosts, union_set->explicit_hosts()); 446 EXPECT_EQ(expected_explicit_hosts, union_set->explicit_hosts());
447 EXPECT_EQ(expected_scriptable_hosts, union_set->scriptable_hosts()); 447 EXPECT_EQ(expected_scriptable_hosts, union_set->scriptable_hosts());
448 EXPECT_EQ(effective_hosts, union_set->effective_hosts()); 448 EXPECT_EQ(effective_hosts, union_set->effective_hosts());
449 } 449 }
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1766 scoped_refptr<Extension> extension_dwr( 1766 scoped_refptr<Extension> extension_dwr(
1767 LoadManifest("permissions", "web_request_all_host_permissions.json")); 1767 LoadManifest("permissions", "web_request_all_host_permissions.json"));
1768 const PermissionSet& permissions_dwr = 1768 const PermissionSet& permissions_dwr =
1769 extension_dwr->permissions_data()->active_permissions(); 1769 extension_dwr->permissions_data()->active_permissions();
1770 1770
1771 EXPECT_FALSE(PermissionMessageProvider::Get()->IsPrivilegeIncrease( 1771 EXPECT_FALSE(PermissionMessageProvider::Get()->IsPrivilegeIncrease(
1772 permissions, permissions_dwr, extension->GetType())); 1772 permissions, permissions_dwr, extension->GetType()));
1773 } 1773 }
1774 1774
1775 } // namespace extensions 1775 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698