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/renderer/chrome_content_renderer_client.h" | 5 #include "chrome/renderer/chrome_content_renderer_client.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 using blink::WebURLResponse; | 178 using blink::WebURLResponse; |
| 179 using blink::WebVector; | 179 using blink::WebVector; |
| 180 using content::PluginInstanceThrottler; | 180 using content::PluginInstanceThrottler; |
| 181 using content::RenderFrame; | 181 using content::RenderFrame; |
| 182 using content::RenderThread; | 182 using content::RenderThread; |
| 183 using content::WebPluginInfo; | 183 using content::WebPluginInfo; |
| 184 using extensions::Extension; | 184 using extensions::Extension; |
| 185 | 185 |
| 186 namespace { | 186 namespace { |
| 187 | 187 |
| 188 enum YouTubeRewriteStatus { | |
| 189 SUCCESS = 0, | |
| 190 SUCCESS_PARAMS_REWRITE = 1, | |
| 191 SUCCESS_ENABLEJSAPI = 2, | |
| 192 FAILURE_ENABLEJSAPI = 3, | |
| 193 NUM_PLUGIN_ERROR // should be kept last | |
| 194 }; | |
| 195 | |
| 196 const char kFlashYouTubeRewriteUMA[] = "Plugin.Flash.YouTubeRewrite"; | |
| 197 | |
| 188 // Whitelist PPAPI for Android Runtime for Chromium. (See crbug.com/383937) | 198 // Whitelist PPAPI for Android Runtime for Chromium. (See crbug.com/383937) |
| 189 #if defined(ENABLE_PLUGINS) | 199 #if defined(ENABLE_PLUGINS) |
| 190 const char* const kPredefinedAllowedCameraDeviceOrigins[] = { | 200 const char* const kPredefinedAllowedCameraDeviceOrigins[] = { |
| 191 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", | 201 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", |
| 192 "4EB74897CB187C7633357C2FE832E0AD6A44883A" | 202 "4EB74897CB187C7633357C2FE832E0AD6A44883A" |
| 193 }; | 203 }; |
| 194 | 204 |
| 195 const char* const kPredefinedAllowedCompositorOrigins[] = { | 205 const char* const kPredefinedAllowedCompositorOrigins[] = { |
| 196 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", | 206 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", |
| 197 "4EB74897CB187C7633357C2FE832E0AD6A44883A" | 207 "4EB74897CB187C7633357C2FE832E0AD6A44883A" |
| (...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1425 (pos = url_str.find("?", pos)) != std::string::npos; pos += 1) { | 1435 (pos = url_str.find("?", pos)) != std::string::npos; pos += 1) { |
| 1426 url_str.replace(pos, 1, "&"); | 1436 url_str.replace(pos, 1, "&"); |
| 1427 } | 1437 } |
| 1428 } | 1438 } |
| 1429 | 1439 |
| 1430 GURL corrected_url = GURL(url_str); | 1440 GURL corrected_url = GURL(url_str); |
| 1431 | 1441 |
| 1432 // We don't modify any URLs that contain the enablejsapi=1 parameter | 1442 // We don't modify any URLs that contain the enablejsapi=1 parameter |
| 1433 // since the page may be interacting with the YouTube Flash player in | 1443 // since the page may be interacting with the YouTube Flash player in |
| 1434 // Javascript and we don't want to break working content. | 1444 // Javascript and we don't want to break working content. |
| 1435 if (corrected_url.query().find("enablejsapi=1") != std::string::npos) | 1445 if (corrected_url.query().find("enablejsapi=1") != std::string::npos) { |
| 1446 UMA_HISTOGRAM_ENUMERATION(kFlashYouTubeRewriteUMA, FAILURE_ENABLEJSAPI, | |
|
Alexei Svitkine (slow)
2016/08/04 14:31:18
UMA macros expand to a lot of code. Please avoid t
kdsilva
2016/08/04 18:28:52
Done.
| |
| 1447 NUM_PLUGIN_ERROR); | |
| 1436 return GURL(); | 1448 return GURL(); |
| 1449 } | |
| 1437 | 1450 |
| 1438 // Change the path to use the YouTube HTML5 API | 1451 // Change the path to use the YouTube HTML5 API |
| 1439 std::string path = corrected_url.path(); | 1452 std::string path = corrected_url.path(); |
| 1440 path.replace(path.find("/v/"), 3, "/embed/"); | 1453 path.replace(path.find("/v/"), 3, "/embed/"); |
| 1441 | 1454 |
| 1442 url::Replacements<char> r; | 1455 url::Replacements<char> r; |
| 1443 r.SetPath(path.c_str(), url::Component(0, path.length())); | 1456 r.SetPath(path.c_str(), url::Component(0, path.length())); |
| 1444 | 1457 |
| 1458 UMA_HISTOGRAM_ENUMERATION(kFlashYouTubeRewriteUMA, | |
| 1459 invalid_url ? SUCCESS_PARAMS_REWRITE : SUCCESS, | |
| 1460 NUM_PLUGIN_ERROR); | |
| 1445 return corrected_url.ReplaceComponents(r); | 1461 return corrected_url.ReplaceComponents(r); |
| 1446 } | 1462 } |
| OLD | NEW |