| OLD | NEW |
| 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 <utility> | 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 10 #include "base/json/json_file_value_serializer.h" | 11 #include "base/json/json_file_value_serializer.h" |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 URLPatternSet explicit_hosts1; | 337 URLPatternSet explicit_hosts1; |
| 337 URLPatternSet explicit_hosts2; | 338 URLPatternSet explicit_hosts2; |
| 338 URLPatternSet expected_explicit_hosts; | 339 URLPatternSet expected_explicit_hosts; |
| 339 | 340 |
| 340 URLPatternSet scriptable_hosts1; | 341 URLPatternSet scriptable_hosts1; |
| 341 URLPatternSet scriptable_hosts2; | 342 URLPatternSet scriptable_hosts2; |
| 342 URLPatternSet expected_scriptable_hosts; | 343 URLPatternSet expected_scriptable_hosts; |
| 343 | 344 |
| 344 URLPatternSet effective_hosts; | 345 URLPatternSet effective_hosts; |
| 345 | 346 |
| 346 scoped_ptr<const PermissionSet> set1; | 347 std::unique_ptr<const PermissionSet> set1; |
| 347 scoped_ptr<const PermissionSet> set2; | 348 std::unique_ptr<const PermissionSet> set2; |
| 348 scoped_ptr<const PermissionSet> union_set; | 349 std::unique_ptr<const PermissionSet> union_set; |
| 349 | 350 |
| 350 const APIPermissionInfo* permission_info = | 351 const APIPermissionInfo* permission_info = |
| 351 PermissionsInfo::GetInstance()->GetByID(APIPermission::kSocket); | 352 PermissionsInfo::GetInstance()->GetByID(APIPermission::kSocket); |
| 352 permission = permission_info->CreateAPIPermission(); | 353 permission = permission_info->CreateAPIPermission(); |
| 353 { | 354 { |
| 354 scoped_ptr<base::ListValue> value(new base::ListValue()); | 355 std::unique_ptr<base::ListValue> value(new base::ListValue()); |
| 355 value->Append(new base::StringValue("tcp-connect:*.example.com:80")); | 356 value->Append(new base::StringValue("tcp-connect:*.example.com:80")); |
| 356 value->Append(new base::StringValue("udp-bind::8080")); | 357 value->Append(new base::StringValue("udp-bind::8080")); |
| 357 value->Append(new base::StringValue("udp-send-to::8888")); | 358 value->Append(new base::StringValue("udp-send-to::8888")); |
| 358 ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL)); | 359 ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL)); |
| 359 } | 360 } |
| 360 | 361 |
| 361 // Union with an empty set. | 362 // Union with an empty set. |
| 362 apis1.insert(APIPermission::kTab); | 363 apis1.insert(APIPermission::kTab); |
| 363 apis1.insert(APIPermission::kBackground); | 364 apis1.insert(APIPermission::kBackground); |
| 364 apis1.insert(permission->Clone()); | 365 apis1.insert(permission->Clone()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 389 EXPECT_EQ(expected_explicit_hosts, union_set->effective_hosts()); | 390 EXPECT_EQ(expected_explicit_hosts, union_set->effective_hosts()); |
| 390 | 391 |
| 391 // Now use a real second set. | 392 // Now use a real second set. |
| 392 apis2.insert(APIPermission::kTab); | 393 apis2.insert(APIPermission::kTab); |
| 393 apis2.insert(APIPermission::kProxy); | 394 apis2.insert(APIPermission::kProxy); |
| 394 apis2.insert(APIPermission::kClipboardWrite); | 395 apis2.insert(APIPermission::kClipboardWrite); |
| 395 apis2.insert(APIPermission::kPlugin); | 396 apis2.insert(APIPermission::kPlugin); |
| 396 | 397 |
| 397 permission = permission_info->CreateAPIPermission(); | 398 permission = permission_info->CreateAPIPermission(); |
| 398 { | 399 { |
| 399 scoped_ptr<base::ListValue> value(new base::ListValue()); | 400 std::unique_ptr<base::ListValue> value(new base::ListValue()); |
| 400 value->Append(new base::StringValue("tcp-connect:*.example.com:80")); | 401 value->Append(new base::StringValue("tcp-connect:*.example.com:80")); |
| 401 value->Append(new base::StringValue("udp-send-to::8899")); | 402 value->Append(new base::StringValue("udp-send-to::8899")); |
| 402 ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL)); | 403 ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL)); |
| 403 } | 404 } |
| 404 apis2.insert(permission); | 405 apis2.insert(permission); |
| 405 | 406 |
| 406 expected_apis.insert(APIPermission::kTab); | 407 expected_apis.insert(APIPermission::kTab); |
| 407 expected_apis.insert(APIPermission::kProxy); | 408 expected_apis.insert(APIPermission::kProxy); |
| 408 expected_apis.insert(APIPermission::kClipboardWrite); | 409 expected_apis.insert(APIPermission::kClipboardWrite); |
| 409 expected_apis.insert(APIPermission::kPlugin); | 410 expected_apis.insert(APIPermission::kPlugin); |
| 410 | 411 |
| 411 permission = permission_info->CreateAPIPermission(); | 412 permission = permission_info->CreateAPIPermission(); |
| 412 { | 413 { |
| 413 scoped_ptr<base::ListValue> value(new base::ListValue()); | 414 std::unique_ptr<base::ListValue> value(new base::ListValue()); |
| 414 value->Append(new base::StringValue("tcp-connect:*.example.com:80")); | 415 value->Append(new base::StringValue("tcp-connect:*.example.com:80")); |
| 415 value->Append(new base::StringValue("udp-bind::8080")); | 416 value->Append(new base::StringValue("udp-bind::8080")); |
| 416 value->Append(new base::StringValue("udp-send-to::8888")); | 417 value->Append(new base::StringValue("udp-send-to::8888")); |
| 417 value->Append(new base::StringValue("udp-send-to::8899")); | 418 value->Append(new base::StringValue("udp-send-to::8899")); |
| 418 ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL)); | 419 ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL)); |
| 419 } | 420 } |
| 420 // Insert a new permission socket permisssion which will replace the old one. | 421 // Insert a new permission socket permisssion which will replace the old one. |
| 421 expected_apis.insert(permission); | 422 expected_apis.insert(permission); |
| 422 | 423 |
| 423 AddPattern(&explicit_hosts2, "http://*.example.com/*"); | 424 AddPattern(&explicit_hosts2, "http://*.example.com/*"); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 URLPatternSet explicit_hosts1; | 459 URLPatternSet explicit_hosts1; |
| 459 URLPatternSet explicit_hosts2; | 460 URLPatternSet explicit_hosts2; |
| 460 URLPatternSet expected_explicit_hosts; | 461 URLPatternSet expected_explicit_hosts; |
| 461 | 462 |
| 462 URLPatternSet scriptable_hosts1; | 463 URLPatternSet scriptable_hosts1; |
| 463 URLPatternSet scriptable_hosts2; | 464 URLPatternSet scriptable_hosts2; |
| 464 URLPatternSet expected_scriptable_hosts; | 465 URLPatternSet expected_scriptable_hosts; |
| 465 | 466 |
| 466 URLPatternSet effective_hosts; | 467 URLPatternSet effective_hosts; |
| 467 | 468 |
| 468 scoped_ptr<const PermissionSet> set1; | 469 std::unique_ptr<const PermissionSet> set1; |
| 469 scoped_ptr<const PermissionSet> set2; | 470 std::unique_ptr<const PermissionSet> set2; |
| 470 scoped_ptr<const PermissionSet> new_set; | 471 std::unique_ptr<const PermissionSet> new_set; |
| 471 | 472 |
| 472 const APIPermissionInfo* permission_info = | 473 const APIPermissionInfo* permission_info = |
| 473 PermissionsInfo::GetInstance()->GetByID(APIPermission::kSocket); | 474 PermissionsInfo::GetInstance()->GetByID(APIPermission::kSocket); |
| 474 | 475 |
| 475 // Intersection with an empty set. | 476 // Intersection with an empty set. |
| 476 apis1.insert(APIPermission::kTab); | 477 apis1.insert(APIPermission::kTab); |
| 477 apis1.insert(APIPermission::kBackground); | 478 apis1.insert(APIPermission::kBackground); |
| 478 permission = permission_info->CreateAPIPermission(); | 479 permission = permission_info->CreateAPIPermission(); |
| 479 { | 480 { |
| 480 scoped_ptr<base::ListValue> value(new base::ListValue()); | 481 std::unique_ptr<base::ListValue> value(new base::ListValue()); |
| 481 value->Append(new base::StringValue("tcp-connect:*.example.com:80")); | 482 value->Append(new base::StringValue("tcp-connect:*.example.com:80")); |
| 482 value->Append(new base::StringValue("udp-bind::8080")); | 483 value->Append(new base::StringValue("udp-bind::8080")); |
| 483 value->Append(new base::StringValue("udp-send-to::8888")); | 484 value->Append(new base::StringValue("udp-send-to::8888")); |
| 484 ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL)); | 485 ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL)); |
| 485 } | 486 } |
| 486 apis1.insert(permission); | 487 apis1.insert(permission); |
| 487 | 488 |
| 488 AddPattern(&explicit_hosts1, "http://*.google.com/*"); | 489 AddPattern(&explicit_hosts1, "http://*.google.com/*"); |
| 489 AddPattern(&scriptable_hosts1, "http://www.reddit.com/*"); | 490 AddPattern(&scriptable_hosts1, "http://www.reddit.com/*"); |
| 490 | 491 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 507 EXPECT_EQ(expected_scriptable_hosts, new_set->scriptable_hosts()); | 508 EXPECT_EQ(expected_scriptable_hosts, new_set->scriptable_hosts()); |
| 508 EXPECT_EQ(expected_explicit_hosts, new_set->effective_hosts()); | 509 EXPECT_EQ(expected_explicit_hosts, new_set->effective_hosts()); |
| 509 | 510 |
| 510 // Now use a real second set. | 511 // Now use a real second set. |
| 511 apis2.insert(APIPermission::kTab); | 512 apis2.insert(APIPermission::kTab); |
| 512 apis2.insert(APIPermission::kProxy); | 513 apis2.insert(APIPermission::kProxy); |
| 513 apis2.insert(APIPermission::kClipboardWrite); | 514 apis2.insert(APIPermission::kClipboardWrite); |
| 514 apis2.insert(APIPermission::kPlugin); | 515 apis2.insert(APIPermission::kPlugin); |
| 515 permission = permission_info->CreateAPIPermission(); | 516 permission = permission_info->CreateAPIPermission(); |
| 516 { | 517 { |
| 517 scoped_ptr<base::ListValue> value(new base::ListValue()); | 518 std::unique_ptr<base::ListValue> value(new base::ListValue()); |
| 518 value->Append(new base::StringValue("udp-bind::8080")); | 519 value->Append(new base::StringValue("udp-bind::8080")); |
| 519 value->Append(new base::StringValue("udp-send-to::8888")); | 520 value->Append(new base::StringValue("udp-send-to::8888")); |
| 520 value->Append(new base::StringValue("udp-send-to::8899")); | 521 value->Append(new base::StringValue("udp-send-to::8899")); |
| 521 ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL)); | 522 ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL)); |
| 522 } | 523 } |
| 523 apis2.insert(permission); | 524 apis2.insert(permission); |
| 524 | 525 |
| 525 expected_apis.insert(APIPermission::kTab); | 526 expected_apis.insert(APIPermission::kTab); |
| 526 permission = permission_info->CreateAPIPermission(); | 527 permission = permission_info->CreateAPIPermission(); |
| 527 { | 528 { |
| 528 scoped_ptr<base::ListValue> value(new base::ListValue()); | 529 std::unique_ptr<base::ListValue> value(new base::ListValue()); |
| 529 value->Append(new base::StringValue("udp-bind::8080")); | 530 value->Append(new base::StringValue("udp-bind::8080")); |
| 530 value->Append(new base::StringValue("udp-send-to::8888")); | 531 value->Append(new base::StringValue("udp-send-to::8888")); |
| 531 ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL)); | 532 ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL)); |
| 532 } | 533 } |
| 533 expected_apis.insert(permission); | 534 expected_apis.insert(permission); |
| 534 | 535 |
| 535 AddPattern(&explicit_hosts2, "http://*.example.com/*"); | 536 AddPattern(&explicit_hosts2, "http://*.example.com/*"); |
| 536 AddPattern(&explicit_hosts2, "http://*.google.com/*"); | 537 AddPattern(&explicit_hosts2, "http://*.google.com/*"); |
| 537 AddPattern(&scriptable_hosts2, "http://*.google.com/*"); | 538 AddPattern(&scriptable_hosts2, "http://*.google.com/*"); |
| 538 AddPattern(&expected_explicit_hosts, "http://*.google.com/*"); | 539 AddPattern(&expected_explicit_hosts, "http://*.google.com/*"); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 URLPatternSet explicit_hosts1; | 571 URLPatternSet explicit_hosts1; |
| 571 URLPatternSet explicit_hosts2; | 572 URLPatternSet explicit_hosts2; |
| 572 URLPatternSet expected_explicit_hosts; | 573 URLPatternSet expected_explicit_hosts; |
| 573 | 574 |
| 574 URLPatternSet scriptable_hosts1; | 575 URLPatternSet scriptable_hosts1; |
| 575 URLPatternSet scriptable_hosts2; | 576 URLPatternSet scriptable_hosts2; |
| 576 URLPatternSet expected_scriptable_hosts; | 577 URLPatternSet expected_scriptable_hosts; |
| 577 | 578 |
| 578 URLPatternSet effective_hosts; | 579 URLPatternSet effective_hosts; |
| 579 | 580 |
| 580 scoped_ptr<const PermissionSet> set1; | 581 std::unique_ptr<const PermissionSet> set1; |
| 581 scoped_ptr<const PermissionSet> set2; | 582 std::unique_ptr<const PermissionSet> set2; |
| 582 scoped_ptr<const PermissionSet> new_set; | 583 std::unique_ptr<const PermissionSet> new_set; |
| 583 | 584 |
| 584 const APIPermissionInfo* permission_info = | 585 const APIPermissionInfo* permission_info = |
| 585 PermissionsInfo::GetInstance()->GetByID(APIPermission::kSocket); | 586 PermissionsInfo::GetInstance()->GetByID(APIPermission::kSocket); |
| 586 | 587 |
| 587 // Difference with an empty set. | 588 // Difference with an empty set. |
| 588 apis1.insert(APIPermission::kTab); | 589 apis1.insert(APIPermission::kTab); |
| 589 apis1.insert(APIPermission::kBackground); | 590 apis1.insert(APIPermission::kBackground); |
| 590 permission = permission_info->CreateAPIPermission(); | 591 permission = permission_info->CreateAPIPermission(); |
| 591 { | 592 { |
| 592 scoped_ptr<base::ListValue> value(new base::ListValue()); | 593 std::unique_ptr<base::ListValue> value(new base::ListValue()); |
| 593 value->Append(new base::StringValue("tcp-connect:*.example.com:80")); | 594 value->Append(new base::StringValue("tcp-connect:*.example.com:80")); |
| 594 value->Append(new base::StringValue("udp-bind::8080")); | 595 value->Append(new base::StringValue("udp-bind::8080")); |
| 595 value->Append(new base::StringValue("udp-send-to::8888")); | 596 value->Append(new base::StringValue("udp-send-to::8888")); |
| 596 ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL)); | 597 ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL)); |
| 597 } | 598 } |
| 598 apis1.insert(permission); | 599 apis1.insert(permission); |
| 599 | 600 |
| 600 AddPattern(&explicit_hosts1, "http://*.google.com/*"); | 601 AddPattern(&explicit_hosts1, "http://*.google.com/*"); |
| 601 AddPattern(&scriptable_hosts1, "http://www.reddit.com/*"); | 602 AddPattern(&scriptable_hosts1, "http://www.reddit.com/*"); |
| 602 | 603 |
| 603 set1.reset(new PermissionSet(apis1, manifest_permissions, explicit_hosts1, | 604 set1.reset(new PermissionSet(apis1, manifest_permissions, explicit_hosts1, |
| 604 scriptable_hosts1)); | 605 scriptable_hosts1)); |
| 605 set2.reset(new PermissionSet(apis2, manifest_permissions, explicit_hosts2, | 606 set2.reset(new PermissionSet(apis2, manifest_permissions, explicit_hosts2, |
| 606 scriptable_hosts2)); | 607 scriptable_hosts2)); |
| 607 new_set = PermissionSet::CreateDifference(*set1, *set2); | 608 new_set = PermissionSet::CreateDifference(*set1, *set2); |
| 608 EXPECT_EQ(*set1, *new_set); | 609 EXPECT_EQ(*set1, *new_set); |
| 609 | 610 |
| 610 // Now use a real second set. | 611 // Now use a real second set. |
| 611 apis2.insert(APIPermission::kTab); | 612 apis2.insert(APIPermission::kTab); |
| 612 apis2.insert(APIPermission::kProxy); | 613 apis2.insert(APIPermission::kProxy); |
| 613 apis2.insert(APIPermission::kClipboardWrite); | 614 apis2.insert(APIPermission::kClipboardWrite); |
| 614 apis2.insert(APIPermission::kPlugin); | 615 apis2.insert(APIPermission::kPlugin); |
| 615 permission = permission_info->CreateAPIPermission(); | 616 permission = permission_info->CreateAPIPermission(); |
| 616 { | 617 { |
| 617 scoped_ptr<base::ListValue> value(new base::ListValue()); | 618 std::unique_ptr<base::ListValue> value(new base::ListValue()); |
| 618 value->Append(new base::StringValue("tcp-connect:*.example.com:80")); | 619 value->Append(new base::StringValue("tcp-connect:*.example.com:80")); |
| 619 value->Append(new base::StringValue("udp-send-to::8899")); | 620 value->Append(new base::StringValue("udp-send-to::8899")); |
| 620 ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL)); | 621 ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL)); |
| 621 } | 622 } |
| 622 apis2.insert(permission); | 623 apis2.insert(permission); |
| 623 | 624 |
| 624 expected_apis.insert(APIPermission::kBackground); | 625 expected_apis.insert(APIPermission::kBackground); |
| 625 permission = permission_info->CreateAPIPermission(); | 626 permission = permission_info->CreateAPIPermission(); |
| 626 { | 627 { |
| 627 scoped_ptr<base::ListValue> value(new base::ListValue()); | 628 std::unique_ptr<base::ListValue> value(new base::ListValue()); |
| 628 value->Append(new base::StringValue("udp-bind::8080")); | 629 value->Append(new base::StringValue("udp-bind::8080")); |
| 629 value->Append(new base::StringValue("udp-send-to::8888")); | 630 value->Append(new base::StringValue("udp-send-to::8888")); |
| 630 ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL)); | 631 ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL)); |
| 631 } | 632 } |
| 632 expected_apis.insert(permission); | 633 expected_apis.insert(permission); |
| 633 | 634 |
| 634 AddPattern(&explicit_hosts2, "http://*.example.com/*"); | 635 AddPattern(&explicit_hosts2, "http://*.example.com/*"); |
| 635 AddPattern(&explicit_hosts2, "http://*.google.com/*"); | 636 AddPattern(&explicit_hosts2, "http://*.google.com/*"); |
| 636 AddPattern(&scriptable_hosts2, "http://*.google.com/*"); | 637 AddPattern(&scriptable_hosts2, "http://*.google.com/*"); |
| 637 AddPattern(&expected_scriptable_hosts, "http://www.reddit.com/*"); | 638 AddPattern(&expected_scriptable_hosts, "http://www.reddit.com/*"); |
| (...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1580 } | 1581 } |
| 1581 | 1582 |
| 1582 TEST(PermissionsTest, IsHostPrivilegeIncrease) { | 1583 TEST(PermissionsTest, IsHostPrivilegeIncrease) { |
| 1583 Manifest::Type type = Manifest::TYPE_EXTENSION; | 1584 Manifest::Type type = Manifest::TYPE_EXTENSION; |
| 1584 const PermissionMessageProvider* provider = PermissionMessageProvider::Get(); | 1585 const PermissionMessageProvider* provider = PermissionMessageProvider::Get(); |
| 1585 ManifestPermissionSet empty_manifest_permissions; | 1586 ManifestPermissionSet empty_manifest_permissions; |
| 1586 URLPatternSet elist1; | 1587 URLPatternSet elist1; |
| 1587 URLPatternSet elist2; | 1588 URLPatternSet elist2; |
| 1588 URLPatternSet slist1; | 1589 URLPatternSet slist1; |
| 1589 URLPatternSet slist2; | 1590 URLPatternSet slist2; |
| 1590 scoped_ptr<const PermissionSet> set1; | 1591 std::unique_ptr<const PermissionSet> set1; |
| 1591 scoped_ptr<const PermissionSet> set2; | 1592 std::unique_ptr<const PermissionSet> set2; |
| 1592 APIPermissionSet empty_perms; | 1593 APIPermissionSet empty_perms; |
| 1593 elist1.AddPattern( | 1594 elist1.AddPattern( |
| 1594 URLPattern(URLPattern::SCHEME_HTTP, "http://www.google.com.hk/path")); | 1595 URLPattern(URLPattern::SCHEME_HTTP, "http://www.google.com.hk/path")); |
| 1595 elist1.AddPattern( | 1596 elist1.AddPattern( |
| 1596 URLPattern(URLPattern::SCHEME_HTTP, "http://www.google.com/path")); | 1597 URLPattern(URLPattern::SCHEME_HTTP, "http://www.google.com/path")); |
| 1597 | 1598 |
| 1598 // Test that the host order does not matter. | 1599 // Test that the host order does not matter. |
| 1599 elist2.AddPattern( | 1600 elist2.AddPattern( |
| 1600 URLPattern(URLPattern::SCHEME_HTTP, "http://www.google.com/path")); | 1601 URLPattern(URLPattern::SCHEME_HTTP, "http://www.google.com/path")); |
| 1601 elist2.AddPattern( | 1602 elist2.AddPattern( |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1679 // and we can convert it back to the id set. | 1680 // and we can convert it back to the id set. |
| 1680 EXPECT_EQ(4u, api_names.size()); | 1681 EXPECT_EQ(4u, api_names.size()); |
| 1681 EXPECT_EQ(apis, | 1682 EXPECT_EQ(apis, |
| 1682 PermissionsInfo::GetInstance()->GetAllByName(api_names)); | 1683 PermissionsInfo::GetInstance()->GetAllByName(api_names)); |
| 1683 } | 1684 } |
| 1684 | 1685 |
| 1685 TEST(PermissionsTest, IsEmpty) { | 1686 TEST(PermissionsTest, IsEmpty) { |
| 1686 APIPermissionSet empty_apis; | 1687 APIPermissionSet empty_apis; |
| 1687 URLPatternSet empty_extent; | 1688 URLPatternSet empty_extent; |
| 1688 | 1689 |
| 1689 scoped_ptr<const PermissionSet> empty(new PermissionSet()); | 1690 std::unique_ptr<const PermissionSet> empty(new PermissionSet()); |
| 1690 EXPECT_TRUE(empty->IsEmpty()); | 1691 EXPECT_TRUE(empty->IsEmpty()); |
| 1691 scoped_ptr<const PermissionSet> perm_set; | 1692 std::unique_ptr<const PermissionSet> perm_set; |
| 1692 | 1693 |
| 1693 perm_set.reset(new PermissionSet(empty_apis, ManifestPermissionSet(), | 1694 perm_set.reset(new PermissionSet(empty_apis, ManifestPermissionSet(), |
| 1694 empty_extent, empty_extent)); | 1695 empty_extent, empty_extent)); |
| 1695 EXPECT_TRUE(perm_set->IsEmpty()); | 1696 EXPECT_TRUE(perm_set->IsEmpty()); |
| 1696 | 1697 |
| 1697 APIPermissionSet non_empty_apis; | 1698 APIPermissionSet non_empty_apis; |
| 1698 non_empty_apis.insert(APIPermission::kBackground); | 1699 non_empty_apis.insert(APIPermission::kBackground); |
| 1699 perm_set.reset(new PermissionSet(non_empty_apis, ManifestPermissionSet(), | 1700 perm_set.reset(new PermissionSet(non_empty_apis, ManifestPermissionSet(), |
| 1700 empty_extent, empty_extent)); | 1701 empty_extent, empty_extent)); |
| 1701 EXPECT_FALSE(perm_set->IsEmpty()); | 1702 EXPECT_FALSE(perm_set->IsEmpty()); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1765 scoped_refptr<Extension> extension_dwr( | 1766 scoped_refptr<Extension> extension_dwr( |
| 1766 LoadManifest("permissions", "web_request_all_host_permissions.json")); | 1767 LoadManifest("permissions", "web_request_all_host_permissions.json")); |
| 1767 const PermissionSet& permissions_dwr = | 1768 const PermissionSet& permissions_dwr = |
| 1768 extension_dwr->permissions_data()->active_permissions(); | 1769 extension_dwr->permissions_data()->active_permissions(); |
| 1769 | 1770 |
| 1770 EXPECT_FALSE(PermissionMessageProvider::Get()->IsPrivilegeIncrease( | 1771 EXPECT_FALSE(PermissionMessageProvider::Get()->IsPrivilegeIncrease( |
| 1771 permissions, permissions_dwr, extension->GetType())); | 1772 permissions, permissions_dwr, extension->GetType())); |
| 1772 } | 1773 } |
| 1773 | 1774 |
| 1774 } // namespace extensions | 1775 } // namespace extensions |
| OLD | NEW |