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

Side by Side Diff: chrome/browser/ui/screen_capture_infobar_delegate.cc

Issue 12596011: Whitelist Google Hangouts origins to access Screen Capture API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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
« no previous file with comments | « no previous file | content/browser/renderer_host/media/video_capture_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/ui/screen_capture_infobar_delegate.h" 5 #include "chrome/browser/ui/screen_capture_infobar_delegate.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/api/infobars/infobar_service.h" 9 #include "chrome/browser/api/infobars/infobar_service.h"
10 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
11 #include "grit/generated_resources.h" 11 #include "grit/generated_resources.h"
12 #include "ui/base/l10n/l10n_util.h" 12 #include "ui/base/l10n/l10n_util.h"
13 13
14 namespace {
15
16 // This is a short-term solution to allow testing of the the Screen Capture API
17 // with Google Hangouts in M27.
18 // TODO(sergeyu): Remove this whitelist as soon as possible.
19 bool IsWhitelistedOrigin(const GURL& origin) {
20 #if defined(OFFICIAL_BUILD)
21 return origin.spec() == "https://staging.talkgadget.google.com/" ||
22 origin.spec() == "https://plus.google.com/";
23 #else
24 return false;
25 #endif
26 }
27
28 } // namespace
29
14 // static 30 // static
15 void ScreenCaptureInfoBarDelegate::Create( 31 void ScreenCaptureInfoBarDelegate::Create(
16 content::WebContents* web_contents, 32 content::WebContents* web_contents,
17 const content::MediaStreamRequest& request, 33 const content::MediaStreamRequest& request,
18 const content::MediaResponseCallback& callback) { 34 const content::MediaResponseCallback& callback) {
19 bool screen_capture_enabled = CommandLine::ForCurrentProcess()->HasSwitch( 35 bool screen_capture_enabled = CommandLine::ForCurrentProcess()->HasSwitch(
20 switches::kEnableUserMediaScreenCapturing); 36 switches::kEnableUserMediaScreenCapturing) ||
37 IsWhitelistedOrigin(request.security_origin);
21 // Deny request automatically in the following cases: 38 // Deny request automatically in the following cases:
22 // 1. Screen capturing is not enabled via command line switch. 39 // 1. Screen capturing is not enabled via command line switch.
23 // 2. Audio capture was requested (it's not supported yet). 40 // 2. Audio capture was requested (it's not supported yet).
24 // 3. Request from a page that was not loaded from a secure origin. 41 // 3. Request from a page that was not loaded from a secure origin.
25 if (!screen_capture_enabled || 42 if (!screen_capture_enabled ||
26 request.audio_type != content::MEDIA_NO_SERVICE || 43 request.audio_type != content::MEDIA_NO_SERVICE ||
27 !request.security_origin.SchemeIsSecure()) { 44 !request.security_origin.SchemeIsSecure()) {
28 callback.Run(content::MediaStreamDevices()); 45 callback.Run(content::MediaStreamDevices());
29 return; 46 return;
30 } 47 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 110 }
94 111
95 bool ScreenCaptureInfoBarDelegate::Cancel() { 112 bool ScreenCaptureInfoBarDelegate::Cancel() {
96 Deny(); 113 Deny();
97 return true; 114 return true;
98 } 115 }
99 116
100 void ScreenCaptureInfoBarDelegate::Deny() { 117 void ScreenCaptureInfoBarDelegate::Deny() {
101 callback_.Run(content::MediaStreamDevices()); 118 callback_.Run(content::MediaStreamDevices());
102 } 119 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/media/video_capture_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698