summaryrefslogtreecommitdiffstats
path: root/chrome/browser/media/webrtc_browsertest_base.cc
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-03 03:16:26 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-03 03:16:26 +0000
commit42b0ecedf7eb4beea125ac17ffc0cd373f4b420c (patch)
tree8c2026442208c18ec14613f0f6132b24acd1e7de /chrome/browser/media/webrtc_browsertest_base.cc
parent37a241c6f22e761a07d9ff70aff1b15674eb8bf6 (diff)
downloadchromium_src-42b0ecedf7eb4beea125ac17ffc0cd373f4b420c.zip
chromium_src-42b0ecedf7eb4beea125ac17ffc0cd373f4b420c.tar.gz
chromium_src-42b0ecedf7eb4beea125ac17ffc0cd373f4b420c.tar.bz2
Infobar system refactor.
This changes the ownership model of infobars so that InfoBars are long-lived and own their InfoBarDelegates directly. The InfoBarService pseudo-owns the InfoBars (instead of deleting them directly, it tells them when they're unowned and expects them to delete themselves). This fixes leaks when infobars are closed while not visible (e.g. in a background tab) and in general makes the system clearer and easier to reason about. BUG=62154 TEST=none R=erg@chromium.org, sail@chromium.org, sky@chromium.org Review URL: https://codereview.chromium.org/22694006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238283 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/media/webrtc_browsertest_base.cc')
-rw-r--r--chrome/browser/media/webrtc_browsertest_base.cc28
1 files changed, 12 insertions, 16 deletions
diff --git a/chrome/browser/media/webrtc_browsertest_base.cc b/chrome/browser/media/webrtc_browsertest_base.cc
index ad073ad..0c1d8d5 100644
--- a/chrome/browser/media/webrtc_browsertest_base.cc
+++ b/chrome/browser/media/webrtc_browsertest_base.cc
@@ -38,9 +38,8 @@ void WebRtcTestBase::GetUserMediaAndAccept(
void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndAccept(
content::WebContents* tab_contents,
const std::string& constraints) const {
- MediaStreamInfoBarDelegate* infobar =
- GetUserMediaAndWaitForInfoBar(tab_contents, constraints);
- infobar->Accept();
+ InfoBar* infobar = GetUserMediaAndWaitForInfoBar(tab_contents, constraints);
+ infobar->delegate()->AsConfirmInfoBarDelegate()->Accept();
CloseInfoBarInTab(tab_contents, infobar);
// Wait for WebRTC to call the success callback.
@@ -57,9 +56,8 @@ void WebRtcTestBase::GetUserMediaAndDeny(content::WebContents* tab_contents) {
void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndDeny(
content::WebContents* tab_contents,
const std::string& constraints) const {
- MediaStreamInfoBarDelegate* infobar =
- GetUserMediaAndWaitForInfoBar(tab_contents, constraints);
- infobar->Cancel();
+ InfoBar* infobar = GetUserMediaAndWaitForInfoBar(tab_contents, constraints);
+ infobar->delegate()->AsConfirmInfoBarDelegate()->Cancel();
CloseInfoBarInTab(tab_contents, infobar);
// Wait for WebRTC to call the fail callback.
@@ -69,9 +67,9 @@ void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndDeny(
void WebRtcTestBase::GetUserMediaAndDismiss(
content::WebContents* tab_contents) const {
- MediaStreamInfoBarDelegate* infobar =
+ InfoBar* infobar =
GetUserMediaAndWaitForInfoBar(tab_contents, kAudioVideoCallConstraints);
- infobar->InfoBarDismissed();
+ infobar->delegate()->InfoBarDismissed();
CloseInfoBarInTab(tab_contents, infobar);
// A dismiss should be treated like a deny.
@@ -99,7 +97,7 @@ void WebRtcTestBase::GetUserMedia(content::WebContents* tab_contents,
EXPECT_EQ("ok-requested", result);
}
-MediaStreamInfoBarDelegate* WebRtcTestBase::GetUserMediaAndWaitForInfoBar(
+InfoBar* WebRtcTestBase::GetUserMediaAndWaitForInfoBar(
content::WebContents* tab_contents,
const std::string& constraints) const {
content::WindowedNotificationObserver infobar_added(
@@ -112,9 +110,8 @@ MediaStreamInfoBarDelegate* WebRtcTestBase::GetUserMediaAndWaitForInfoBar(
// Wait for the bar to pop up, then return it.
infobar_added.Wait();
content::Details<InfoBar::AddedDetails> details(infobar_added.details());
- MediaStreamInfoBarDelegate* infobar = details->AsMediaStreamInfoBarDelegate();
- EXPECT_TRUE(infobar);
- return infobar;
+ EXPECT_TRUE(details->delegate()->AsMediaStreamInfoBarDelegate());
+ return details.ptr();
}
content::WebContents* WebRtcTestBase::OpenPageAndAcceptUserMedia(
@@ -130,10 +127,9 @@ content::WebContents* WebRtcTestBase::OpenPageAndAcceptUserMedia(
content::WebContents* tab_contents =
browser()->tab_strip_model()->GetActiveWebContents();
content::Details<InfoBar::AddedDetails> details(infobar_added.details());
- MediaStreamInfoBarDelegate* infobar =
- details->AsMediaStreamInfoBarDelegate();
+ InfoBar* infobar = details.ptr();
EXPECT_TRUE(infobar);
- infobar->Accept();
+ infobar->delegate()->AsMediaStreamInfoBarDelegate()->Accept();
CloseInfoBarInTab(tab_contents, infobar);
return tab_contents;
@@ -141,7 +137,7 @@ content::WebContents* WebRtcTestBase::OpenPageAndAcceptUserMedia(
void WebRtcTestBase::CloseInfoBarInTab(
content::WebContents* tab_contents,
- MediaStreamInfoBarDelegate* infobar) const {
+ InfoBar* infobar) const {
content::WindowedNotificationObserver infobar_removed(
chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
content::NotificationService::AllSources());