chore: remove native_mate (Part 7) (#20561)

* refactor: use gin converters in api::Protocol

* refactor: convert JS constructor impl to gin

* refactor: use InitWithArgs helper

* fix: gin_helper::Dictionary should behave the same with mate

* fix cpplint warnings

* refactor: no more need to patch gin/dictionary.h
This commit is contained in:
Cheng Zhao 2019-10-15 10:15:23 +09:00 committed by GitHub
parent 6c6bff81ac
commit 1ecfcc8c70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 274 additions and 368 deletions

View file

@ -57,15 +57,9 @@ namespace electron {
namespace api {
BrowserView::BrowserView(v8::Isolate* isolate,
v8::Local<v8::Object> wrapper,
BrowserView::BrowserView(gin::Arguments* args,
const mate::Dictionary& options) {
Init(isolate, wrapper, options);
}
void BrowserView::Init(v8::Isolate* isolate,
v8::Local<v8::Object> wrapper,
const mate::Dictionary& options) {
v8::Isolate* isolate = args->isolate();
mate::Dictionary web_preferences = mate::Dictionary::CreateEmpty(isolate);
options.Get(options::kWebPreferences, &web_preferences);
web_preferences.Set("type", "browserView");
@ -79,7 +73,7 @@ void BrowserView::Init(v8::Isolate* isolate,
view_.reset(
NativeBrowserView::Create(api_web_contents_->managed_web_contents()));
InitWith(isolate, wrapper);
InitWithArgs(args);
}
BrowserView::~BrowserView() {
@ -96,16 +90,17 @@ void BrowserView::WebContentsDestroyed() {
}
// static
mate::WrappableBase* BrowserView::New(mate::Arguments* args) {
mate::WrappableBase* BrowserView::New(gin_helper::ErrorThrower thrower,
gin::Arguments* args) {
if (!Browser::Get()->is_ready()) {
args->ThrowError("Cannot create BrowserView before app is ready");
thrower.ThrowError("Cannot create BrowserView before app is ready");
return nullptr;
}
mate::Dictionary options = mate::Dictionary::CreateEmpty(args->isolate());
args->GetNext(&options);
return new BrowserView(args->isolate(), args->GetThis(), options);
return new BrowserView(args, options);
}
int32_t BrowserView::ID() const {