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 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1431 url_str.replace(index, 1, "?"); | 1431 url_str.replace(index, 1, "?"); |
1432 | 1432 |
1433 // Replace all instances of ? (after the first) with & | 1433 // Replace all instances of ? (after the first) with & |
1434 for (size_t pos = index + 1; | 1434 for (size_t pos = index + 1; |
1435 (pos = url_str.find("?", pos)) != std::string::npos; pos += 1) { | 1435 (pos = url_str.find("?", pos)) != std::string::npos; pos += 1) { |
1436 url_str.replace(pos, 1, "&"); | 1436 url_str.replace(pos, 1, "&"); |
1437 } | 1437 } |
1438 } | 1438 } |
1439 | 1439 |
1440 GURL corrected_url = GURL(url_str); | 1440 GURL corrected_url = GURL(url_str); |
1441 | 1441 bool android_enablejsapi = false; |
1442 // We don't modify any URLs that contain the enablejsapi=1 parameter | 1442 // Unless we're on an Android device, we don't modify any URLs that contain |
1443 // since the page may be interacting with the YouTube Flash player in | 1443 // the enablejsapi=1 parameter since the page may be interacting with the |
1444 // Javascript and we don't want to break working content. | 1444 // YouTube Flash player in Javascript and we don't want to break working |
1445 // content. If we're on an Android device and the URL contains the | |
1446 // enablejsapi=1 parameter, we do override the URL. | |
1445 if (corrected_url.query().find("enablejsapi=1") != std::string::npos) { | 1447 if (corrected_url.query().find("enablejsapi=1") != std::string::npos) { |
1448 #if defined(OS_ANDROID) | |
1449 RecordYouTubeRewriteUMA(internal::SUCCESS_ENABLEJSAPI); | |
1450 android_enablejsapi = true; | |
1451 #else | |
1446 RecordYouTubeRewriteUMA(internal::FAILURE_ENABLEJSAPI); | 1452 RecordYouTubeRewriteUMA(internal::FAILURE_ENABLEJSAPI); |
1447 return GURL(); | 1453 return GURL(); |
1454 #endif | |
mlamouri (slow - plz ping)
2016/08/08 19:50:25
I think this would be more readable if you had:
``
kdsilva
2016/08/09 10:56:26
Done.
| |
1448 } | 1455 } |
1449 | 1456 |
1450 // Change the path to use the YouTube HTML5 API | 1457 // Change the path to use the YouTube HTML5 API |
1451 std::string path = corrected_url.path(); | 1458 std::string path = corrected_url.path(); |
1452 path.replace(path.find("/v/"), 3, "/embed/"); | 1459 path.replace(path.find("/v/"), 3, "/embed/"); |
1453 | 1460 |
1454 url::Replacements<char> r; | 1461 url::Replacements<char> r; |
1455 r.SetPath(path.c_str(), url::Component(0, path.length())); | 1462 r.SetPath(path.c_str(), url::Component(0, path.length())); |
1456 | 1463 |
1457 RecordYouTubeRewriteUMA(invalid_url ? internal::SUCCESS_PARAMS_REWRITE | 1464 if (!android_enablejsapi) |
1458 : internal::SUCCESS); | 1465 RecordYouTubeRewriteUMA(invalid_url ? internal::SUCCESS_PARAMS_REWRITE |
1466 : internal::SUCCESS); | |
mlamouri (slow - plz ping)
2016/08/08 19:50:25
style: add { } when there is more than a line.
kdsilva
2016/08/09 10:56:26
Done.
| |
1459 return corrected_url.ReplaceComponents(r); | 1467 return corrected_url.ReplaceComponents(r); |
1460 } | 1468 } |
OLD | NEW |