{"action":"created","issue":{"url":"https://api.github.com/repos/frankhale/toby/issues/45","labels_url":"https://api.github.com/repos/frankhale/toby/issues/45/labels{/name}","comments_url":"https://api.github.com/repos/frankhale/toby/issues/45/comments","events_url":"https://api.github.com/repos/frankhale/toby/issues/45/events","html_url":"https://github.com/frankhale/toby/issues/45","id":95059891,"number":45,"title":"Info: Libchromiumcontent / Chromium patch to override HTTP referrer for all requests","user":{"login":"frankhale","id":190154,"avatar_url":"https://avatars.githubusercontent.com/u/190154?v=3","gravatar_id":"","url":"https://api.github.com/users/frankhale","html_url":"https://github.com/frankhale","followers_url":"https://api.github.com/users/frankhale/followers","following_url":"https://api.github.com/users/frankhale/following{/other_user}","gists_url":"https://api.github.com/users/frankhale/gists{/gist_id}","starred_url":"https://api.github.com/users/frankhale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frankhale/subscriptions","organizations_url":"https://api.github.com/users/frankhale/orgs","repos_url":"https://api.github.com/users/frankhale/repos","events_url":"https://api.github.com/users/frankhale/events{/privacy}","received_events_url":"https://api.github.com/users/frankhale/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/frankhale/toby/labels/documentation","name":"documentation","color":"5319e7"},{"url":"https://api.github.com/repos/frankhale/toby/labels/up-for-grabs","name":"up-for-grabs","color":"eb6420"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-14T22:49:40Z","updated_at":"2015-07-31T15:20:00Z","closed_at":"2015-07-31T15:20:00Z","body":"This needs to be put in either the README or some other doc file so that it's easily found for those wanting to do this themselves. I'd like to eventually get this put into libchromiumcontent upstream.\r\n\r\nTL;DR - VEVO videos will be blocked because the HTTP referrer is not set. The following patch will resolve that issue. Note that this is different than setting the HTTP referrer in a webview which Electron already supports. This overrides it for all requests so things like the YouTube iframe API will work nicely with an overridden referrer.\r\n\r\nThis adds a new switch called --override-http-referrer which will allow you to override the HTTP referrer for all requests.\r\n\r\nPatch the SetReferrer function like so in the Chromium source:\r\n\r\nlocation in Chromium source: net\\url_request\\url_request.cc\r\n\r\nNOTE: This requires compling libchromiumcontent and then building Electron against it. Once you run python script\\update on libchromiumcontent and it downloads and extracts the Chrome source code you can patch the file and then run the build.\r\n\r\nNOTE: I've added the switch inline here for now but really want to put it in base\\base_switches.h|.cc (eventually) but I got unresolved symbols doing that. I tried for several hours to track it down but couldn't figure it out yet.  No idea what is going on so I dug into the gyp files but couldn't find a resolution yet. \r\n\r\n```cpp\r\n#include \"base/command_line.h\"\r\n\r\n...\r\n\r\nvoid URLRequest::SetReferrer(const std::string& referrer) {\r\n  DCHECK(!is_pending_);\r\n\r\n  std::string _referrer = referrer;\r\n  const std::string& override_http_referrer_switch = \"override-http-referrer\";\r\n  auto command_line = base::CommandLine::ForCurrentProcess();\r\n\r\n  if(command_line->HasSwitch(override_http_referrer_switch)) {\r\n    _referrer = command_line->GetSwitchValueASCII(\r\n      override_http_referrer_switch);\r\n  }\r\n\r\n  GURL referrer_url(_referrer);\r\n  if (referrer_url.is_valid()) {\r\n    referrer_ = referrer_url.GetAsReferrer().spec();\r\n  } else {\r\n    referrer_ = referrer;\r\n  }\r\n}\r\n```\r\n\r\nusage:\r\n\r\n```\r\nelectron.exe --override-http-referrer=http://foobar.com\r\n```\r\n\r\nOr use the Electron API to set the switch in your app."},"comment":{"url":"https://api.github.com/repos/frankhale/toby/issues/comments/126723224","html_url":"https://github.com/frankhale/toby/issues/45#issuecomment-126723224","issue_url":"https://api.github.com/repos/frankhale/toby/issues/45","id":126723224,"user":{"login":"frankhale","id":190154,"avatar_url":"https://avatars.githubusercontent.com/u/190154?v=3","gravatar_id":"","url":"https://api.github.com/users/frankhale","html_url":"https://github.com/frankhale","followers_url":"https://api.github.com/users/frankhale/followers","following_url":"https://api.github.com/users/frankhale/following{/other_user}","gists_url":"https://api.github.com/users/frankhale/gists{/gist_id}","starred_url":"https://api.github.com/users/frankhale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frankhale/subscriptions","organizations_url":"https://api.github.com/users/frankhale/orgs","repos_url":"https://api.github.com/users/frankhale/repos","events_url":"https://api.github.com/users/frankhale/events{/privacy}","received_events_url":"https://api.github.com/users/frankhale/received_events","type":"User","site_admin":false},"created_at":"2015-07-31T15:20:00Z","updated_at":"2015-07-31T15:20:00Z","body":"I've started a build document that is in the docs folder. I've copied what is here there. \r\n\r\nClosed via af8a493d1daaf91b93702eb519917e5db5e0a2af"}}