1717#include " content/public/common/pepper_plugin_info.h"
1818#include " content/public/common/user_agent.h"
1919#include " ppapi/shared_impl/ppapi_permissions.h"
20+ #include " url/url_constants.h"
2021
2122namespace atom {
2223
@@ -62,6 +63,17 @@ content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path,
6263 return plugin;
6364}
6465
66+ void ConvertStringWithSeparatorToVector (std::vector<std::string>* vec,
67+ const char * separator,
68+ const char * cmd_switch) {
69+ auto command_line = base::CommandLine::ForCurrentProcess ();
70+ auto string_with_separator = command_line->GetSwitchValueASCII (cmd_switch);
71+ if (!string_with_separator.empty ())
72+ *vec = base::SplitString (string_with_separator, separator,
73+ base::TRIM_WHITESPACE,
74+ base::SPLIT_WANT_NONEMPTY);
75+ }
76+
6577} // namespace
6678
6779AtomContentClient::AtomContentClient () {
@@ -83,12 +95,10 @@ std::string AtomContentClient::GetUserAgent() const {
8395void AtomContentClient::AddAdditionalSchemes (
8496 std::vector<url::SchemeWithType>* standard_schemes,
8597 std::vector<std::string>* savable_schemes) {
86- auto command_line = base::CommandLine::ForCurrentProcess ();
87- auto custom_schemes = command_line->GetSwitchValueASCII (
88- switches::kRegisterStandardSchemes );
89- if (!custom_schemes.empty ()) {
90- std::vector<std::string> schemes = base::SplitString (
91- custom_schemes, " ," , base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
98+ std::vector<std::string> schemes;
99+ ConvertStringWithSeparatorToVector (&schemes, " ," ,
100+ switches::kRegisterStandardSchemes );
101+ if (!schemes.empty ()) {
92102 for (const std::string& scheme : schemes)
93103 standard_schemes->push_back ({scheme.c_str (), url::SCHEME_WITHOUT_PORT});
94104 }
@@ -110,4 +120,16 @@ void AtomContentClient::AddPepperPlugins(
110120 CreatePepperFlashInfo (flash_path, flash_version));
111121}
112122
123+ void AtomContentClient::AddServiceWorkerSchemes (
124+ std::set<std::string>* service_worker_schemes) {
125+ std::vector<std::string> schemes;
126+ ConvertStringWithSeparatorToVector (&schemes, " ," ,
127+ switches::kRegisterServiceWorkerSchemes );
128+ if (!schemes.empty ()) {
129+ for (const std::string& scheme : schemes)
130+ service_worker_schemes->insert (scheme);
131+ }
132+ service_worker_schemes->insert (url::kFileScheme );
133+ }
134+
113135} // namespace atom
0 commit comments