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 = 4 | |
|
mlamouri (slow - plz ping)
2016/08/04 12:42:02
Can you add a comment that says that this one shou
kdsilva
2016/08/04 14:13:21
Done.
| |
| 194 }; | |
| 195 | |
| 196 const char kFlashYouTubeRewrite[] = "Plugin.Flash.YouTubeRewrite"; | |
|
mlamouri (slow - plz ping)
2016/08/04 12:42:02
Maybe name this `kFlashYouTubeRewriteUma`?
kdsilva
2016/08/04 14:13:22
Done.
| |
| 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 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1423 for (size_t pos = index + 1; | 1433 for (size_t pos = index + 1; |
| 1424 (pos = url_str.find("?",pos )) != std::string::npos; pos += 1) | 1434 (pos = url_str.find("?",pos )) != std::string::npos; pos += 1) |
| 1425 url_str.replace(pos, 1, "&"); | 1435 url_str.replace(pos, 1, "&"); |
| 1426 } | 1436 } |
| 1427 | 1437 |
| 1428 GURL corrected_url = GURL(url_str); | 1438 GURL corrected_url = GURL(url_str); |
| 1429 | 1439 |
| 1430 // We don't modify any URLs that contain the enablejsapi=1 parameter | 1440 // We don't modify any URLs that contain the enablejsapi=1 parameter |
| 1431 // since the page may be interacting with the YouTube Flash player in | 1441 // since the page may be interacting with the YouTube Flash player in |
| 1432 // Javascript and we don't want to break working content. | 1442 // Javascript and we don't want to break working content. |
| 1433 if (corrected_url.query().find("enablejsapi=1") != std::string::npos) | 1443 if (corrected_url.query().find("enablejsapi=1") != std::string::npos) { |
| 1444 UMA_HISTOGRAM_ENUMERATION(kFlashYouTubeRewrite, FAILURE_ENABLEJSAPI, | |
| 1445 NUM_PLUGIN_ERROR); | |
| 1434 return GURL(); | 1446 return GURL(); |
| 1447 } | |
| 1435 | 1448 |
| 1436 // Change the path to use the YouTube HTML5 API | 1449 // Change the path to use the YouTube HTML5 API |
| 1437 std::string path = corrected_url.path(); | 1450 std::string path = corrected_url.path(); |
| 1438 path.replace(path.find("/v/"), 3, "/embed/"); | 1451 path.replace(path.find("/v/"), 3, "/embed/"); |
| 1439 | 1452 |
| 1440 url::Replacements<char> r; | 1453 url::Replacements<char> r; |
| 1441 r.SetPath(path.c_str(), url::Component(0, path.length())); | 1454 r.SetPath(path.c_str(), url::Component(0, path.length())); |
| 1442 | 1455 |
| 1456 UMA_HISTOGRAM_ENUMERATION(kFlashYouTubeRewrite, | |
| 1457 invalid_url ? SUCCESS_PARAMS_REWRITE : SUCCESS, NUM_PLUGIN_ERROR); | |
| 1443 return corrected_url.ReplaceComponents(r); | 1458 return corrected_url.ReplaceComponents(r); |
| 1444 } | 1459 } |
| OLD | NEW |