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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/json/json_file_value_serializer.h" | 6 #include "base/json/json_file_value_serializer.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 // Just video present. | 967 // Just video present. |
968 set->apis_.erase(APIPermission::kAudioCapture); | 968 set->apis_.erase(APIPermission::kAudioCapture); |
969 set->apis_.insert(APIPermission::kVideoCapture); | 969 set->apis_.insert(APIPermission::kVideoCapture); |
970 warnings = provider->GetWarningMessages(set, extension->GetType()); | 970 warnings = provider->GetWarningMessages(set, extension->GetType()); |
971 EXPECT_EQ(combined_size, warnings.size()); | 971 EXPECT_EQ(combined_size, warnings.size()); |
972 EXPECT_FALSE(Contains(warnings, "Use your microphone")); | 972 EXPECT_FALSE(Contains(warnings, "Use your microphone")); |
973 EXPECT_FALSE(Contains(warnings, "Use your microphone and camera")); | 973 EXPECT_FALSE(Contains(warnings, "Use your microphone and camera")); |
974 EXPECT_TRUE(Contains(warnings, "Use your camera")); | 974 EXPECT_TRUE(Contains(warnings, "Use your camera")); |
975 } | 975 } |
976 | 976 |
| 977 TEST(PermissionsTest, GetWarningMessages_CombinedSessions) { |
| 978 { |
| 979 APIPermissionSet api_permissions; |
| 980 api_permissions.insert(APIPermission::kTab); |
| 981 api_permissions.insert(APIPermission::kSessions); |
| 982 scoped_refptr<PermissionSet> permissions( |
| 983 new PermissionSet(api_permissions, ManifestPermissionSet(), |
| 984 URLPatternSet(), URLPatternSet())); |
| 985 std::vector<base::string16> messages = |
| 986 PermissionMessageProvider::Get()->GetWarningMessages( |
| 987 permissions, Manifest::TYPE_EXTENSION); |
| 988 EXPECT_EQ(1u, messages.size()); |
| 989 EXPECT_EQ(l10n_util::GetStringUTF16( |
| 990 IDS_EXTENSION_PROMPT_WARNING_TABS_AND_SESSIONS), |
| 991 messages[0]); |
| 992 } |
| 993 { |
| 994 APIPermissionSet api_permissions; |
| 995 api_permissions.insert(APIPermission::kHistory); |
| 996 api_permissions.insert(APIPermission::kSessions); |
| 997 scoped_refptr<PermissionSet> permissions( |
| 998 new PermissionSet(api_permissions, ManifestPermissionSet(), |
| 999 URLPatternSet(), URLPatternSet())); |
| 1000 std::vector<base::string16> messages = |
| 1001 PermissionMessageProvider::Get()->GetWarningMessages( |
| 1002 permissions, Manifest::TYPE_EXTENSION); |
| 1003 EXPECT_EQ(1u, messages.size()); |
| 1004 EXPECT_EQ(l10n_util::GetStringUTF16( |
| 1005 IDS_EXTENSION_PROMPT_WARNING_BROWSING_HISTORY_AND_SESSIONS), |
| 1006 messages[0]); |
| 1007 } |
| 1008 { |
| 1009 APIPermissionSet api_permissions; |
| 1010 api_permissions.insert(APIPermission::kTab); |
| 1011 api_permissions.insert(APIPermission::kHistory); |
| 1012 api_permissions.insert(APIPermission::kSessions); |
| 1013 scoped_refptr<PermissionSet> permissions( |
| 1014 new PermissionSet(api_permissions, ManifestPermissionSet(), |
| 1015 URLPatternSet(), URLPatternSet())); |
| 1016 std::vector<base::string16> messages = |
| 1017 PermissionMessageProvider::Get()->GetWarningMessages( |
| 1018 permissions, Manifest::TYPE_EXTENSION); |
| 1019 EXPECT_EQ(1u, messages.size()); |
| 1020 EXPECT_EQ(l10n_util::GetStringUTF16( |
| 1021 IDS_EXTENSION_PROMPT_WARNING_BROWSING_HISTORY_AND_SESSIONS), |
| 1022 messages[0]); |
| 1023 } |
| 1024 } |
| 1025 |
977 TEST(PermissionsTest, GetWarningMessages_DeclarativeWebRequest) { | 1026 TEST(PermissionsTest, GetWarningMessages_DeclarativeWebRequest) { |
978 // Test that if the declarativeWebRequest permission is present | 1027 // Test that if the declarativeWebRequest permission is present |
979 // in combination with all hosts permission, then only the warning | 1028 // in combination with all hosts permission, then only the warning |
980 // for host permissions is shown, because that covers the use of | 1029 // for host permissions is shown, because that covers the use of |
981 // declarativeWebRequest. | 1030 // declarativeWebRequest. |
982 | 1031 |
983 // Until Declarative Web Request is in stable, let's make sure it is enabled | 1032 // Until Declarative Web Request is in stable, let's make sure it is enabled |
984 // on the current channel. | 1033 // on the current channel. |
985 ScopedCurrentChannel sc(chrome::VersionInfo::CHANNEL_CANARY); | 1034 ScopedCurrentChannel sc(chrome::VersionInfo::CHANNEL_CANARY); |
986 | 1035 |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1578 scoped_refptr<const PermissionSet> permissions_dwr( | 1627 scoped_refptr<const PermissionSet> permissions_dwr( |
1579 extension_dwr->GetActivePermissions()); | 1628 extension_dwr->GetActivePermissions()); |
1580 | 1629 |
1581 EXPECT_FALSE(PermissionMessageProvider::Get()-> | 1630 EXPECT_FALSE(PermissionMessageProvider::Get()-> |
1582 IsPrivilegeIncrease(permissions.get(), | 1631 IsPrivilegeIncrease(permissions.get(), |
1583 permissions_dwr.get(), | 1632 permissions_dwr.get(), |
1584 extension->GetType())); | 1633 extension->GetType())); |
1585 } | 1634 } |
1586 | 1635 |
1587 } // namespace extensions | 1636 } // namespace extensions |
OLD | NEW |