| Index: chrome/browser/media/webrtc/media_stream_devices_controller_browsertest.cc | 
| diff --git a/chrome/browser/media/webrtc/media_stream_devices_controller_browsertest.cc b/chrome/browser/media/webrtc/media_stream_devices_controller_browsertest.cc | 
| index 19d44472321bff4fa15679ba9141ed6de6b1cfa5..6900dba6da5ca31faf0fa8add3bf1dc44f72ed98 100644 | 
| --- a/chrome/browser/media/webrtc/media_stream_devices_controller_browsertest.cc | 
| +++ b/chrome/browser/media/webrtc/media_stream_devices_controller_browsertest.cc | 
| @@ -5,7 +5,10 @@ | 
| #include <string> | 
|  | 
| #include "base/bind.h" | 
| +#include "base/callback.h" | 
| #include "base/metrics/field_trial.h" | 
| +#include "base/run_loop.h" | 
| +#include "base/test/scoped_feature_list.h" | 
| #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 
| #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 
| #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" | 
| @@ -14,11 +17,14 @@ | 
| #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" | 
| #include "chrome/browser/media/webrtc/webrtc_browsertest_base.h" | 
| #include "chrome/browser/permissions/permission_context_base.h" | 
| +#include "chrome/browser/permissions/permission_request.h" | 
| #include "chrome/browser/permissions/permission_request_manager.h" | 
| #include "chrome/browser/permissions/permission_util.h" | 
| #include "chrome/browser/profiles/profile.h" | 
| #include "chrome/browser/ui/browser.h" | 
| +#include "chrome/browser/ui/permission_bubble/mock_permission_prompt_factory.h" | 
| #include "chrome/browser/ui/tabs/tab_strip_model.h" | 
| +#include "chrome/common/chrome_features.h" | 
| #include "chrome/common/pref_names.h" | 
| #include "chrome/test/base/ui_test_utils.h" | 
| #include "components/content_settings/core/browser/host_content_settings_map.h" | 
| @@ -29,7 +35,14 @@ | 
| #include "content/public/test/mock_render_process_host.h" | 
| #include "testing/gtest/include/gtest/gtest.h" | 
|  | 
| -class MediaStreamDevicesControllerTest : public WebRtcTestBase { | 
| +enum class TestType { | 
| +  DEFAULT, | 
| +  TEST_WITH_GROUPED_MEDIA_REQUESTS, | 
| +}; | 
| + | 
| +class MediaStreamDevicesControllerTest | 
| +    : public WebRtcTestBase, | 
| +      public ::testing::WithParamInterface<TestType> { | 
| public: | 
| // TODO(raymes): When crbug.com/606138 is finished and the | 
| // PermissionRequestManager is used to show all prompts on Android/Desktop | 
| @@ -84,6 +97,8 @@ class MediaStreamDevicesControllerTest : public WebRtcTestBase { | 
| std::unique_ptr<content::MediaStreamUI> ui) { | 
| media_stream_devices_ = devices; | 
| media_stream_result_ = result; | 
| +    quit_closure_.Run(); | 
| +    quit_closure_ = base::Closure(); | 
| } | 
|  | 
| protected: | 
| @@ -106,12 +121,14 @@ class MediaStreamDevicesControllerTest : public WebRtcTestBase { | 
| void RequestPermissions(content::WebContents* web_contents, | 
| const content::MediaStreamRequest& request, | 
| const content::MediaResponseCallback& callback) { | 
| +    base::RunLoop run_loop; | 
| +    ASSERT_TRUE(quit_closure_.is_null()); | 
| +    quit_closure_ = run_loop.QuitClosure(); | 
| MediaStreamDevicesController::RequestPermissionsWithDelegate( | 
| request, callback, &prompt_delegate_); | 
| +    run_loop.Run(); | 
| } | 
|  | 
| -  TestPermissionPromptDelegate* prompt_delegate() { return &prompt_delegate_; } | 
| - | 
| // Sets the device policy-controlled |access| for |example_url_| to be for the | 
| // selected |device_type|. | 
| void SetDevicePolicy(DeviceType device_type, Access access) { | 
| @@ -193,10 +210,67 @@ class MediaStreamDevicesControllerTest : public WebRtcTestBase { | 
| GetContentSettings()->GetMicrophoneCameraState()); | 
| } | 
|  | 
| +  void SetPromptResponseType( | 
| +      PermissionRequestManager::AutoResponseType response_type) { | 
| +    if (base::FeatureList::IsEnabled( | 
| +            features::kUsePermissionManagerForMediaRequests)) { | 
| +      prompt_factory_->set_response_type(response_type); | 
| +    } else { | 
| +      prompt_delegate_.set_response_type(response_type); | 
| +    } | 
| +  } | 
| + | 
| +  size_t TotalPromptRequestCount() { | 
| +    if (base::FeatureList::IsEnabled( | 
| +            features::kUsePermissionManagerForMediaRequests)) { | 
| +      return prompt_factory_->TotalRequestCount(); | 
| +    } else { | 
| +      return prompt_delegate_.TotalRequestCount(); | 
| +    } | 
| +  } | 
| + | 
| +  bool WasPermissionShown(ContentSettingsType type) { | 
| +    if (base::FeatureList::IsEnabled( | 
| +            features::kUsePermissionManagerForMediaRequests)) { | 
| +      if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { | 
| +        return prompt_factory_->RequestTypeSeen( | 
| +            PermissionRequestType::PERMISSION_MEDIASTREAM_MIC); | 
| +      } else if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { | 
| +        return prompt_factory_->RequestTypeSeen( | 
| +            PermissionRequestType::PERMISSION_MEDIASTREAM_CAMERA); | 
| +      } else { | 
| +        NOTREACHED(); | 
| +        return false; | 
| +      } | 
| +    } else { | 
| +      return prompt_delegate_.WasRequested(type); | 
| +    } | 
| +  } | 
| + | 
| +  void ResetPromptCounters() { | 
| +    if (base::FeatureList::IsEnabled( | 
| +            features::kUsePermissionManagerForMediaRequests)) { | 
| +      prompt_factory_->ResetCounts(); | 
| +    } else { | 
| +      prompt_delegate_.Reset(); | 
| +    } | 
| +  } | 
| + | 
| private: | 
| void SetUpOnMainThread() override { | 
| WebRtcTestBase::SetUpOnMainThread(); | 
|  | 
| +    if (static_cast<TestType>(GetParam()) == | 
| +        TestType::TEST_WITH_GROUPED_MEDIA_REQUESTS) { | 
| +      scoped_feature_list_.InitAndEnableFeature( | 
| +          features::kUsePermissionManagerForMediaRequests); | 
| +      PermissionRequestManager* manager = | 
| +          PermissionRequestManager::FromWebContents( | 
| +              browser()->tab_strip_model()->GetActiveWebContents()); | 
| +      prompt_factory_.reset(new MockPermissionPromptFactory(manager)); | 
| +      manager->DisplayPendingRequests(); | 
| +    } | 
| + | 
| // Cleanup. | 
| media_stream_devices_.clear(); | 
| media_stream_result_ = content::NUM_MEDIA_REQUEST_RESULTS; | 
| @@ -218,6 +292,12 @@ class MediaStreamDevicesControllerTest : public WebRtcTestBase { | 
| video_devices); | 
| } | 
|  | 
| +  void TearDownOnMainThread() override { | 
| +    prompt_factory_.reset(); | 
| + | 
| +    WebRtcTestBase::TearDownOnMainThread(); | 
| +  } | 
| + | 
| GURL example_url_; | 
| const std::string example_audio_id_; | 
| const std::string example_video_id_; | 
| @@ -225,16 +305,21 @@ class MediaStreamDevicesControllerTest : public WebRtcTestBase { | 
| content::MediaStreamDevices media_stream_devices_; | 
| content::MediaStreamRequestResult media_stream_result_; | 
|  | 
| +  base::Closure quit_closure_; | 
| + | 
| TestPermissionPromptDelegate prompt_delegate_; | 
| +  std::unique_ptr<MockPermissionPromptFactory> prompt_factory_; | 
| + | 
| +  base::test::ScopedFeatureList scoped_feature_list_; | 
| }; | 
|  | 
| // Request and allow microphone access. | 
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, RequestAndAllowMic) { | 
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, RequestAndAllowMic) { | 
| InitWithUrl(GURL("https://www.example.com")); | 
| SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_ALLOWED); | 
| // Ensure the prompt is accepted if necessary such that tab specific content | 
| // settings are updated. | 
| -  prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 
| +  SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); | 
| RequestPermissions( | 
| GetWebContents(), CreateRequest(example_audio_id(), std::string()), | 
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 
| @@ -257,12 +342,12 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, RequestAndAllowMic) { | 
| } | 
|  | 
| // Request and allow camera access. | 
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, RequestAndAllowCam) { | 
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, RequestAndAllowCam) { | 
| InitWithUrl(GURL("https://www.example.com")); | 
| SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_ALLOWED); | 
| // Ensure the prompt is accepted if necessary such that tab specific content | 
| // settings are updated. | 
| -  prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 
| +  SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); | 
| RequestPermissions( | 
| GetWebContents(), CreateRequest(std::string(), example_video_id()), | 
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 
| @@ -285,12 +370,12 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, RequestAndAllowCam) { | 
| } | 
|  | 
| // Request and block microphone access. | 
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, RequestAndBlockMic) { | 
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, RequestAndBlockMic) { | 
| InitWithUrl(GURL("https://www.example.com")); | 
| SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_DENIED); | 
| // Ensure the prompt is accepted if necessary such that tab specific content | 
| // settings are updated. | 
| -  prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 
| +  SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); | 
| RequestPermissions( | 
| GetWebContents(), CreateRequest(example_audio_id(), std::string()), | 
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 
| @@ -314,12 +399,12 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, RequestAndBlockMic) { | 
| } | 
|  | 
| // Request and block camera access. | 
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, RequestAndBlockCam) { | 
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, RequestAndBlockCam) { | 
| InitWithUrl(GURL("https://www.example.com")); | 
| SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_DENIED); | 
| // Ensure the prompt is accepted if necessary such that tab specific content | 
| // settings are updated. | 
| -  prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 
| +  SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); | 
| RequestPermissions( | 
| GetWebContents(), CreateRequest(std::string(), example_video_id()), | 
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 
| @@ -343,14 +428,14 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, RequestAndBlockCam) { | 
| } | 
|  | 
| // Request and allow microphone and camera access. | 
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, | 
| RequestAndAllowMicCam) { | 
| InitWithUrl(GURL("https://www.example.com")); | 
| SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_ALLOWED); | 
| SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_ALLOWED); | 
| // Ensure the prompt is accepted if necessary such that tab specific content | 
| // settings are updated. | 
| -  prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 
| +  SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); | 
| RequestPermissions( | 
| GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), | 
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 
| @@ -378,14 +463,14 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 
| } | 
|  | 
| // Request and block microphone and camera access. | 
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, | 
| RequestAndBlockMicCam) { | 
| InitWithUrl(GURL("https://www.example.com")); | 
| SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_DENIED); | 
| SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_DENIED); | 
| // Ensure the prompt is accepted if necessary such that tab specific content | 
| // settings are updated. | 
| -  prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 
| +  SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); | 
| RequestPermissions( | 
| GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), | 
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 
| @@ -415,14 +500,14 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 
| } | 
|  | 
| // Request microphone and camera access. Allow microphone, block camera. | 
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, | 
| RequestMicCamBlockCam) { | 
| InitWithUrl(GURL("https://www.example.com")); | 
| SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_ALLOWED); | 
| SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_DENIED); | 
| // Ensure the prompt is accepted if necessary such that tab specific content | 
| // settings are updated. | 
| -  prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 
| +  SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); | 
| RequestPermissions( | 
| GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), | 
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 
| @@ -451,14 +536,14 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 
| } | 
|  | 
| // Request microphone and camera access. Block microphone, allow camera. | 
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, | 
| RequestMicCamBlockMic) { | 
| InitWithUrl(GURL("https://www.example.com")); | 
| SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_DENIED); | 
| SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_ALLOWED); | 
| // Ensure the prompt is accepted if necessary such that tab specific content | 
| // settings are updated. | 
| -  prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 
| +  SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); | 
| RequestPermissions( | 
| GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), | 
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 
| @@ -488,14 +573,14 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 
|  | 
| // Request microphone access. Requesting camera should not change microphone | 
| // state. | 
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, | 
| RequestCamDoesNotChangeMic) { | 
| InitWithUrl(GURL("https://www.example.com")); | 
| // Request mic and deny. | 
| SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_DENIED); | 
| // Ensure the prompt is accepted if necessary such that tab specific content | 
| // settings are updated. | 
| -  prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 
| +  SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); | 
| RequestPermissions( | 
| GetWebContents(), CreateRequest(example_audio_id(), std::string()), | 
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 
| @@ -536,14 +621,14 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 
| } | 
|  | 
| // Denying mic access after camera access should still show the camera as state. | 
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, | 
| DenyMicDoesNotChangeCam) { | 
| InitWithUrl(GURL("https://www.example.com")); | 
| // Request cam and allow | 
| SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_ALLOWED); | 
| // Ensure the prompt is accepted if necessary such that tab specific content | 
| // settings are updated. | 
| -  prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 
| +  SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); | 
| RequestPermissions( | 
| GetWebContents(), CreateRequest(std::string(), example_video_id()), | 
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 
| @@ -576,7 +661,7 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 
| SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_DENIED); | 
| // Ensure the prompt is accepted if necessary such that tab specific content | 
| // settings are updated. | 
| -  prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 
| +  SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); | 
| RequestPermissions( | 
| GetWebContents(), CreateRequest(example_audio_id(), std::string()), | 
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 
| @@ -648,7 +733,7 @@ struct ContentSettingsTestData { | 
|  | 
| // Test all combinations of cam/mic content settings. Then tests the result of | 
| // clicking both accept/deny on the infobar. Both cam/mic are requested. | 
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, ContentSettings) { | 
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, ContentSettings) { | 
| InitWithUrl(GURL("https://www.example.com")); | 
| static const ContentSettingsTestData tests[] = { | 
| // Settings that won't result in an infobar. | 
| @@ -677,32 +762,28 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, ContentSettings) { | 
| for (auto& test : tests) { | 
| SetContentSettings(test.mic, test.cam); | 
|  | 
| -    prompt_delegate()->Reset(); | 
| +    ResetPromptCounters(); | 
|  | 
| // Accept or deny the infobar if it's showing. | 
| if (test.ExpectMicInfobar() || test.ExpectCamInfobar()) { | 
| if (test.accept_infobar) { | 
| -        prompt_delegate()->set_response_type( | 
| -            PermissionRequestManager::ACCEPT_ALL); | 
| +        SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); | 
| } else { | 
| -        prompt_delegate()->set_response_type( | 
| -            PermissionRequestManager::DENY_ALL); | 
| +        SetPromptResponseType(PermissionRequestManager::DENY_ALL); | 
| } | 
| } else { | 
| -      prompt_delegate()->set_response_type(PermissionRequestManager::NONE); | 
| +      SetPromptResponseType(PermissionRequestManager::NONE); | 
| } | 
| RequestPermissions( | 
| GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), | 
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 
| base::Unretained(this))); | 
|  | 
| -    ASSERT_LE(prompt_delegate()->TotalRequestCount(), 2u); | 
| -    ASSERT_EQ( | 
| -        test.ExpectMicInfobar(), | 
| -        prompt_delegate()->WasRequested(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 
| +    ASSERT_LE(TotalPromptRequestCount(), 2u); | 
| +    ASSERT_EQ(test.ExpectMicInfobar(), | 
| +              WasPermissionShown(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 
| ASSERT_EQ(test.ExpectCamInfobar(), | 
| -              prompt_delegate()->WasRequested( | 
| -                  CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 
| +              WasPermissionShown(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 
|  | 
| // Check the media stream result is expected and the devices returned are | 
| // expected; | 
| @@ -715,7 +796,7 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, ContentSettings) { | 
| } | 
|  | 
| // Request and allow camera access on WebUI pages without prompting. | 
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, | 
| WebUIRequestAndAllowCam) { | 
| InitWithUrl(GURL("chrome://test-page")); | 
| RequestPermissions( | 
| @@ -723,27 +804,25 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 
| base::Unretained(this))); | 
|  | 
| -  ASSERT_EQ(0u, prompt_delegate()->TotalRequestCount()); | 
| +  ASSERT_EQ(0u, TotalPromptRequestCount()); | 
|  | 
| ASSERT_EQ(content::MEDIA_DEVICE_OK, media_stream_result()); | 
| ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); | 
| ASSERT_TRUE(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE)); | 
| } | 
|  | 
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, | 
| ExtensionRequestMicCam) { | 
| InitWithUrl(GURL("chrome-extension://test-page")); | 
| // Test that a prompt is required. | 
| -  prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 
| +  SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); | 
| RequestPermissions( | 
| GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), | 
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 
| base::Unretained(this))); | 
| -  ASSERT_EQ(2u, prompt_delegate()->TotalRequestCount()); | 
| -  ASSERT_TRUE(prompt_delegate()->WasRequested( | 
| -      CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 
| -  ASSERT_TRUE( | 
| -      prompt_delegate()->WasRequested(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 
| +  ASSERT_EQ(2u, TotalPromptRequestCount()); | 
| +  ASSERT_TRUE(WasPermissionShown(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 
| +  ASSERT_TRUE(WasPermissionShown(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 
|  | 
| // Accept the prompt. | 
| ASSERT_EQ(content::MEDIA_DEVICE_OK, media_stream_result()); | 
| @@ -751,12 +830,12 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 
| ASSERT_TRUE(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE)); | 
|  | 
| // Check that re-requesting allows without prompting. | 
| -  prompt_delegate()->Reset(); | 
| +  ResetPromptCounters(); | 
| RequestPermissions( | 
| GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), | 
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 
| base::Unretained(this))); | 
| -  ASSERT_EQ(0u, prompt_delegate()->TotalRequestCount()); | 
| +  ASSERT_EQ(0u, TotalPromptRequestCount()); | 
|  | 
| ASSERT_EQ(content::MEDIA_DEVICE_OK, media_stream_result()); | 
| ASSERT_TRUE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); | 
| @@ -765,7 +844,7 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 
|  | 
| // For Pepper request from insecure origin, even if it's ALLOW, it won't be | 
| // changed to ASK. | 
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, | 
| PepperRequestInsecure) { | 
| InitWithUrl(GURL("http://www.example.com")); | 
| SetContentSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW); | 
| @@ -776,11 +855,11 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 
| content::MEDIA_OPEN_DEVICE_PEPPER_ONLY), | 
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 
| base::Unretained(this))); | 
| -  ASSERT_EQ(0u, prompt_delegate()->TotalRequestCount()); | 
| +  ASSERT_EQ(0u, TotalPromptRequestCount()); | 
| } | 
|  | 
| // Request and block microphone and camera access with kill switch. | 
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, | 
| RequestAndKillSwitchMicCam) { | 
| std::map<std::string, std::string> params; | 
| params[PermissionUtil::GetPermissionString( | 
| @@ -803,9 +882,15 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 
| base::Unretained(this))); | 
|  | 
| -  ASSERT_EQ(0u, prompt_delegate()->TotalRequestCount()); | 
| +  ASSERT_EQ(0u, TotalPromptRequestCount()); | 
|  | 
| ASSERT_EQ(content::MEDIA_DEVICE_KILL_SWITCH_ON, media_stream_result()); | 
| ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); | 
| ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE)); | 
| } | 
| + | 
| +INSTANTIATE_TEST_CASE_P( | 
| +    MediaStreamDevicesControllerTestInstance, | 
| +    MediaStreamDevicesControllerTest, | 
| +    ::testing::Values(TestType::DEFAULT, | 
| +                      TestType::TEST_WITH_GROUPED_MEDIA_REQUESTS)); | 
|  |