Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/media_capture_devices_dispatcher.h" | 5 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 // Once http://crbug.com/292856 is fixed, remove this whitelist. | 82 // Once http://crbug.com/292856 is fixed, remove this whitelist. |
| 83 bool IsMediaRequestWhitelistedForExtension( | 83 bool IsMediaRequestWhitelistedForExtension( |
| 84 const extensions::Extension* extension) { | 84 const extensions::Extension* extension) { |
| 85 return extension->id() == "mppnpdlheglhdfmldimlhpnegondlapf" || | 85 return extension->id() == "mppnpdlheglhdfmldimlhpnegondlapf" || |
| 86 extension->id() == "bepbmhgboaologfdajaanbcjmnhjmhfn" || | 86 extension->id() == "bepbmhgboaologfdajaanbcjmnhjmhfn" || |
| 87 extension->id() == "jokbpnebhdcladagohdnfgjcpejggllo" || | 87 extension->id() == "jokbpnebhdcladagohdnfgjcpejggllo" || |
| 88 extension->id() == "clffjmdilanldobdnedchkdbofoimcgb" || | 88 extension->id() == "clffjmdilanldobdnedchkdbofoimcgb" || |
| 89 extension->id() == "nnckehldicaciogcbchegobnafnjkcne"; | 89 extension->id() == "nnckehldicaciogcbchegobnafnjkcne"; |
| 90 } | 90 } |
| 91 | 91 |
| 92 // This is a short-term solution to allow testing of the the Screen Capture API | 92 bool IsBuiltInExtension(const GURL& origin) { |
| 93 // with Google Hangouts in M27. | 93 return |
| 94 // TODO(sergeyu): Remove this whitelist as soon as possible. | 94 // Feedback Extension. |
| 95 bool IsOriginWhitelistedForScreenCapture(const GURL& origin) { | 95 origin.spec() == "chrome-extension://gfdkimpbcpahaombhbimeihdjnejgicl/"; |
| 96 } | |
| 97 | |
| 98 #define OFFICIAL_BUILD | |
|
mark a. foltz
2014/04/25 21:44:38
Did you intend to add this?
Sergey Ulanov
2014/04/25 21:57:58
no - just wanted to make sure it compiles as offic
| |
| 99 // Returns true of the security origin is associated with casting. | |
| 100 bool IsOriginForCasting(const GURL& origin) { | |
| 96 #if defined(OFFICIAL_BUILD) | 101 #if defined(OFFICIAL_BUILD) |
| 97 if (// Google Hangouts. | 102 // Whitelisted tab casting extensions. |
| 98 (origin.SchemeIs("https") && | 103 return |
| 99 EndsWith(origin.spec(), ".talkgadget.google.com/", true)) || | 104 // Dev |
| 100 origin.spec() == "https://talkgadget.google.com/" || | 105 origin.spec() == "chrome-extension://enhhojjnijigcajfphajepfemndkmdlo/" || |
| 101 origin.spec() == "https://plus.google.com/" || | 106 // Canary |
| 102 origin.spec() == "chrome-extension://pkedcjkdefgpdelpbcmbmeomcjbeemfm/" || | 107 origin.spec() == "chrome-extension://hfaagokkkhdbgiakmmlclaapfelnkoah/" || |
| 108 // Beta (internal) | |
| 103 origin.spec() == "chrome-extension://fmfcbgogabcbclcofgocippekhfcmgfj/" || | 109 origin.spec() == "chrome-extension://fmfcbgogabcbclcofgocippekhfcmgfj/" || |
| 104 origin.spec() == "chrome-extension://hfaagokkkhdbgiakmmlclaapfelnkoah/" || | 110 // Google Cast Beta |
| 105 origin.spec() == "chrome-extension://boadgeojelhgndaghljhdicfkmllpafd/" || | 111 origin.spec() == "chrome-extension://dliochdbjfkdbacpmhlcpmleaejidimm/" || |
| 106 origin.spec() == "chrome-extension://gfdkimpbcpahaombhbimeihdjnejgicl/") { | 112 // Google Cast Stable |
| 107 return true; | 113 origin.spec() == "chrome-extension://boadgeojelhgndaghljhdicfkmllpafd/"; |
| 108 } | |
| 109 // Check against hashed origins. | |
| 110 // TODO(hshi): remove this when trusted tester becomes public. | |
| 111 const std::string origin_hash = base::SHA1HashString(origin.spec()); | |
| 112 DCHECK_EQ(origin_hash.length(), base::kSHA1Length); | |
| 113 const std::string hexencoded_origin_hash = | |
| 114 base::HexEncode(origin_hash.data(), origin_hash.length()); | |
| 115 return | |
| 116 hexencoded_origin_hash == "3C2705BC432E7C51CA8553FDC5BEE873FF2468EE"; | |
| 117 #else | 114 #else |
| 118 return false; | 115 return false; |
| 119 #endif | 116 #endif |
| 120 } | 117 } |
| 121 | 118 |
| 122 #if defined(OS_CHROMEOS) | |
| 123 // Returns true of the security origin is associated with casting. | |
| 124 bool IsOriginForCasting(const GURL& origin) { | |
| 125 #if defined(OFFICIAL_BUILD) | |
| 126 // Whitelisted tab casting extensions. | |
| 127 if (origin.spec() == "chrome-extension://pkedcjkdefgpdelpbcmbmeomcjbeemfm/" || | |
| 128 origin.spec() == "chrome-extension://fmfcbgogabcbclcofgocippekhfcmgfj/" || | |
| 129 origin.spec() == "chrome-extension://hfaagokkkhdbgiakmmlclaapfelnkoah/" || | |
| 130 origin.spec() == "chrome-extension://boadgeojelhgndaghljhdicfkmllpafd/") { | |
| 131 return true; | |
| 132 } | |
| 133 // Check against hashed origins. | |
| 134 // TODO(hshi): remove this when trusted tester becomes public. | |
| 135 const std::string origin_hash = base::SHA1HashString(origin.spec()); | |
| 136 DCHECK_EQ(origin_hash.length(), base::kSHA1Length); | |
| 137 const std::string hexencoded_origin_hash = | |
| 138 base::HexEncode(origin_hash.data(), origin_hash.length()); | |
| 139 return | |
| 140 hexencoded_origin_hash == "3C2705BC432E7C51CA8553FDC5BEE873FF2468EE"; | |
| 141 #else | |
| 142 return false; | |
| 143 #endif | |
| 144 } | |
| 145 #endif | |
| 146 | |
| 147 // Helper to get title of the calling application shown in the screen capture | 119 // Helper to get title of the calling application shown in the screen capture |
| 148 // notification. | 120 // notification. |
| 149 base::string16 GetApplicationTitle(content::WebContents* web_contents, | 121 base::string16 GetApplicationTitle(content::WebContents* web_contents, |
| 150 const extensions::Extension* extension) { | 122 const extensions::Extension* extension) { |
| 151 // Use extension name as title for extensions and host/origin for drive-by | 123 // Use extension name as title for extensions and host/origin for drive-by |
| 152 // web. | 124 // web. |
| 153 std::string title; | 125 std::string title; |
| 154 if (extension) { | 126 if (extension) { |
| 155 title = extension->name(); | 127 title = extension->name(); |
| 156 } else { | 128 } else { |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 428 // Currently loopback audio capture is supported only on Windows and ChromeOS. | 400 // Currently loopback audio capture is supported only on Windows and ChromeOS. |
| 429 loopback_audio_supported = true; | 401 loopback_audio_supported = true; |
| 430 #endif | 402 #endif |
| 431 | 403 |
| 432 const bool component_extension = | 404 const bool component_extension = |
| 433 extension && extension->location() == extensions::Manifest::COMPONENT; | 405 extension && extension->location() == extensions::Manifest::COMPONENT; |
| 434 | 406 |
| 435 const bool screen_capture_enabled = | 407 const bool screen_capture_enabled = |
| 436 CommandLine::ForCurrentProcess()->HasSwitch( | 408 CommandLine::ForCurrentProcess()->HasSwitch( |
| 437 switches::kEnableUserMediaScreenCapturing) || | 409 switches::kEnableUserMediaScreenCapturing) || |
| 438 IsOriginWhitelistedForScreenCapture(request.security_origin); | 410 IsOriginForCasting(request.security_origin) || |
| 411 IsBuiltInExtension(request.security_origin); | |
| 439 | 412 |
| 440 const bool origin_is_secure = | 413 const bool origin_is_secure = |
| 441 request.security_origin.SchemeIsSecure() || | 414 request.security_origin.SchemeIsSecure() || |
| 442 request.security_origin.SchemeIs(extensions::kExtensionScheme) || | 415 request.security_origin.SchemeIs(extensions::kExtensionScheme) || |
| 443 CommandLine::ForCurrentProcess()->HasSwitch( | 416 CommandLine::ForCurrentProcess()->HasSwitch( |
| 444 switches::kAllowHttpScreenCapture); | 417 switches::kAllowHttpScreenCapture); |
| 445 | 418 |
| 446 // Approve request only when the following conditions are met: | 419 // Approve request only when the following conditions are met: |
| 447 // 1. Screen capturing is enabled via command line switch or white-listed for | 420 // 1. Screen capturing is enabled via command line switch or white-listed for |
| 448 // the given origin. | 421 // the given origin. |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 944 | 917 |
| 945 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( | 918 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( |
| 946 const MediaStreamDevices& devices) { | 919 const MediaStreamDevices& devices) { |
| 947 test_audio_devices_ = devices; | 920 test_audio_devices_ = devices; |
| 948 } | 921 } |
| 949 | 922 |
| 950 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( | 923 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( |
| 951 const MediaStreamDevices& devices) { | 924 const MediaStreamDevices& devices) { |
| 952 test_video_devices_ = devices; | 925 test_video_devices_ = devices; |
| 953 } | 926 } |
| OLD | NEW |