Implement protocol.isHandledProtocol

This commit is contained in:
Cheng Zhao 2015-08-13 19:33:53 +08:00
parent 05fd81ebdc
commit 374d83ed9c
2 changed files with 22 additions and 2 deletions

View file

@ -56,7 +56,8 @@ mate::ObjectTemplateBuilder Protocol::GetObjectTemplateBuilder(
&Protocol::RegisterProtocol<UrlRequestAsyncAsarJob>)
.SetMethod("registerHttpProtocol",
&Protocol::RegisterProtocol<URLRequestFetchJob>)
.SetMethod("unregisterProtocol", &Protocol::UnregisterProtocol);
.SetMethod("unregisterProtocol", &Protocol::UnregisterProtocol)
.SetMethod("isHandledProtocol", &Protocol::IsHandledProtocol);
}
void Protocol::RegisterStandardSchemes(
@ -84,6 +85,19 @@ Protocol::ProtocolError Protocol::UnregisterProtocolInIO(
return PROTOCOL_OK;
}
void Protocol::IsHandledProtocol(const std::string& scheme,
const BooleanCallback& callback) {
content::BrowserThread::PostTaskAndReplyWithResult(
content::BrowserThread::IO, FROM_HERE,
base::Bind(&Protocol::IsHandledProtocolInIO,
base::Unretained(this), scheme),
callback);
}
bool Protocol::IsHandledProtocolInIO(const std::string& scheme) {
return job_factory_->IsHandledProtocol(scheme);
}
void Protocol::OnIOCompleted(
const CompletionCallback& callback, ProtocolError error) {
// The completion callback is optional.