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

Side by Side Diff: chrome/browser/media/webrtc_browsertest_base.cc

Issue 341833004: [WebsiteSettings] Enable permission bubbles by default. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/media/webrtc_browsertest_base.h" 5 #include "chrome/browser/media/webrtc_browsertest_base.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/infobars/infobar_service.h" 11 #include "chrome/browser/infobars/infobar_service.h"
12 #include "chrome/browser/media/media_stream_infobar_delegate.h" 12 #include "chrome/browser/media/media_stream_infobar_delegate.h"
13 #include "chrome/browser/media/webrtc_browsertest_common.h" 13 #include "chrome/browser/media/webrtc_browsertest_common.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_tabstrip.h" 15 #include "chrome/browser/ui/browser_tabstrip.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model.h"
17 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
17 #include "chrome/test/base/ui_test_utils.h" 18 #include "chrome/test/base/ui_test_utils.h"
18 #include "components/infobars/core/infobar.h" 19 #include "components/infobars/core/infobar.h"
19 #include "content/public/browser/notification_service.h" 20 #include "content/public/browser/notification_service.h"
20 #include "content/public/test/browser_test_utils.h" 21 #include "content/public/test/browser_test_utils.h"
22 #include "content/public/test/test_utils.h"
21 #include "net/test/embedded_test_server/embedded_test_server.h" 23 #include "net/test/embedded_test_server/embedded_test_server.h"
22 24
23 #if defined(OS_WIN) 25 #if defined(OS_WIN)
24 // For fine-grained suppression. 26 // For fine-grained suppression.
25 #include "base/win/windows_version.h" 27 #include "base/win/windows_version.h"
26 #endif 28 #endif
27 29
28 const char WebRtcTestBase::kAudioVideoCallConstraints[] = 30 const char WebRtcTestBase::kAudioVideoCallConstraints[] =
29 "{audio: true, video: true}"; 31 "{audio: true, video: true}";
30 const char WebRtcTestBase::kAudioVideoCallConstraintsQVGA[] = 32 const char WebRtcTestBase::kAudioVideoCallConstraintsQVGA[] =
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 98
97 void WebRtcTestBase::GetUserMediaAndAccept( 99 void WebRtcTestBase::GetUserMediaAndAccept(
98 content::WebContents* tab_contents) const { 100 content::WebContents* tab_contents) const {
99 GetUserMediaWithSpecificConstraintsAndAccept(tab_contents, 101 GetUserMediaWithSpecificConstraintsAndAccept(tab_contents,
100 kAudioVideoCallConstraints); 102 kAudioVideoCallConstraints);
101 } 103 }
102 104
103 void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndAccept( 105 void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndAccept(
104 content::WebContents* tab_contents, 106 content::WebContents* tab_contents,
105 const std::string& constraints) const { 107 const std::string& constraints) const {
106 infobars::InfoBar* infobar = 108 if (!PermissionBubbleManager::Enabled()) {
107 GetUserMediaAndWaitForInfoBar(tab_contents, constraints); 109 infobars::InfoBar* infobar =
108 infobar->delegate()->AsConfirmInfoBarDelegate()->Accept(); 110 GetUserMediaAndWaitForInfoBar(tab_contents, constraints);
109 CloseInfoBarInTab(tab_contents, infobar); 111 infobar->delegate()->AsConfirmInfoBarDelegate()->Accept();
112 CloseInfoBarInTab(tab_contents, infobar);
113 } else {
114 GetUserMedia(tab_contents, constraints);
115 LOG(INFO) << "Accept bubble";
116 PermissionBubbleManager::FromWebContents(tab_contents)->Accept();
117 content::RunAllPendingInMessageLoop();
118 }
110 119
120 LOG(INFO) << "Wait until called";
111 // Wait for WebRTC to call the success callback. 121 // Wait for WebRTC to call the success callback.
112 const char kOkGotStream[] = "ok-got-stream"; 122 const char kOkGotStream[] = "ok-got-stream";
113 EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()", kOkGotStream, 123 EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()", kOkGotStream,
114 tab_contents)); 124 tab_contents));
125 LOG(INFO) << "DONE!!!!!";
115 } 126 }
116 127
117 void WebRtcTestBase::GetUserMediaAndDeny(content::WebContents* tab_contents) { 128 void WebRtcTestBase::GetUserMediaAndDeny(content::WebContents* tab_contents) {
118 return GetUserMediaWithSpecificConstraintsAndDeny(tab_contents, 129 return GetUserMediaWithSpecificConstraintsAndDeny(tab_contents,
119 kAudioVideoCallConstraints); 130 kAudioVideoCallConstraints);
120 } 131 }
121 132
122 void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndDeny( 133 void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndDeny(
123 content::WebContents* tab_contents, 134 content::WebContents* tab_contents,
124 const std::string& constraints) const { 135 const std::string& constraints) const {
125 infobars::InfoBar* infobar = 136 if (!PermissionBubbleManager::Enabled()) {
126 GetUserMediaAndWaitForInfoBar(tab_contents, constraints); 137 infobars::InfoBar* infobar =
127 infobar->delegate()->AsConfirmInfoBarDelegate()->Cancel(); 138 GetUserMediaAndWaitForInfoBar(tab_contents, constraints);
128 CloseInfoBarInTab(tab_contents, infobar); 139 infobar->delegate()->AsConfirmInfoBarDelegate()->Cancel();
140 CloseInfoBarInTab(tab_contents, infobar);
141 } else {
142 GetUserMedia(tab_contents, constraints);
143 PermissionBubbleManager::FromWebContents(tab_contents)->Deny();
144 }
129 145
130 // Wait for WebRTC to call the fail callback. 146 // Wait for WebRTC to call the fail callback.
131 EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()", 147 EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()",
132 kFailedWithPermissionDeniedError, 148 kFailedWithPermissionDeniedError,
133 tab_contents)); 149 tab_contents));
134 } 150 }
135 151
136 void WebRtcTestBase::GetUserMediaAndDismiss( 152 void WebRtcTestBase::GetUserMediaAndDismiss(
137 content::WebContents* tab_contents) const { 153 content::WebContents* tab_contents) const {
138 infobars::InfoBar* infobar = 154 if (!PermissionBubbleManager::Enabled()) {
139 GetUserMediaAndWaitForInfoBar(tab_contents, kAudioVideoCallConstraints); 155 infobars::InfoBar* infobar =
140 infobar->delegate()->InfoBarDismissed(); 156 GetUserMediaAndWaitForInfoBar(tab_contents, kAudioVideoCallConstraints);
141 CloseInfoBarInTab(tab_contents, infobar); 157 infobar->delegate()->InfoBarDismissed();
158 CloseInfoBarInTab(tab_contents, infobar);
159 } else {
160 GetUserMedia(tab_contents, kAudioVideoCallConstraints);
161 PermissionBubbleManager::FromWebContents(tab_contents)->Closing();
162 }
142 163
143 // A dismiss should be treated like a deny. 164 // A dismiss should be treated like a deny.
144 EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()", 165 EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()",
145 kFailedWithPermissionDismissedError, 166 kFailedWithPermissionDismissedError,
146 tab_contents)); 167 tab_contents));
147 } 168 }
148 169
149 void WebRtcTestBase::GetUserMedia(content::WebContents* tab_contents, 170 void WebRtcTestBase::GetUserMedia(content::WebContents* tab_contents,
150 const std::string& constraints) const { 171 const std::string& constraints) const {
151 // Request user media: this will launch the media stream info bar. 172 // Request user media: this will launch the media stream info bar.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 } 217 }
197 218
198 content::WebContents* WebRtcTestBase::OpenTestPageAndGetUserMediaInNewTab( 219 content::WebContents* WebRtcTestBase::OpenTestPageAndGetUserMediaInNewTab(
199 const std::string& test_page) const { 220 const std::string& test_page) const {
200 return OpenPageAndGetUserMediaInNewTab( 221 return OpenPageAndGetUserMediaInNewTab(
201 embedded_test_server()->GetURL(test_page)); 222 embedded_test_server()->GetURL(test_page));
202 } 223 }
203 224
204 content::WebContents* WebRtcTestBase::OpenPageAndAcceptUserMedia( 225 content::WebContents* WebRtcTestBase::OpenPageAndAcceptUserMedia(
205 const GURL& url) const { 226 const GURL& url) const {
206 content::WindowedNotificationObserver infobar_added( 227 content::WindowedNotificationObserver nav(
207 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, 228 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
208 content::NotificationService::AllSources()); 229 content::NotificationService::AllSources());
209 230
210 ui_test_utils::NavigateToURL(browser(), url); 231 ui_test_utils::NavigateToURL(browser(), url);
211 232
212 infobar_added.Wait(); 233 nav.Wait();
213 234
214 content::WebContents* tab_contents = 235 content::WebContents* tab_contents =
215 browser()->tab_strip_model()->GetActiveWebContents(); 236 browser()->tab_strip_model()->GetActiveWebContents();
216 content::Details<infobars::InfoBar::AddedDetails> details( 237 if (!PermissionBubbleManager::Enabled()) {
217 infobar_added.details()); 238 content::Details<infobars::InfoBar::AddedDetails> details(
218 infobars::InfoBar* infobar = details.ptr(); 239 nav.details());
219 EXPECT_TRUE(infobar); 240 infobars::InfoBar* infobar = details.ptr();
220 infobar->delegate()->AsMediaStreamInfoBarDelegate()->Accept(); 241 EXPECT_TRUE(infobar);
242 infobar->delegate()->AsMediaStreamInfoBarDelegate()->Accept();
221 243
222 CloseInfoBarInTab(tab_contents, infobar); 244 CloseInfoBarInTab(tab_contents, infobar);
245 } else {
246 PermissionBubbleManager* mgr =
247 PermissionBubbleManager::FromWebContents(tab_contents);
248 mgr->Closing();
249 }
223 return tab_contents; 250 return tab_contents;
224 } 251 }
225 252
226 void WebRtcTestBase::CloseInfoBarInTab(content::WebContents* tab_contents, 253 void WebRtcTestBase::CloseInfoBarInTab(content::WebContents* tab_contents,
227 infobars::InfoBar* infobar) const { 254 infobars::InfoBar* infobar) const {
228 content::WindowedNotificationObserver infobar_removed( 255 content::WindowedNotificationObserver infobar_removed(
229 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, 256 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
230 content::NotificationService::AllSources()); 257 content::NotificationService::AllSources());
231 258
232 InfoBarService* infobar_service = 259 InfoBarService* infobar_service =
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 #endif 388 #endif
362 } 389 }
363 390
364 bool WebRtcTestBase::OnWin8() const { 391 bool WebRtcTestBase::OnWin8() const {
365 #if defined(OS_WIN) 392 #if defined(OS_WIN)
366 return base::win::GetVersion() > base::win::VERSION_WIN7; 393 return base::win::GetVersion() > base::win::VERSION_WIN7;
367 #else 394 #else
368 return false; 395 return false;
369 #endif 396 #endif
370 } 397 }
OLDNEW
« no previous file with comments | « chrome/browser/media/media_stream_devices_controller.cc ('k') | chrome/browser/notifications/notification_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698