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

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

Issue 323633003: Change tabs + sessions permission warning (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/extensions/permissions/chrome_permission_message_provider.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 // Just video present. 968 // Just video present.
969 set->apis_.erase(APIPermission::kAudioCapture); 969 set->apis_.erase(APIPermission::kAudioCapture);
970 set->apis_.insert(APIPermission::kVideoCapture); 970 set->apis_.insert(APIPermission::kVideoCapture);
971 warnings = provider->GetWarningMessages(set, extension->GetType()); 971 warnings = provider->GetWarningMessages(set, extension->GetType());
972 EXPECT_EQ(combined_size, warnings.size()); 972 EXPECT_EQ(combined_size, warnings.size());
973 EXPECT_FALSE(Contains(warnings, "Use your microphone")); 973 EXPECT_FALSE(Contains(warnings, "Use your microphone"));
974 EXPECT_FALSE(Contains(warnings, "Use your microphone and camera")); 974 EXPECT_FALSE(Contains(warnings, "Use your microphone and camera"));
975 EXPECT_TRUE(Contains(warnings, "Use your camera")); 975 EXPECT_TRUE(Contains(warnings, "Use your camera"));
976 } 976 }
977 977
978 TEST(PermissionsTest, GetWarningMessages_CombinedSessions) {
979 {
980 APIPermissionSet api_permissions;
981 api_permissions.insert(APIPermission::kTab);
982 api_permissions.insert(APIPermission::kSessions);
983 scoped_refptr<PermissionSet> permissions(
984 new PermissionSet(api_permissions, ManifestPermissionSet(),
985 URLPatternSet(), URLPatternSet()));
986 std::vector<base::string16> messages =
987 PermissionMessageProvider::Get()->GetWarningMessages(
988 permissions, Manifest::TYPE_EXTENSION);
989 EXPECT_EQ(1u, messages.size());
990 EXPECT_EQ(l10n_util::GetStringUTF16(
991 IDS_EXTENSION_PROMPT_WARNING_TABS_AND_SESSIONS),
992 messages[0]);
993 }
994 {
995 APIPermissionSet api_permissions;
996 api_permissions.insert(APIPermission::kHistory);
997 api_permissions.insert(APIPermission::kSessions);
998 scoped_refptr<PermissionSet> permissions(
999 new PermissionSet(api_permissions, ManifestPermissionSet(),
1000 URLPatternSet(), URLPatternSet()));
1001 std::vector<base::string16> messages =
1002 PermissionMessageProvider::Get()->GetWarningMessages(
1003 permissions, Manifest::TYPE_EXTENSION);
1004 EXPECT_EQ(1u, messages.size());
1005 EXPECT_EQ(l10n_util::GetStringUTF16(
1006 IDS_EXTENSION_PROMPT_WARNING_BROWSING_HISTORY_AND_SESSIONS),
1007 messages[0]);
1008 }
1009 {
1010 APIPermissionSet api_permissions;
1011 api_permissions.insert(APIPermission::kTab);
1012 api_permissions.insert(APIPermission::kHistory);
1013 api_permissions.insert(APIPermission::kSessions);
1014 scoped_refptr<PermissionSet> permissions(
1015 new PermissionSet(api_permissions, ManifestPermissionSet(),
1016 URLPatternSet(), URLPatternSet()));
1017 std::vector<base::string16> messages =
1018 PermissionMessageProvider::Get()->GetWarningMessages(
1019 permissions, Manifest::TYPE_EXTENSION);
1020 EXPECT_EQ(1u, messages.size());
1021 EXPECT_EQ(l10n_util::GetStringUTF16(
1022 IDS_EXTENSION_PROMPT_WARNING_BROWSING_HISTORY_AND_SESSIONS),
1023 messages[0]);
1024 }
1025 }
1026
978 TEST(PermissionsTest, GetWarningMessages_DeclarativeWebRequest) { 1027 TEST(PermissionsTest, GetWarningMessages_DeclarativeWebRequest) {
979 // Test that if the declarativeWebRequest permission is present 1028 // Test that if the declarativeWebRequest permission is present
980 // in combination with all hosts permission, then only the warning 1029 // in combination with all hosts permission, then only the warning
981 // for host permissions is shown, because that covers the use of 1030 // for host permissions is shown, because that covers the use of
982 // declarativeWebRequest. 1031 // declarativeWebRequest.
983 1032
984 // Until Declarative Web Request is in stable, let's make sure it is enabled 1033 // Until Declarative Web Request is in stable, let's make sure it is enabled
985 // on the current channel. 1034 // on the current channel.
986 ScopedCurrentChannel sc(chrome::VersionInfo::CHANNEL_CANARY); 1035 ScopedCurrentChannel sc(chrome::VersionInfo::CHANNEL_CANARY);
987 1036
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 scoped_refptr<const PermissionSet> permissions_dwr( 1634 scoped_refptr<const PermissionSet> permissions_dwr(
1586 extension_dwr->permissions_data()->active_permissions()); 1635 extension_dwr->permissions_data()->active_permissions());
1587 1636
1588 EXPECT_FALSE(PermissionMessageProvider::Get()-> 1637 EXPECT_FALSE(PermissionMessageProvider::Get()->
1589 IsPrivilegeIncrease(permissions.get(), 1638 IsPrivilegeIncrease(permissions.get(),
1590 permissions_dwr.get(), 1639 permissions_dwr.get(),
1591 extension->GetType())); 1640 extension->GetType()));
1592 } 1641 }
1593 1642
1594 } // namespace extensions 1643 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/permissions/chrome_permission_message_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698