feat: add net.online / net.isOnline() (#21004)
This commit is contained in:
parent
1ef803d2ea
commit
df1432a315
5 changed files with 47 additions and 1 deletions
|
@ -5,6 +5,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "gin/handle.h"
|
||||
#include "net/base/network_change_notifier.h"
|
||||
#include "services/network/public/cpp/features.h"
|
||||
#include "shell/browser/api/electron_api_url_loader.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
|
@ -14,6 +15,10 @@
|
|||
|
||||
namespace {
|
||||
|
||||
bool IsOnline() {
|
||||
return !net::NetworkChangeNotifier::IsOffline();
|
||||
}
|
||||
|
||||
bool IsValidHeaderName(std::string header_name) {
|
||||
return net::HttpUtil::IsValidHeaderName(header_name);
|
||||
}
|
||||
|
@ -31,6 +36,7 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
v8::Isolate* isolate = context->GetIsolate();
|
||||
|
||||
gin_helper::Dictionary dict(isolate, exports);
|
||||
dict.SetMethod("isOnline", &IsOnline);
|
||||
dict.SetMethod("isValidHeaderName", &IsValidHeaderName);
|
||||
dict.SetMethod("isValidHeaderValue", &IsValidHeaderValue);
|
||||
dict.SetMethod("createURLLoader", &SimpleURLLoaderWrapper::Create);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue