void AtomContentClient::AddAdditionalSchemes(
std::vector<std::string>* standard_schemes,
std::vector<std::string>* savable_schemes) {
+ auto command_line = base::CommandLine::ForCurrentProcess();
+ auto custom_schemes = command_line->GetSwitchValueASCII(
+ switches::kRegisterStandardSchemes);
+ if (!custom_schemes.empty()) {
+ std::vector<std::string> schemes;
+ base::SplitString(custom_schemes, ',', &schemes);
+ standard_schemes->insert(standard_schemes->end(),
+ schemes.begin(),
+ schemes.end());
+ }
standard_schemes->push_back("chrome-extension");
}
#include "atom/browser/api/atom_api_protocol.h"
+#include "atom/browser/atom_browser_client.h"
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/net/adapter_request_job.h"
#include "atom/browser/net/atom_url_request_job_factory.h"
return mate::ObjectTemplateBuilder(isolate)
.SetMethod("registerProtocol", &Protocol::RegisterProtocol)
.SetMethod("unregisterProtocol", &Protocol::UnregisterProtocol)
+ .SetMethod("registerStandardSchemes", &Protocol::RegisterStandardSchemes)
.SetMethod("isHandledProtocol", &Protocol::IsHandledProtocol)
.SetMethod("interceptProtocol", &Protocol::InterceptProtocol)
.SetMethod("uninterceptProtocol", &Protocol::UninterceptProtocol);
base::Unretained(this), scheme));
}
+void Protocol::RegisterStandardSchemes(
+ const std::vector<std::string>& schemes) {
+ atom::AtomBrowserClient::SetCustomSchemes(schemes);
+}
+
bool Protocol::IsHandledProtocol(const std::string& scheme) {
return job_factory_->IsHandledProtocol(scheme);
}
#include <string>
#include <map>
+#include <vector>
#include "atom/browser/api/event_emitter.h"
#include "base/callback.h"
private:
typedef std::map<std::string, JsProtocolHandler> ProtocolHandlersMap;
+ // Register schemes to standard scheme list.
+ void RegisterStandardSchemes(const std::vector<std::string>& schemes);
+
// Register/unregister an networking |scheme| which would be handled by
// |callback|.
void RegisterProtocol(v8::Isolate* isolate,
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_util.h"
#include "chrome/browser/printing/printing_message_filter.h"
#include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
#include "chrome/browser/speech/tts_message_filter.h"
// Next navigation should not restart renderer process.
bool g_suppress_renderer_process_restart = false;
+// Custom schemes to be registered to standard.
+std::string g_custom_schemes = "";
+
// Find out the owner of the child process according to |process_id|.
enum ProcessOwner {
OWNER_NATIVE_WINDOW,
g_suppress_renderer_process_restart = true;
}
+void AtomBrowserClient::SetCustomSchemes(
+ const std::vector<std::string>& schemes) {
+ g_custom_schemes = JoinString(schemes, ',');
+}
+
AtomBrowserClient::AtomBrowserClient() {
}
base::CommandLine* command_line,
int process_id) {
std::string process_type = command_line->GetSwitchValueASCII("type");
+
if (process_type != "renderer")
return;
+ command_line->AppendSwitchASCII(switches::kRegisterStandardSchemes,
+ g_custom_schemes);
+
NativeWindow* window;
WebViewManager::WebViewInfo info;
ProcessOwner owner = GetProcessOwner(process_id, &window, &info);
#define ATOM_BROWSER_ATOM_BROWSER_CLIENT_H_
#include <string>
+#include <vector>
#include "brightray/browser/browser_client.h"
// Don't force renderer process to restart for once.
static void SuppressRendererProcessRestartForOnce();
+ // Custom schemes to be registered to standard.
+ static void SetCustomSchemes(const std::vector<std::string>& schemes);
protected:
// content::ContentBrowserClient:
// Disable HTTP cache.
const char kDisableHttpCache[] = "disable-http-cache";
+// Register schemes to standard.
+const char kRegisterStandardSchemes[] = "register-standard-schemes";
+
} // namespace switches
} // namespace atom
extern const char kPageVisibility[];
extern const char kDisableHttpCache[];
+extern const char kRegisterStandardSchemes[];
} // namespace switches
Unregisters the custom protocol of `scheme`.
+## protocol.registerStandardSchemes(value)
+
+* `value` Array
+
+`value` is an array of custom schemes to be registered to the standard.
+
## protocol.isHandledProtocol(scheme)
* `scheme` String