Merge pull request #1970 from deepak1556/scheme_patch

protocol: api to register custom schemes to standard schemes
This commit is contained in:
Cheng Zhao 2015-06-19 16:16:46 +08:00
commit 49e1316f7f
8 changed files with 47 additions and 0 deletions

View file

@ -4,6 +4,7 @@
#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/atom_browser_main_parts.h"
#include "atom/browser/net/adapter_request_job.h"
@ -207,6 +208,7 @@ mate::ObjectTemplateBuilder Protocol::GetObjectTemplateBuilder(
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);
@ -239,6 +241,11 @@ void Protocol::UnregisterProtocol(v8::Isolate* isolate,
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);
}

View file

@ -7,6 +7,7 @@
#include <string>
#include <map>
#include <vector>
#include "atom/browser/api/event_emitter.h"
#include "base/callback.h"
@ -45,6 +46,9 @@ class Protocol : public mate::EventEmitter {
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,