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 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1384 // information. Also, the enforcement of sending and binding UDP is already done | 1394 // information. Also, the enforcement of sending and binding UDP is already done |
| 1385 // by chrome extension permission model. | 1395 // by chrome extension permission model. |
| 1386 bool ChromeContentRendererClient::ShouldEnforceWebRTCRoutingPreferences() { | 1396 bool ChromeContentRendererClient::ShouldEnforceWebRTCRoutingPreferences() { |
| 1387 #if defined(ENABLE_EXTENSIONS) | 1397 #if defined(ENABLE_EXTENSIONS) |
| 1388 return !IsStandaloneExtensionProcess(); | 1398 return !IsStandaloneExtensionProcess(); |
| 1389 #else | 1399 #else |
| 1390 return true; | 1400 return true; |
| 1391 #endif | 1401 #endif |
| 1392 } | 1402 } |
| 1393 | 1403 |
| 1404 void ChromeContentRendererClient::UpdateUMAMetrics(const int& status, | |
|
mlamouri (slow - plz ping)
2016/08/05 12:51:09
Maybe name this "RecordYouTubeRewriteUMA"?
And mo
kdsilva
2016/08/05 14:33:54
Done.
| |
| 1405 const int& max) { | |
|
mlamouri (slow - plz ping)
2016/08/05 12:51:09
s/const int&/int/
kdsilva
2016/08/05 14:33:54
Done.
| |
| 1406 UMA_HISTOGRAM_ENUMERATION(kFlashYouTubeRewriteUMA, status, max); | |
| 1407 } | |
| 1408 | |
| 1394 GURL ChromeContentRendererClient::OverrideFlashEmbedWithHTML(const GURL& url) { | 1409 GURL ChromeContentRendererClient::OverrideFlashEmbedWithHTML(const GURL& url) { |
| 1395 if (!base::FeatureList::IsEnabled(features::kOverrideYouTubeFlashEmbed)) | 1410 if (!base::FeatureList::IsEnabled(features::kOverrideYouTubeFlashEmbed)) |
| 1396 return GURL(); | 1411 return GURL(); |
| 1397 | 1412 |
| 1398 if (!url.is_valid()) | 1413 if (!url.is_valid()) |
| 1399 return GURL(); | 1414 return GURL(); |
| 1400 | 1415 |
| 1401 // We'll only modify YouTube Flash embeds. The URLs can be recognized since | 1416 // We'll only modify YouTube Flash embeds. The URLs can be recognized since |
| 1402 // they're in the following form: youtube.com/v/VIDEO_ID. So, we check to see | 1417 // they're in the following form: youtube.com/v/VIDEO_ID. So, we check to see |
| 1403 // if the given URL does follow that format. | 1418 // if the given URL does follow that format. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 1426 (pos = url_str.find("?", pos)) != std::string::npos; pos += 1) { | 1441 (pos = url_str.find("?", pos)) != std::string::npos; pos += 1) { |
| 1427 url_str.replace(pos, 1, "&"); | 1442 url_str.replace(pos, 1, "&"); |
| 1428 } | 1443 } |
| 1429 } | 1444 } |
| 1430 | 1445 |
| 1431 GURL corrected_url = GURL(url_str); | 1446 GURL corrected_url = GURL(url_str); |
| 1432 | 1447 |
| 1433 // We don't modify any URLs that contain the enablejsapi=1 parameter | 1448 // We don't modify any URLs that contain the enablejsapi=1 parameter |
| 1434 // since the page may be interacting with the YouTube Flash player in | 1449 // since the page may be interacting with the YouTube Flash player in |
| 1435 // Javascript and we don't want to break working content. | 1450 // Javascript and we don't want to break working content. |
| 1436 if (corrected_url.query().find("enablejsapi=1") != std::string::npos) | 1451 if (corrected_url.query().find("enablejsapi=1") != std::string::npos) { |
| 1452 UpdateUMAMetrics(FAILURE_ENABLEJSAPI, NUM_PLUGIN_ERROR); | |
| 1437 return GURL(); | 1453 return GURL(); |
| 1454 } | |
| 1438 | 1455 |
| 1439 // Change the path to use the YouTube HTML5 API | 1456 // Change the path to use the YouTube HTML5 API |
| 1440 std::string path = corrected_url.path(); | 1457 std::string path = corrected_url.path(); |
| 1441 path.replace(path.find("/v/"), 3, "/embed/"); | 1458 path.replace(path.find("/v/"), 3, "/embed/"); |
| 1442 | 1459 |
| 1443 url::Replacements<char> r; | 1460 url::Replacements<char> r; |
| 1444 r.SetPath(path.c_str(), url::Component(0, path.length())); | 1461 r.SetPath(path.c_str(), url::Component(0, path.length())); |
| 1445 | 1462 |
| 1463 UpdateUMAMetrics(invalid_url ? SUCCESS_PARAMS_REWRITE : SUCCESS, | |
| 1464 NUM_PLUGIN_ERROR); | |
| 1446 return corrected_url.ReplaceComponents(r); | 1465 return corrected_url.ReplaceComponents(r); |
| 1447 } | 1466 } |
| OLD | NEW |