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 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1383 // chrome.system.network.getNetworkInterfaces provides the same | 1383 // chrome.system.network.getNetworkInterfaces provides the same |
| 1384 // information. Also, the enforcement of sending and binding UDP is already done | 1384 // information. Also, the enforcement of sending and binding UDP is already done |
| 1385 // by chrome extension permission model. | 1385 // by chrome extension permission model. |
| 1386 bool ChromeContentRendererClient::ShouldEnforceWebRTCRoutingPreferences() { | 1386 bool ChromeContentRendererClient::ShouldEnforceWebRTCRoutingPreferences() { |
| 1387 #if defined(ENABLE_EXTENSIONS) | 1387 #if defined(ENABLE_EXTENSIONS) |
| 1388 return !IsStandaloneExtensionProcess(); | 1388 return !IsStandaloneExtensionProcess(); |
| 1389 #else | 1389 #else |
| 1390 return true; | 1390 return true; |
| 1391 #endif | 1391 #endif |
| 1392 } | 1392 } |
| 1393 | |
| 1394 std::string ChromeContentRendererClient::OverrideFlashEmbedWithHTML( | |
| 1395 const std::string& url) { | |
| 1396 | |
|
mlamouri (slow - plz ping)
2016/07/21 15:55:07
style: remove empty line
kdsilva
2016/07/22 13:55:57
Done.
| |
| 1397 GURL gurl = GURL(url); | |
|
mlamouri (slow - plz ping)
2016/07/21 15:55:07
nit: I would call the `url` you get as param `str_
kdsilva
2016/07/22 13:55:57
Done.
| |
| 1398 | |
|
mlamouri (slow - plz ping)
2016/07/21 15:55:07
nit: you could add `DCHECK(url.isValid())` so it g
kdsilva
2016/07/22 13:55:57
Done.
| |
| 1399 std::string retUrl = url; | |
|
mlamouri (slow - plz ping)
2016/07/21 15:55:07
This should move after the early return so we avoi
kdsilva
2016/07/22 13:55:57
Done.
| |
| 1400 | |
| 1401 if (!gurl.DomainIs("youtube.com") || gurl.path().find("/v/") != 0 | |
|
mlamouri (slow - plz ping)
2016/07/21 15:55:07
Maybe add a comment explaining why these checks? :
kdsilva
2016/07/22 13:55:57
Done.
| |
| 1402 || retUrl.find("enablejsapi=1") != (size_t) -1) | |
|
mlamouri (slow - plz ping)
2016/07/21 15:55:07
`(size_t) -1` should be `string::npos`, right?
kdsilva
2016/07/22 13:55:57
Yup! My bad.
| |
| 1403 return ""; | |
| 1404 | |
| 1405 // If the website is using an invalid YouTube URL, we'll try and | |
| 1406 // fix the URL by ensuring that IF there are multiple parameters, | |
| 1407 // the parameter string begins with a "?" and then follows with "&" | |
| 1408 // for each subsequent parameter. | |
| 1409 bool invalidUrl = false; | |
| 1410 size_t indexAmp = retUrl.find("&"); | |
| 1411 size_t indexQm = retUrl.find("?"); | |
| 1412 | |
| 1413 // URLs are considered invalid if a "&" appears before a "?", however either | |
| 1414 // a "?" or a "&" must exist in the URL. | |
| 1415 if (indexQm >= indexAmp && | |
| 1416 (indexAmp != std::string::npos || indexQm != std::string::npos)) | |
|
mlamouri (slow - plz ping)
2016/07/21 15:55:07
What about using std::string::find_first_of? http:
kdsilva
2016/07/22 13:55:57
Wow, that is a much better way of doing it than wh
| |
| 1417 invalidUrl = true; | |
| 1418 | |
| 1419 if (invalidUrl) { | |
| 1420 // Replace all instances of ? with & | |
| 1421 size_t start_pos = 0; | |
| 1422 while((start_pos = retUrl.find("?", start_pos)) != std::string::npos) { | |
| 1423 retUrl.replace(start_pos, 1, "&"); | |
| 1424 start_pos += 1; | |
| 1425 } | |
| 1426 | |
| 1427 // ? should appear first before all parameters | |
| 1428 if (indexAmp != std::string::npos) { | |
| 1429 retUrl.replace(indexAmp, 1, "?"); | |
| 1430 } | |
| 1431 } | |
| 1432 retUrl.replace(retUrl.find("/v/"), 3, "/embed/"); | |
|
mlamouri (slow - plz ping)
2016/07/21 15:55:07
Could we do this before? Like just after we know i
kdsilva
2016/07/22 13:55:57
Done.
| |
| 1433 return retUrl; | |
| 1434 } | |
| OLD | NEW |