Don't rely on AddAdditionalSchemes for setting standard schemes

On Linux because of the existence of zygote process, it becomes very
tricky to correctly set standard schemes, basically we have to:
1. Pass --standard-schemes to both zygote and render processes
2. Init standard schemes for both zygote and render processes

The )1 is very hard to achieve, so instead of using
AddAdditionalSchemes, we just call url::AddStandardScheme directly.
This commit is contained in:
Cheng Zhao 2016-06-08 16:27:16 +09:00
parent 7108cc5f2b
commit 1bfbd215ea
2 changed files with 10 additions and 14 deletions

View file

@ -181,20 +181,6 @@ void AtomContentClient::AddAdditionalSchemes(
std::vector<url::SchemeWithType>* standard_schemes,
std::vector<url::SchemeWithType>* referrer_schemes,
std::vector<std::string>* savable_schemes) {
// Parse --standard-schemes=scheme1,scheme2
auto command_line = base::CommandLine::ForCurrentProcess();
std::string custom_schemes = command_line->GetSwitchValueASCII(
switches::kStandardSchemes);
if (!custom_schemes.empty()) {
// Note that url::SchemeWithType requires passing const char*, so we have
// to ensure the string still lives after this function exits.
static std::vector<std::string> schemes_list;
schemes_list = base::SplitString(
custom_schemes, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
for (const std::string& scheme : schemes_list)
standard_schemes->push_back({scheme.c_str(), url::SCHEME_WITHOUT_PORT});
}
standard_schemes->push_back({"chrome-extension", url::SCHEME_WITHOUT_PORT});
}

View file

@ -122,6 +122,16 @@ bool IsDevToolsExtension(content::RenderFrame* render_frame) {
AtomRendererClient::AtomRendererClient()
: node_bindings_(NodeBindings::Create(false)),
atom_bindings_(new AtomBindings) {
// Parse --standard-schemes=scheme1,scheme2
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
std::string custom_schemes = command_line->GetSwitchValueASCII(
switches::kStandardSchemes);
if (!custom_schemes.empty()) {
std::vector<std::string> schemes_list = base::SplitString(
custom_schemes, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
for (const std::string& scheme : schemes_list)
url::AddStandardScheme(scheme.c_str(), url::SCHEME_WITHOUT_PORT);
}
}
AtomRendererClient::~AtomRendererClient() {