diff options
author | xians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-16 18:08:24 +0000 |
---|---|---|
committer | xians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-16 18:08:24 +0000 |
commit | f1f24ae4ff87c70f1988ea6edd8bf01f292b82db (patch) | |
tree | 155337ab5dd51610ad7dfcbd5c0a9a9f896540dc /chrome/browser | |
parent | d92b23227d0f956bb932815f1dfdd07ac76c361d (diff) | |
download | chromium_src-f1f24ae4ff87c70f1988ea6edd8bf01f292b82db.zip chromium_src-f1f24ae4ff87c70f1988ea6edd8bf01f292b82db.tar.gz chromium_src-f1f24ae4ff87c70f1988ea6edd8bf01f292b82db.tar.bz2 |
Revert: Per navigation sticky media permissions.
This CL re-enables the same behavior for getUserMedia prompts as it was in M35.
The reason for this is because there was a change of hearts at the standards level about this.
More information in the issue.
BUG=269719
TEST=bots
Review URL: https://codereview.chromium.org/332193002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277491 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
3 files changed, 2 insertions, 176 deletions
diff --git a/chrome/browser/media/chrome_media_stream_infobar_browsertest.cc b/chrome/browser/media/chrome_media_stream_infobar_browsertest.cc index 07c4f0b..4c9dd5f09 100644 --- a/chrome/browser/media/chrome_media_stream_infobar_browsertest.cc +++ b/chrome/browser/media/chrome_media_stream_infobar_browsertest.cc @@ -152,7 +152,7 @@ IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, content::WebContents* tab_contents = LoadTestPageInTab(); GetUserMediaAndAccept(tab_contents); - DenyRequest(tab_contents, content::MEDIA_DEVICE_PERMISSION_DENIED); + GetUserMediaAndDeny(tab_contents); // Should fail with permission denied right away with no infobar popping up. GetUserMedia(tab_contents, kAudioVideoCallConstraints); @@ -177,58 +177,9 @@ IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, MAYBE_TestAcceptIsNotSticky) { // If accept were sticky the second call would hang because it hangs if an // infobar does not pop up. GetUserMediaAndAccept(tab_contents); - - // Because http request permissions are sticky per navigation, we need to - // navigate away from the current page in order to verify that the granted - // permissions are not permanently sticky. - ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), - GURL("about:blank"), 1); - - // Now navigate back to our test page. - ui_test_utils::NavigateToURL(browser(), test_page_url()); - tab_contents = browser()->tab_strip_model()->GetActiveWebContents(); - GetUserMediaAndAccept(tab_contents); } -// Test that accepting one getUserMedia request will not require a second -// prompt when issuing a second getUserMedia request. -IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, - TestAcceptIsStickyPerNavigation) { - content::WebContents* tab_contents = LoadTestPageInTab(); - - GetUserMediaAndAccept(tab_contents); - - // Before issuing the second gUM request, make sure we first stop the tracks - // we started with the first request. If they're still running the permissions - // will be active for other reasons and we won't be testing the temporary - // stickiness properly. - EXPECT_TRUE(StopLocalStream(tab_contents)); - - // Now no media tracks are running, so let's issue the second request. - GetUserMedia(tab_contents, kAudioVideoCallConstraints); -} - -IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, - TestTwoAcceptsPlusStickyPerNavigation) { - content::WebContents* tab_contents = LoadTestPageInTab(); - - // First ask for audio only and approve. - GetUserMediaWithSpecificConstraintsAndAccept(tab_contents, - kAudioOnlyCallConstraints); - EXPECT_TRUE(StopLocalStream(tab_contents)); - - // Next ask for video permissions. - // This will hang if the previous gUM call somehow gave video permissions. - GetUserMediaWithSpecificConstraintsAndAccept(tab_contents, - kVideoOnlyCallConstraints); - EXPECT_TRUE(StopLocalStream(tab_contents)); - - // Now ask for both audio and video and expect the call to go through without - // showing any UI. - GetUserMedia(tab_contents, kAudioVideoCallConstraints); -} - IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestDismissIsNotSticky) { content::WebContents* tab_contents = LoadTestPageInTab(); diff --git a/chrome/browser/media/chrome_webrtc_webcam_browsertest.cc b/chrome/browser/media/chrome_webrtc_webcam_browsertest.cc index 483715a..2212a93 100644 --- a/chrome/browser/media/chrome_webrtc_webcam_browsertest.cc +++ b/chrome/browser/media/chrome_webrtc_webcam_browsertest.cc @@ -39,8 +39,6 @@ static const char* kTestConfigFlags[] = { class WebRtcWebcamBrowserTest : public WebRtcTestBase, public testing::WithParamInterface<const char*> { public: - WebRtcWebcamBrowserTest() : get_user_media_call_count_(0) {} - virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { EXPECT_FALSE(command_line->HasSwitch( switches::kUseFakeDeviceForMediaStream)); @@ -57,17 +55,7 @@ class WebRtcWebcamBrowserTest : public WebRtcTestBase, std::string GetUserMediaAndGetStreamSize(content::WebContents* tab, const std::string& constraints) { - // We will get a permission prompt for the first getUserMedia call. - // Subsequent calls won't trigger a prompt. - if (get_user_media_call_count_ == 0) { - GetUserMediaWithSpecificConstraintsAndAccept(tab, constraints); - } else { - GetUserMedia(tab, constraints); - EXPECT_TRUE(test::PollingWaitUntil( - "obtainGetUserMediaResult()", "ok-got-stream", tab)); - } - - ++get_user_media_call_count_; + GetUserMediaWithSpecificConstraintsAndAccept(tab, constraints); StartDetectingVideo(tab, "local-view"); WaitForVideoToPlay(tab); @@ -83,8 +71,6 @@ class WebRtcWebcamBrowserTest : public WebRtcTestBase, return false; #endif } - - int get_user_media_call_count_; }; IN_PROC_BROWSER_TEST_P(WebRtcWebcamBrowserTest, diff --git a/chrome/browser/media/media_stream_devices_controller.cc b/chrome/browser/media/media_stream_devices_controller.cc index 56e73b9..3cb55cc 100644 --- a/chrome/browser/media/media_stream_devices_controller.cc +++ b/chrome/browser/media/media_stream_devices_controller.cc @@ -23,7 +23,6 @@ #include "chrome/common/pref_names.h" #include "components/pref_registry/pref_registry_syncable.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/navigation_entry.h" #include "content/public/common/media_stream_request.h" #include "extensions/common/constants.h" #include "grit/generated_resources.h" @@ -38,15 +37,6 @@ using content::BrowserThread; namespace { -// This prefix is combined with request security origins to store media access -// permissions that the user has granted a specific page navigation instance. -// The string value stored with the navigation instance will contain one or more -// kMediaPermissionXxx constants that indicates the permission(s) that the user -// has granted the page. -const char kMediaPermissionKeyPrefix[] = "media_permissions#"; -const base::char16 kMediaPermissionAudio = static_cast<base::char16>('a'); -const base::char16 kMediaPermissionVideo = static_cast<base::char16>('v'); - bool HasAvailableDevicesForRequest(const content::MediaStreamRequest& request) { const content::MediaStreamDevices* audio_devices = request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE ? @@ -90,75 +80,6 @@ bool HasAvailableDevicesForRequest(const content::MediaStreamRequest& request) { return true; } -base::string16 GetMediaPermissionsFromNavigationEntry( - content::NavigationEntry* navigation_entry, - const content::MediaStreamRequest& request) { - const std::string key(kMediaPermissionKeyPrefix + - request.security_origin.spec()); - - base::string16 permissions; - if (!navigation_entry->GetExtraData(key, &permissions)) { - DCHECK(permissions.empty()); - } - - return permissions; -} - -void SetMediaPermissionsForNavigationEntry( - content::NavigationEntry* navigation_entry, - const content::MediaStreamRequest& request, - const base::string16& permissions) { - const std::string key(kMediaPermissionKeyPrefix + - request.security_origin.spec()); - permissions.empty() ? - navigation_entry->ClearExtraData(key) : - navigation_entry->SetExtraData(key, permissions); -} - -void SetMediaPermissionsForNavigationEntry( - content::NavigationEntry* navigation_entry, - const content::MediaStreamRequest& request, - bool allow_audio, - bool allow_video) { - base::string16 permissions; - if (allow_audio) - permissions += kMediaPermissionAudio; - if (allow_video) - permissions += kMediaPermissionVideo; - SetMediaPermissionsForNavigationEntry(navigation_entry, request, permissions); -} - -bool IsRequestAllowedByNavigationEntry( - content::NavigationEntry* navigation_entry, - const content::MediaStreamRequest& request) { - using content::MEDIA_NO_SERVICE; - using content::MEDIA_DEVICE_AUDIO_CAPTURE; - using content::MEDIA_DEVICE_VIDEO_CAPTURE; - - // If we aren't being asked for at least one of these two, fail right away. - if (!navigation_entry || - (request.audio_type != MEDIA_DEVICE_AUDIO_CAPTURE && - request.video_type != MEDIA_DEVICE_VIDEO_CAPTURE)) { - return false; - } - - base::string16 permissions = - GetMediaPermissionsFromNavigationEntry(navigation_entry, request); - - bool audio_requested_and_granted = - request.audio_type == MEDIA_DEVICE_AUDIO_CAPTURE && - permissions.find(kMediaPermissionAudio) != base::string16::npos; - - bool video_requested_and_granted = - request.video_type == MEDIA_DEVICE_VIDEO_CAPTURE && - permissions.find(kMediaPermissionVideo) != base::string16::npos; - - return - (audio_requested_and_granted || request.audio_type == MEDIA_NO_SERVICE) && - (video_requested_and_granted || request.video_type == MEDIA_NO_SERVICE); -} - - bool IsInKioskMode() { if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) return true; @@ -309,18 +230,6 @@ bool MediaStreamDevicesController::DismissInfoBarAndTakeActionOnSettings() { return true; } - // Check if the navigation entry has previously been granted access. - // We do this after the IsDefaultMediaAccessBlocked check to handle the use - // case where the user modifies the content settings to 'deny' after having - // previously granted the page access and the permissions in the - // NavigationEntry are out of date. - content::NavigationEntry* navigation_entry = - web_contents_->GetController().GetVisibleEntry(); - if (IsRequestAllowedByNavigationEntry(navigation_entry, request_)) { - Accept(false); - return true; - } - // Show the infobar. return false; } @@ -409,18 +318,6 @@ void MediaStreamDevicesController::Accept(bool update_content_setting) { get_default_video_device, &devices); } - - // For pages accessed via http (not https), tag this navigation entry - // with the granted permissions. This avoids repeated prompts for - // device access. - if (!IsSchemeSecure()) { - content::NavigationEntry* navigation_entry = - web_contents_->GetController().GetVisibleEntry(); - if (navigation_entry) { - SetMediaPermissionsForNavigationEntry( - navigation_entry, request_, audio_allowed, video_allowed); - } - } break; } case content::MEDIA_DEVICE_ACCESS: { @@ -470,14 +367,6 @@ void MediaStreamDevicesController::Deny( DLOG(WARNING) << "MediaStreamDevicesController::Deny: " << result; NotifyUIRequestDenied(); - // Clear previously allowed permissions from the navigation entry if any. - content::NavigationEntry* navigation_entry = - web_contents_->GetController().GetVisibleEntry(); - if (navigation_entry) { - SetMediaPermissionsForNavigationEntry( - navigation_entry, request_, false, false); - } - if (update_content_setting) { CHECK_EQ(content::MEDIA_DEVICE_PERMISSION_DENIED, result); SetPermission(false); |