diff options
author | treib <treib@chromium.org> | 2015-04-27 02:30:46 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-27 09:30:46 +0000 |
commit | f94fcdc47b9f0c1db393ea6b276e6af3a9d4587d (patch) | |
tree | bcfe1153cd10586fd7ad834f9bdb56eb451bbf0f | |
parent | d5197b41fa82539ccdad9d8698658b808a877d71 (diff) | |
download | chromium_src-f94fcdc47b9f0c1db393ea6b276e6af3a9d4587d.zip chromium_src-f94fcdc47b9f0c1db393ea6b276e6af3a9d4587d.tar.gz chromium_src-f94fcdc47b9f0c1db393ea6b276e6af3a9d4587d.tar.bz2 |
Extensions: Switch to new permission message system, part IV
Flip the Switch!
Also, re-order a rule in the new system to fix a test.
Also, cleanup the test.
BUG=398257,478634
Review URL: https://codereview.chromium.org/1106613005
Cr-Commit-Position: refs/heads/master@{#327020}
3 files changed, 21 insertions, 25 deletions
diff --git a/chrome/common/extensions/permissions/chrome_permission_message_rules.cc b/chrome/common/extensions/permissions/chrome_permission_message_rules.cc index f5eca76..1f2ffae 100644 --- a/chrome/common/extensions/permissions/chrome_permission_message_rules.cc +++ b/chrome/common/extensions/permissions/chrome_permission_message_rules.cc @@ -320,10 +320,6 @@ ChromePermissionMessageRule::GetAllRules() { APIPermission::kAccessibilityFeaturesRead}, {}}, - {IDS_EXTENSION_PROMPT_WARNING_AUDIO_AND_VIDEO_CAPTURE, - {APIPermission::kAudioCapture, APIPermission::kVideoCapture}, - {}}, - // TODO(sashab): Add the missing combinations of media galleries // permissions so a valid permission is generated for all combinations. {IDS_EXTENSION_PROMPT_WARNING_MEDIA_GALLERIES_READ_WRITE_DELETE, @@ -544,6 +540,10 @@ ChromePermissionMessageRule::GetAllRules() { {APIPermission::kStartupPages}, {}}, + {IDS_EXTENSION_PROMPT_WARNING_AUDIO_AND_VIDEO_CAPTURE, + {APIPermission::kAudioCapture, APIPermission::kVideoCapture}, + {}}, + // Individual message rules taken from // ExtensionsAPIPermissions::GetAllPermissions(): {IDS_EXTENSION_PROMPT_WARNING_AUDIO_CAPTURE, diff --git a/chrome/common/extensions/permissions/permission_set_unittest.cc b/chrome/common/extensions/permissions/permission_set_unittest.cc index f212652..7d8d748 100644 --- a/chrome/common/extensions/permissions/permission_set_unittest.cc +++ b/chrome/common/extensions/permissions/permission_set_unittest.cc @@ -1139,46 +1139,42 @@ TEST(PermissionsTest, GetWarningMessages_Plugins) { } TEST(PermissionsTest, GetWarningMessages_AudioVideo) { + const std::string kAudio("Use your microphone"); + const std::string kVideo("Use your camera"); + const std::string kBoth("Use your microphone and camera"); + // Both audio and video present. scoped_refptr<Extension> extension = LoadManifest("permissions", "audio-video.json"); const PermissionMessageProvider* provider = PermissionMessageProvider::Get(); PermissionSet* set = const_cast<PermissionSet*>( extension->permissions_data()->active_permissions().get()); - EXPECT_FALSE(VerifyHasPermissionMessage(set, extension->GetType(), - "Use your microphone")); - EXPECT_FALSE( - VerifyHasPermissionMessage(set, extension->GetType(), "Use your camera")); - EXPECT_TRUE(VerifyHasPermissionMessage(set, extension->GetType(), - "Use your microphone and camera")); + EXPECT_FALSE(VerifyHasPermissionMessage(set, extension->GetType(), kAudio)); + EXPECT_FALSE(VerifyHasPermissionMessage(set, extension->GetType(), kVideo)); + EXPECT_TRUE(VerifyHasPermissionMessage(set, extension->GetType(), kBoth)); PermissionMessageStrings warnings = provider->GetPermissionMessageStrings(set, extension->GetType()); - size_t combined_index = IndexOf(warnings, "Use your microphone and camera"); + size_t combined_index = IndexOf(warnings, kBoth); size_t combined_size = warnings.size(); // Just audio present. set->apis_.erase(APIPermission::kVideoCapture); - EXPECT_TRUE(VerifyHasPermissionMessage(set, extension->GetType(), - "Use your microphone")); - EXPECT_FALSE( - VerifyHasPermissionMessage(set, extension->GetType(), "Use your camera")); - EXPECT_FALSE(VerifyHasPermissionMessage(set, extension->GetType(), - "Use your microphone and camera")); + EXPECT_TRUE(VerifyHasPermissionMessage(set, extension->GetType(), kAudio)); + EXPECT_FALSE(VerifyHasPermissionMessage(set, extension->GetType(), kVideo)); + EXPECT_FALSE(VerifyHasPermissionMessage(set, extension->GetType(), kBoth)); warnings = provider->GetPermissionMessageStrings(set, extension->GetType()); EXPECT_EQ(combined_size, warnings.size()); - EXPECT_EQ(combined_index, IndexOf(warnings, "Use your microphone")); + EXPECT_EQ(combined_index, IndexOf(warnings, kAudio)); // Just video present. set->apis_.erase(APIPermission::kAudioCapture); set->apis_.insert(APIPermission::kVideoCapture); - EXPECT_FALSE(VerifyHasPermissionMessage(set, extension->GetType(), - "Use your microphone")); - EXPECT_TRUE( - VerifyHasPermissionMessage(set, extension->GetType(), "Use your camera")); - EXPECT_FALSE(VerifyHasPermissionMessage(set, extension->GetType(), - "Use your microphone and camera")); + EXPECT_FALSE(VerifyHasPermissionMessage(set, extension->GetType(), kAudio)); + EXPECT_TRUE(VerifyHasPermissionMessage(set, extension->GetType(), kVideo)); + EXPECT_FALSE(VerifyHasPermissionMessage(set, extension->GetType(), kBoth)); warnings = provider->GetPermissionMessageStrings(set, extension->GetType()); EXPECT_EQ(combined_size, warnings.size()); + EXPECT_EQ(combined_index, IndexOf(warnings, kVideo)); } TEST(PermissionsTest, GetWarningMessages_CombinedSessions) { diff --git a/extensions/common/permissions/permission_message_provider.cc b/extensions/common/permissions/permission_message_provider.cc index f194340..d4c3025 100644 --- a/extensions/common/permissions/permission_message_provider.cc +++ b/extensions/common/permissions/permission_message_provider.cc @@ -20,7 +20,7 @@ bool IsNewPermissionMessageSystemEnabled() { return g_force_permission_system_for_testing == ForceForTesting::FORCE_NEW; const std::string group_name = base::FieldTrialList::FindFullName("PermissionMessageSystem"); - return group_name == "NewSystem"; + return group_name != "OldSystem"; } } // namespace |