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 // TODO(kdsilva) | |
1395 bool ChromeContentRendererClient::OverrideEmbedInfo(std::string* url) { | |
1396 GURL gurl = GURL(*url); | |
1397 | |
1398 if (url->find("enablejsapi=1") == (size_t) -1 && | |
1399 gurl.DomainIs("www.youtube.com") && gurl.path().find("/v/") == 0) { | |
mlamouri (slow - plz ping)
2016/07/20 13:22:02
Could this be "youtube.com" instead of "www.youtub
kdsilva
2016/07/21 13:59:45
Done.
| |
1400 | |
1401 // If the website is using an invalid YouTube URL, we'll try and | |
1402 // fix the url by ensuring that IF there are multiple parameters, | |
1403 // the parameter string begins with a "?" and then follows with "&" | |
1404 // for each subsequent parameter. | |
1405 size_t indexAmp = url->find("&"); | |
1406 bool invalidUrl = false; | |
mlamouri (slow - plz ping)
2016/07/20 13:22:02
nit: maybe have the `bool` first.
kdsilva
2016/07/21 13:59:45
Done.
| |
1407 size_t indexQm = url->find("?"); | |
1408 | |
1409 if (indexQm == std::string::npos || indexQm > indexAmp) { | |
mlamouri (slow - plz ping)
2016/07/20 13:22:02
Does this mean that "www.youtube.com/v/VIDEO_ID" i
kdsilva
2016/07/21 13:59:45
You're right that youtube.com/v/ID should't be con
| |
1410 invalidUrl = true; | |
1411 } | |
mlamouri (slow - plz ping)
2016/07/20 13:22:02
style: we [unfortunately] don't put { } for one-li
kdsilva
2016/07/21 13:59:45
Done.
| |
1412 | |
1413 if (invalidUrl) { | |
1414 // Replace all instances of ? with & | |
1415 size_t start_pos = 0; | |
1416 while((start_pos = url->find("?", start_pos)) != std::string::npos) { | |
1417 url->replace(start_pos, 1, "&"); | |
1418 start_pos += 1; | |
1419 } | |
1420 | |
1421 // ? should appear first before all parameters | |
1422 if (indexAmp != std::string::npos) { | |
1423 url->replace(indexAmp, 1, "?"); | |
1424 } | |
1425 } | |
1426 url->replace(url->find("/v/"), 3, "/embed/"); | |
1427 return true; | |
1428 } | |
mlamouri (slow - plz ping)
2016/07/20 13:22:02
nit: you should favour early returns. In this case
kdsilva
2016/07/21 13:59:45
Done.
| |
1429 | |
1430 return false; | |
1431 } | |
OLD | NEW |