chore: remove native_mate (Part 12) (#20869)

* refactor: move mate::Event to gin

* refactor: move mate::Locker to gin

* refactor: convert contextBridge to gin

* refactor: convert contentTracing to gin

* refactor: remove callback converter of native_mate

* refactor: remove file_dialog_converter and native_window_converter from native_mate

* refactor: convert webFrame to gin

* refactor: move blink_converter to gin

* refactor: remove net_converter from native_mate

* refactor: remove event_emitter_caller_deprecated

* refactor: remove gurl_converter from native_mate

* refactor: remove file_path and string16_converter from native_mate

* refactor: remove image_converter from native_mate

* refactor: move value_converter to gin
This commit is contained in:
Cheng Zhao 2019-10-31 16:56:00 +09:00 committed by GitHub
parent 6781d5e3c8
commit 3ae3233e65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
96 changed files with 622 additions and 1711 deletions

View file

@ -48,7 +48,7 @@
#include "shell/common/gin_converters/gurl_converter.h"
#include "shell/common/gin_converters/image_converter.h"
#include "shell/common/gin_converters/net_converter.h"
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/node_includes.h"

View file

@ -18,7 +18,7 @@
#include "shell/browser/window_list.h"
#include "shell/common/api/constructor.h"
#include "shell/common/color_util.h"
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/node_includes.h"

View file

@ -6,21 +6,20 @@
#include <string>
#include <utility>
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/optional.h"
#include "base/threading/thread_restrictions.h"
#include "content/public/browser/tracing_controller.h"
#include "native_mate/dictionary.h"
#include "shell/common/native_mate_converters/callback_converter_deprecated.h"
#include "shell/common/native_mate_converters/file_path_converter.h"
#include "shell/common/native_mate_converters/value_converter.h"
#include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_converters/file_path_converter.h"
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/node_includes.h"
#include "shell/common/promise_util.h"
using content::TracingController;
namespace mate {
namespace gin {
template <>
struct Converter<base::trace_event::TraceConfig> {
@ -31,7 +30,7 @@ struct Converter<base::trace_event::TraceConfig> {
// has to be checked first because none of the fields
// in the `memory_dump_config` dict below are mandatory
// and we cannot check the config format.
Dictionary options;
gin_helper::Dictionary options;
if (ConvertFromV8(isolate, val, &options)) {
std::string category_filter, trace_options;
if (options.Get("categoryFilter", &category_filter) &&
@ -51,7 +50,7 @@ struct Converter<base::trace_event::TraceConfig> {
}
};
} // namespace mate
} // namespace gin
namespace {
@ -79,7 +78,7 @@ void StopTracing(electron::util::Promise<base::FilePath> promise,
}
}
v8::Local<v8::Promise> StopRecording(mate::Arguments* args) {
v8::Local<v8::Promise> StopRecording(gin_helper::Arguments* args) {
electron::util::Promise<base::FilePath> promise(args->isolate());
v8::Local<v8::Promise> handle = promise.GetHandle();
@ -131,18 +130,18 @@ v8::Local<v8::Promise> StartTracing(
}
void OnTraceBufferUsageAvailable(
electron::util::Promise<mate::Dictionary> promise,
electron::util::Promise<gin_helper::Dictionary> promise,
float percent_full,
size_t approximate_count) {
mate::Dictionary dict = mate::Dictionary::CreateEmpty(promise.isolate());
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(promise.isolate());
dict.Set("percentage", percent_full);
dict.Set("value", approximate_count);
promise.Resolve(dict);
promise.ResolveWithGin(dict);
}
v8::Local<v8::Promise> GetTraceBufferUsage(v8::Isolate* isolate) {
electron::util::Promise<mate::Dictionary> promise(isolate);
electron::util::Promise<gin_helper::Dictionary> promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
// Note: This method always succeeds.
@ -155,7 +154,7 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
gin_helper::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("getCategories", &GetCategories);
dict.SetMethod("startRecording", &StartTracing);
dict.SetMethod("stopRecording", &StopRecording);

View file

@ -21,7 +21,7 @@
#include "shell/browser/atom_browser_context.h"
#include "shell/browser/cookie_change_notifier.h"
#include "shell/common/gin_converters/gurl_converter.h"
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/object_template_builder.h"

View file

@ -12,7 +12,7 @@
#include "base/json/json_writer.h"
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/web_contents.h"
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/node_includes.h"
@ -80,7 +80,7 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
if (dict->GetDictionary("result", &result_body)) {
result.Swap(result_body);
}
promise.Resolve(result);
promise.ResolveWithGin(result);
}
}
}

View file

@ -20,7 +20,7 @@ void Initialize(v8::Local<v8::Object> exports,
void* priv) {
gin_helper::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("createWithSender", &CreateWithSender);
dict.SetMethod("createEmpty", &mate::Event::Create);
dict.SetMethod("createEmpty", &gin_helper::Event::Create);
}
} // namespace

View file

@ -12,7 +12,7 @@
#include "gin/arguments.h"
#include "shell/browser/api/atom_api_top_level_window.h"
#include "shell/browser/ui/atom_menu_model.h"
#include "shell/common/api/locker.h"
#include "shell/common/gin_helper/locker.h"
#include "shell/common/gin_helper/trackable_object.h"
namespace electron {

View file

@ -56,7 +56,7 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
int y,
int positioning_item,
base::Closure callback) {
mate::Locker locker(isolate());
gin_helper::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
if (!native_window)

View file

@ -25,7 +25,7 @@ void MenuViews::PopupAt(TopLevelWindow* window,
int y,
int positioning_item,
const base::Closure& callback) {
mate::Locker locker(isolate());
gin_helper::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
auto* native_window = static_cast<NativeWindowViews*>(window->window());

View file

@ -57,7 +57,7 @@
#include "shell/common/gin_converters/file_path_converter.h"
#include "shell/common/gin_converters/gurl_converter.h"
#include "shell/common/gin_converters/net_converter.h"
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/node_includes.h"

View file

@ -5,7 +5,7 @@
#include "shell/browser/api/atom_api_system_preferences.h"
#include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/node_includes.h"

View file

@ -27,7 +27,7 @@
#include "shell/browser/ui/cocoa/NSColor+Hex.h"
#include "shell/common/deprecate_util.h"
#include "shell/common/gin_converters/gurl_converter.h"
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
#include "shell/common/gin_converters/value_converter.h"
#include "ui/native_theme/native_theme.h"
namespace gin {

View file

@ -5,11 +5,11 @@
#include "shell/browser/api/atom_api_top_level_window.h"
#include <string>
#include <utility>
#include <vector>
#include "electron/buildflags/buildflags.h"
#include "gin/dictionary.h"
#include "native_mate/persistent_dictionary.h"
#include "shell/browser/api/atom_api_browser_view.h"
#include "shell/browser/api/atom_api_menu.h"
#include "shell/browser/api/atom_api_view.h"
@ -20,9 +20,10 @@
#include "shell/common/gin_converters/gfx_converter.h"
#include "shell/common/gin_converters/image_converter.h"
#include "shell/common/gin_converters/native_window_converter.h"
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/gin_helper/persistent_dictionary.h"
#include "shell/common/node_includes.h"
#include "shell/common/options_switches.h"
@ -809,8 +810,8 @@ void TopLevelWindow::SetVibrancy(v8::Isolate* isolate,
}
void TopLevelWindow::SetTouchBar(
const std::vector<mate::PersistentDictionary>& items) {
window_->SetTouchBar(items);
std::vector<gin_helper::PersistentDictionary> items) {
window_->SetTouchBar(std::move(items));
}
void TopLevelWindow::RefreshTouchBarItem(const std::string& item_id) {
@ -818,8 +819,8 @@ void TopLevelWindow::RefreshTouchBarItem(const std::string& item_id) {
}
void TopLevelWindow::SetEscapeTouchBarItem(
const mate::PersistentDictionary& item) {
window_->SetEscapeTouchBarItem(item);
gin_helper::PersistentDictionary item) {
window_->SetEscapeTouchBarItem(std::move(item));
}
void TopLevelWindow::SelectPreviousTab() {

View file

@ -184,9 +184,9 @@ class TopLevelWindow : public gin_helper::TrackableObject<TopLevelWindow>,
bool IsVisibleOnAllWorkspaces();
void SetAutoHideCursor(bool auto_hide);
virtual void SetVibrancy(v8::Isolate* isolate, v8::Local<v8::Value> value);
void SetTouchBar(const std::vector<mate::PersistentDictionary>& items);
void SetTouchBar(std::vector<gin_helper::PersistentDictionary> items);
void RefreshTouchBarItem(const std::string& item_id);
void SetEscapeTouchBarItem(const mate::PersistentDictionary& item);
void SetEscapeTouchBarItem(gin_helper::PersistentDictionary item);
void SelectPreviousTab();
void SelectNextTab();
void MergeAllWindows();

View file

@ -70,7 +70,7 @@
#include "shell/browser/web_view_guest_delegate.h"
#include "shell/common/api/atom_api_native_image.h"
#include "shell/common/color_util.h"
#include "shell/common/gin_converters/blink_converter_gin_adapter.h"
#include "shell/common/gin_converters/blink_converter.h"
#include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_converters/content_converter.h"
#include "shell/common/gin_converters/file_path_converter.h"
@ -78,7 +78,7 @@
#include "shell/common/gin_converters/gurl_converter.h"
#include "shell/common/gin_converters/image_converter.h"
#include "shell/common/gin_converters/net_converter.h"
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/mouse_util.h"
@ -1023,7 +1023,7 @@ void WebContents::Message(bool internal,
blink::CloneableMessage arguments) {
// webContents.emit('-ipc-message', new Event(), internal, channel,
// arguments);
EmitWithSender("-ipc-message", bindings_.dispatch_context(), base::nullopt,
EmitWithSender("-ipc-message", bindings_.dispatch_context(), InvokeCallback(),
internal, channel, std::move(arguments));
}
@ -1064,7 +1064,7 @@ void WebContents::MessageHost(const std::string& channel,
blink::CloneableMessage arguments) {
// webContents.emit('ipc-message-host', new Event(), channel, args);
EmitWithSender("ipc-message-host", bindings_.dispatch_context(),
base::nullopt, channel, std::move(arguments));
InvokeCallback(), channel, std::move(arguments));
}
#if BUILDFLAG(ENABLE_REMOTE_MODULE)
@ -1075,7 +1075,7 @@ void WebContents::DereferenceRemoteJSObject(const std::string& context_id,
args.Append(context_id);
args.Append(object_id);
args.Append(ref_count);
EmitWithSender("-ipc-message", bindings_.dispatch_context(), base::nullopt,
EmitWithSender("-ipc-message", bindings_.dispatch_context(), InvokeCallback(),
/* internal */ true, "ELECTRON_BROWSER_DEREFERENCE",
std::move(args));
}
@ -2071,10 +2071,10 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
content::RenderWidgetHost* rwh = view->GetRenderWidgetHost();
blink::WebInputEvent::Type type =
mate::GetWebInputEventType(isolate, input_event);
gin::GetWebInputEventType(isolate, input_event);
if (blink::WebInputEvent::IsMouseEventType(type)) {
blink::WebMouseEvent mouse_event;
if (mate::ConvertFromV8(isolate, input_event, &mouse_event)) {
if (gin::ConvertFromV8(isolate, input_event, &mouse_event)) {
if (IsOffScreen()) {
#if BUILDFLAG(ENABLE_OSR)
GetOffScreenRenderWidgetHostView()->SendMouseEvent(mouse_event);
@ -2094,7 +2094,7 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
}
} else if (type == blink::WebInputEvent::kMouseWheel) {
blink::WebMouseWheelEvent mouse_wheel_event;
if (mate::ConvertFromV8(isolate, input_event, &mouse_wheel_event)) {
if (gin::ConvertFromV8(isolate, input_event, &mouse_wheel_event)) {
if (IsOffScreen()) {
#if BUILDFLAG(ENABLE_OSR)
GetOffScreenRenderWidgetHostView()->SendMouseWheelEvent(

View file

@ -20,7 +20,7 @@
#include "shell/common/gin_converters/gurl_converter.h"
#include "shell/common/gin_converters/net_converter.h"
#include "shell/common/gin_converters/std_converter.h"
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
#include "shell/common/gin_converters/value_converter.h"
namespace gin {

View file

@ -7,7 +7,7 @@
#include "shell/browser/web_contents_zoom_controller.h"
#include "shell/browser/web_view_manager.h"
#include "shell/common/gin_converters/content_converter.h"
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/node_includes.h"
#include "shell/common/options_switches.h"

View file

@ -6,26 +6,26 @@
#include <utility>
#include "native_mate/object_template_builder_deprecated.h"
#include "shell/common/native_mate_converters/blink_converter.h"
#include "gin/object_template_builder.h"
#include "shell/common/gin_converters/blink_converter.h"
namespace mate {
namespace gin_helper {
Event::Event(v8::Isolate* isolate) {
Init(isolate);
}
gin::WrapperInfo Event::kWrapperInfo = {gin::kEmbedderNativeGin};
Event::Event() {}
Event::~Event() = default;
void Event::SetCallback(base::Optional<InvokeCallback> callback) {
void Event::SetCallback(InvokeCallback callback) {
DCHECK(!callback_);
callback_ = std::move(callback);
}
void Event::PreventDefault(v8::Isolate* isolate) {
GetWrapper()
->Set(isolate->GetCurrentContext(),
StringToV8(isolate, "defaultPrevented"), v8::True(isolate))
v8::Local<v8::Object> self = GetWrapper(isolate).ToLocalChecked();
self->Set(isolate->GetCurrentContext(),
gin::StringToV8(isolate, "defaultPrevented"), v8::True(isolate))
.Check();
}
@ -34,27 +34,28 @@ bool Event::SendReply(v8::Isolate* isolate, v8::Local<v8::Value> result) {
return false;
blink::CloneableMessage message;
if (!ConvertFromV8(isolate, result, &message)) {
if (!gin::ConvertFromV8(isolate, result, &message)) {
return false;
}
std::move(*callback_).Run(std::move(message));
callback_.reset();
std::move(callback_).Run(std::move(message));
return true;
}
// static
Handle<Event> Event::Create(v8::Isolate* isolate) {
return mate::CreateHandle(isolate, new Event(isolate));
}
// static
void Event::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "Event"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
gin::ObjectTemplateBuilder Event::GetObjectTemplateBuilder(
v8::Isolate* isolate) {
return gin::Wrappable<Event>::GetObjectTemplateBuilder(isolate)
.SetMethod("preventDefault", &Event::PreventDefault)
.SetMethod("sendReply", &Event::SendReply);
}
} // namespace mate
const char* Event::GetTypeName() {
return "WebRequest";
}
// static
gin::Handle<Event> Event::Create(v8::Isolate* isolate) {
return gin::CreateHandle(isolate, new Event());
}
} // namespace gin_helper

View file

@ -5,27 +5,26 @@
#ifndef SHELL_BROWSER_API_EVENT_H_
#define SHELL_BROWSER_API_EVENT_H_
#include "base/optional.h"
#include "electron/shell/common/api/api.mojom.h"
#include "native_mate/handle.h"
#include "native_mate/wrappable.h"
#include "gin/handle.h"
#include "gin/wrappable.h"
namespace IPC {
class Message;
}
namespace mate {
namespace gin_helper {
class Event : public Wrappable<Event> {
class Event : public gin::Wrappable<Event> {
public:
using InvokeCallback = electron::mojom::ElectronBrowser::InvokeCallback;
static Handle<Event> Create(v8::Isolate* isolate);
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
static gin::WrapperInfo kWrapperInfo;
static gin::Handle<Event> Create(v8::Isolate* isolate);
// Pass the callback to be invoked.
void SetCallback(base::Optional<InvokeCallback> callback);
void SetCallback(InvokeCallback callback);
// event.PreventDefault().
void PreventDefault(v8::Isolate* isolate);
@ -35,16 +34,21 @@ class Event : public Wrappable<Event> {
bool SendReply(v8::Isolate* isolate, v8::Local<v8::Value> result);
protected:
explicit Event(v8::Isolate* isolate);
Event();
~Event() override;
// gin::Wrappable:
gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
v8::Isolate* isolate) override;
const char* GetTypeName() override;
private:
// Replyer for the synchronous messages.
base::Optional<InvokeCallback> callback_;
InvokeCallback callback_;
DISALLOW_COPY_AND_ASSIGN(Event);
};
} // namespace mate
} // namespace gin_helper
#endif // SHELL_BROWSER_API_EVENT_H_

View file

@ -11,6 +11,7 @@
#include "content/public/browser/browser_thread.h"
#include "gpu/config/gpu_info_collector.h"
#include "shell/browser/api/gpu_info_enumerator.h"
#include "shell/common/gin_converters/value_converter.h"
namespace electron {
@ -46,7 +47,7 @@ void GPUInfoManager::ProcessCompleteInfo() {
// We have received the complete information, resolve all promises that
// were waiting for this info.
for (auto& promise : complete_info_promise_set_) {
promise.Resolve(*result);
promise.ResolveWithGin(*result);
}
complete_info_promise_set_.clear();
}
@ -86,7 +87,7 @@ void GPUInfoManager::FetchBasicInfo(
util::Promise<base::DictionaryValue> promise) {
gpu::GPUInfo gpu_info;
CollectBasicGraphicsInfo(&gpu_info);
promise.Resolve(*EnumerateGPUInfo(gpu_info));
promise.ResolveWithGin(*EnumerateGPUInfo(gpu_info));
}
std::unique_ptr<base::DictionaryValue> GPUInfoManager::EnumerateGPUInfo(

View file

@ -12,7 +12,6 @@
#include "content/browser/gpu/gpu_data_manager_impl.h" // nogncheck
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/gpu_data_manager_observer.h"
#include "shell/common/native_mate_converters/value_converter.h"
#include "shell/common/promise_util.h"
namespace electron {

View file

@ -16,7 +16,7 @@
#include "base/time/time.h"
#include "gin/arguments.h"
#include "shell/browser/browser.h"
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h"

View file

@ -5,7 +5,9 @@
#include "shell/browser/login_handler.h"
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/task/post_task.h"
#include "base/values.h"
@ -13,13 +15,71 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
#include "net/base/auth.h"
#include "net/base/upload_bytes_element_reader.h"
#include "net/base/upload_data_stream.h"
#include "net/base/upload_element_reader.h"
#include "net/base/upload_file_element_reader.h"
#include "shell/browser/browser.h"
#include "shell/common/native_mate_converters/net_converter.h"
#include "shell/common/gin_converters/net_converter.h"
using content::BrowserThread;
namespace electron {
namespace {
void GetUploadData(base::ListValue* upload_data_list,
const net::URLRequest* request) {
const net::UploadDataStream* upload_data = request->get_upload_for_testing();
if (!upload_data)
return;
const std::vector<std::unique_ptr<net::UploadElementReader>>* readers =
upload_data->GetElementReaders();
for (const auto& reader : *readers) {
auto upload_data_dict = std::make_unique<base::DictionaryValue>();
if (reader->AsBytesReader()) {
const net::UploadBytesElementReader* bytes_reader =
reader->AsBytesReader();
auto bytes = std::make_unique<base::Value>(
std::vector<char>(bytes_reader->bytes(),
bytes_reader->bytes() + bytes_reader->length()));
upload_data_dict->Set("bytes", std::move(bytes));
} else if (reader->AsFileReader()) {
const net::UploadFileElementReader* file_reader = reader->AsFileReader();
auto file_path = file_reader->path().AsUTF8Unsafe();
upload_data_dict->SetKey("file", base::Value(file_path));
}
// else {
// const storage::UploadBlobElementReader* blob_reader =
// static_cast<storage::UploadBlobElementReader*>(reader.get());
// upload_data_dict->SetString("blobUUID", blob_reader->uuid());
// }
upload_data_list->Append(std::move(upload_data_dict));
}
}
void FillRequestDetails(base::DictionaryValue* details,
const net::URLRequest* request) {
details->SetString("method", request->method());
std::string url;
if (!request->url_chain().empty())
url = request->url().spec();
details->SetKey("url", base::Value(url));
details->SetString("referrer", request->referrer());
auto list = std::make_unique<base::ListValue>();
GetUploadData(list.get(), request);
if (!list->empty())
details->Set("uploadData", std::move(list));
auto headers_value = std::make_unique<base::DictionaryValue>();
for (net::HttpRequestHeaders::Iterator it(request->extra_request_headers());
it.GetNext();) {
headers_value->SetString(it.name(), it.value());
}
details->Set("headers", std::move(headers_value));
}
} // namespace
LoginHandler::LoginHandler(net::URLRequest* request,
const net::AuthChallengeInfo& auth_info,
// net::NetworkDelegate::AuthCallback callback,
@ -32,6 +92,7 @@ LoginHandler::LoginHandler(net::URLRequest* request,
std::unique_ptr<base::DictionaryValue> request_details(
new base::DictionaryValue);
// TODO(zcbenz): Use the converters from net_converter.
FillRequestDetails(request_details.get(), request);
// TODO(deepak1556): fix with network service

View file

@ -15,6 +15,7 @@
#include "shell/browser/window_list.h"
#include "shell/common/color_util.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/persistent_dictionary.h"
#include "shell/common/options_switches.h"
#include "ui/views/widget/widget.h"
@ -346,12 +347,12 @@ bool NativeWindow::AddTabbedWindow(NativeWindow* window) {
void NativeWindow::SetVibrancy(const std::string& filename) {}
void NativeWindow::SetTouchBar(
const std::vector<mate::PersistentDictionary>& items) {}
std::vector<gin_helper::PersistentDictionary> items) {}
void NativeWindow::RefreshTouchBarItem(const std::string& item_id) {}
void NativeWindow::SetEscapeTouchBarItem(
const mate::PersistentDictionary& item) {}
gin_helper::PersistentDictionary item) {}
void NativeWindow::SetAutoHideMenuBar(bool auto_hide) {}

View file

@ -39,11 +39,8 @@ class Size;
namespace gin_helper {
class Dictionary;
}
namespace mate {
class PersistentDictionary;
}
} // namespace gin_helper
namespace electron {
@ -198,10 +195,9 @@ class NativeWindow : public base::SupportsUserData,
virtual void SetVibrancy(const std::string& type);
// Touchbar API
virtual void SetTouchBar(
const std::vector<mate::PersistentDictionary>& items);
virtual void SetTouchBar(std::vector<gin_helper::PersistentDictionary> items);
virtual void RefreshTouchBarItem(const std::string& item_id);
virtual void SetEscapeTouchBarItem(const mate::PersistentDictionary& item);
virtual void SetEscapeTouchBarItem(gin_helper::PersistentDictionary item);
// Native Tab API
virtual void SelectPreviousTab();

View file

@ -133,9 +133,9 @@ class NativeWindowMac : public NativeWindow {
void SetVibrancy(const std::string& type) override;
void SetTouchBar(
const std::vector<mate::PersistentDictionary>& items) override;
std::vector<gin_helper::PersistentDictionary> items) override;
void RefreshTouchBarItem(const std::string& item_id) override;
void SetEscapeTouchBarItem(const mate::PersistentDictionary& item) override;
void SetEscapeTouchBarItem(gin_helper::PersistentDictionary item) override;
void SetGTKDarkThemeEnabled(bool use_dark_theme) override {}
gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& bounds) const override;

View file

@ -1462,12 +1462,12 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
}
void NativeWindowMac::SetTouchBar(
const std::vector<mate::PersistentDictionary>& items) {
std::vector<gin_helper::PersistentDictionary> items) {
if (@available(macOS 10.12.2, *)) {
touch_bar_.reset([[AtomTouchBar alloc]
initWithDelegate:window_delegate_.get()
window:this
settings:items]);
settings:std::move(items)]);
[window_ setTouchBar:nil];
}
}
@ -1480,10 +1480,11 @@ void NativeWindowMac::RefreshTouchBarItem(const std::string& item_id) {
}
void NativeWindowMac::SetEscapeTouchBarItem(
const mate::PersistentDictionary& item) {
gin_helper::PersistentDictionary item) {
if (@available(macOS 10.12.2, *)) {
if (touch_bar_ && [window_ touchBar])
[touch_bar_ setEscapeTouchBarItem:item forTouchBar:[window_ touchBar]];
[touch_bar_ setEscapeTouchBarItem:std::move(item)
forTouchBar:[window_ touchBar]];
}
}

View file

@ -27,7 +27,7 @@
#include "shell/common/gin_converters/file_path_converter.h"
#include "shell/common/gin_converters/gurl_converter.h"
#include "shell/common/gin_converters/net_converter.h"
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/node_includes.h"

View file

@ -5,7 +5,6 @@
#include <utility>
#include "shell/browser/net/cert_verifier_client.h"
#include "shell/common/native_mate_converters/net_converter.h"
namespace electron {

View file

@ -23,7 +23,7 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "shell/common/api/locker.h"
#include "shell/common/gin_helper/locker.h"
#include "shell/common/node_includes.h"
@ -175,7 +175,7 @@ void PrintPreviewMessageHandler::ResolvePromise(
util::Promise<v8::Local<v8::Value>> promise = GetPromise(request_id);
v8::Isolate* isolate = promise.isolate();
mate::Locker locker(isolate);
gin_helper::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
v8::Context::Scope context_scope(
v8::Local<v8::Context>::New(isolate, promise.GetContext()));

View file

@ -19,7 +19,7 @@
#include "content/public/browser/browser_context.h"
#include "shell/browser/api/atom_api_session.h"
#include "shell/browser/atom_browser_context.h"
#include "shell/common/native_mate_converters/gurl_converter.h"
#include "shell/common/gin_converters/gurl_converter.h"
using content::BrowserThread;

View file

@ -12,35 +12,34 @@
#include <vector>
#include "base/mac/scoped_nsobject.h"
#include "native_mate/constructor.h"
#include "native_mate/persistent_dictionary.h"
#include "shell/browser/native_window.h"
#include "shell/common/gin_helper/persistent_dictionary.h"
@interface AtomTouchBar : NSObject <NSScrubberDelegate,
NSScrubberDataSource,
NSScrubberFlowLayoutDelegate> {
@protected
std::vector<mate::PersistentDictionary> ordered_settings_;
std::map<std::string, mate::PersistentDictionary> settings_;
std::vector<gin_helper::PersistentDictionary> ordered_settings_;
std::map<std::string, gin_helper::PersistentDictionary> settings_;
id<NSTouchBarDelegate> delegate_;
electron::NativeWindow* window_;
}
- (id)initWithDelegate:(id<NSTouchBarDelegate>)delegate
window:(electron::NativeWindow*)window
settings:(const std::vector<mate::PersistentDictionary>&)settings;
settings:(std::vector<gin_helper::PersistentDictionary>)settings;
- (NSTouchBar*)makeTouchBar API_AVAILABLE(macosx(10.12.2));
- (NSTouchBar*)touchBarFromItemIdentifiers:(NSMutableArray*)items
API_AVAILABLE(macosx(10.12.2));
- (NSMutableArray*)identifiersFromSettings:
(const std::vector<mate::PersistentDictionary>&)settings;
(const std::vector<gin_helper::PersistentDictionary>&)settings;
- (void)refreshTouchBarItem:(NSTouchBar*)touchBar
id:(const std::string&)item_id
API_AVAILABLE(macosx(10.12.2));
- (void)addNonDefaultTouchBarItems:
(const std::vector<mate::PersistentDictionary>&)items;
- (void)setEscapeTouchBarItem:(const mate::PersistentDictionary&)item
(const std::vector<gin_helper::PersistentDictionary>&)items;
- (void)setEscapeTouchBarItem:(gin_helper::PersistentDictionary)item
forTouchBar:(NSTouchBar*)touchBar
API_AVAILABLE(macosx(10.12.2));
@ -80,19 +79,19 @@
// Helpers to update touch bar items
- (void)updateButton:(NSCustomTouchBarItem*)item
withSettings:(const mate::PersistentDictionary&)settings
withSettings:(const gin_helper::PersistentDictionary&)settings
API_AVAILABLE(macosx(10.12.2));
- (void)updateLabel:(NSCustomTouchBarItem*)item
withSettings:(const mate::PersistentDictionary&)settings
withSettings:(const gin_helper::PersistentDictionary&)settings
API_AVAILABLE(macosx(10.12.2));
- (void)updateColorPicker:(NSColorPickerTouchBarItem*)item
withSettings:(const mate::PersistentDictionary&)settings
withSettings:(const gin_helper::PersistentDictionary&)settings
API_AVAILABLE(macosx(10.12.2));
- (void)updateSlider:(NSSliderTouchBarItem*)item
withSettings:(const mate::PersistentDictionary&)settings
withSettings:(const gin_helper::PersistentDictionary&)settings
API_AVAILABLE(macosx(10.12.2));
- (void)updatePopover:(NSPopoverTouchBarItem*)item
withSettings:(const mate::PersistentDictionary&)settings
withSettings:(const gin_helper::PersistentDictionary&)settings
API_AVAILABLE(macosx(10.12.2));
@end

View file

@ -9,7 +9,7 @@
#include "base/strings/sys_string_conversions.h"
#include "shell/common/color_util.h"
#include "shell/common/native_mate_converters/image_converter.h"
#include "shell/common/gin_converters/image_converter.h"
#include "skia/ext/skia_utils_mac.h"
#include "ui/gfx/image/image.h"
@ -37,12 +37,11 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
- (id)initWithDelegate:(id<NSTouchBarDelegate>)delegate
window:(electron::NativeWindow*)window
settings:
(const std::vector<mate::PersistentDictionary>&)settings {
settings:(std::vector<gin_helper::PersistentDictionary>)settings {
if ((self = [super init])) {
delegate_ = delegate;
window_ = window;
ordered_settings_ = settings;
ordered_settings_ = std::move(settings);
}
return self;
}
@ -61,7 +60,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
}
- (NSMutableArray*)identifiersFromSettings:
(const std::vector<mate::PersistentDictionary>&)dicts {
(const std::vector<gin_helper::PersistentDictionary>&)dicts {
NSMutableArray* identifiers = [NSMutableArray array];
if (@available(macOS 10.12.2, *)) {
@ -133,7 +132,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
- (void)refreshTouchBarItem:(NSTouchBar*)touchBar
id:(NSTouchBarItemIdentifier)identifier
withType:(const std::string&)item_type
withSettings:(const mate::PersistentDictionary&)settings
withSettings:(const gin_helper::PersistentDictionary&)settings
API_AVAILABLE(macosx(10.12.2)) {
NSTouchBarItem* item = [touchBar itemForIdentifier:identifier];
if (!item)
@ -161,11 +160,11 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
}
- (void)addNonDefaultTouchBarItems:
(const std::vector<mate::PersistentDictionary>&)items {
(const std::vector<gin_helper::PersistentDictionary>&)items {
[self identifiersFromSettings:items];
}
- (void)setEscapeTouchBarItem:(const mate::PersistentDictionary&)item
- (void)setEscapeTouchBarItem:(gin_helper::PersistentDictionary)item
forTouchBar:(NSTouchBar*)touchBar {
if (![touchBar
respondsToSelector:@selector(escapeKeyReplacementItemIdentifier)])
@ -177,7 +176,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
identifier = [self identifierFromID:item_id type:type];
}
if (identifier) {
[self addNonDefaultTouchBarItems:{item}];
[self addNonDefaultTouchBarItems:{std::move(item)}];
touchBar.escapeKeyReplacementItemIdentifier = identifier;
} else {
touchBar.escapeKeyReplacementItemIdentifier = nil;
@ -189,7 +188,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
if (![self hasItemWithID:item_id])
return;
mate::PersistentDictionary settings = settings_[item_id];
gin_helper::PersistentDictionary settings = settings_[item_id];
std::string item_type;
settings.Get("type", &item_type);
@ -197,7 +196,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
if (!identifier)
return;
std::vector<mate::Dictionary> parents;
std::vector<gin_helper::Dictionary> parents;
settings.Get("_parents", &parents);
for (auto& parent : parents) {
std::string parent_type;
@ -339,7 +338,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
if (![self hasItemWithID:s_id])
return nil;
mate::PersistentDictionary settings = settings_[s_id];
gin_helper::PersistentDictionary settings = settings_[s_id];
base::scoped_nsobject<NSCustomTouchBarItem> item(
[[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]);
NSButton* button = [NSButton buttonWithTitle:@""
@ -352,7 +351,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
}
- (void)updateButton:(NSCustomTouchBarItem*)item
withSettings:(const mate::PersistentDictionary&)settings {
withSettings:(const gin_helper::PersistentDictionary&)settings {
NSButton* button = (NSButton*)item.view;
std::string backgroundColor;
@ -393,7 +392,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
if (![self hasItemWithID:s_id])
return nil;
mate::PersistentDictionary settings = settings_[s_id];
gin_helper::PersistentDictionary settings = settings_[s_id];
base::scoped_nsobject<NSCustomTouchBarItem> item(
[[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]);
[item setView:[NSTextField labelWithString:@""]];
@ -402,7 +401,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
}
- (void)updateLabel:(NSCustomTouchBarItem*)item
withSettings:(const mate::PersistentDictionary&)settings {
withSettings:(const gin_helper::PersistentDictionary&)settings {
NSTextField* text_field = (NSTextField*)item.view;
std::string label;
@ -427,7 +426,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
if (![self hasItemWithID:s_id])
return nil;
mate::PersistentDictionary settings = settings_[s_id];
gin_helper::PersistentDictionary settings = settings_[s_id];
base::scoped_nsobject<NSColorPickerTouchBarItem> item(
[[NSColorPickerTouchBarItem alloc] initWithIdentifier:identifier]);
[item setTarget:self];
@ -437,7 +436,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
}
- (void)updateColorPicker:(NSColorPickerTouchBarItem*)item
withSettings:(const mate::PersistentDictionary&)settings {
withSettings:(const gin_helper::PersistentDictionary&)settings {
std::vector<std::string> colors;
if (settings.Get("availableColors", &colors) && !colors.empty()) {
NSColorList* color_list =
@ -462,7 +461,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
if (![self hasItemWithID:s_id])
return nil;
mate::PersistentDictionary settings = settings_[s_id];
gin_helper::PersistentDictionary settings = settings_[s_id];
base::scoped_nsobject<NSSliderTouchBarItem> item(
[[NSSliderTouchBarItem alloc] initWithIdentifier:identifier]);
[item setTarget:self];
@ -472,7 +471,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
}
- (void)updateSlider:(NSSliderTouchBarItem*)item
withSettings:(const mate::PersistentDictionary&)settings {
withSettings:(const gin_helper::PersistentDictionary&)settings {
std::string label;
settings.Get("label", &label);
item.label = base::SysUTF8ToNSString(label);
@ -495,7 +494,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
if (![self hasItemWithID:s_id])
return nil;
mate::PersistentDictionary settings = settings_[s_id];
gin_helper::PersistentDictionary settings = settings_[s_id];
base::scoped_nsobject<NSPopoverTouchBarItem> item(
[[NSPopoverTouchBarItem alloc] initWithIdentifier:identifier]);
[self updatePopover:item withSettings:settings];
@ -503,7 +502,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
}
- (void)updatePopover:(NSPopoverTouchBarItem*)item
withSettings:(const mate::PersistentDictionary&)settings {
withSettings:(const gin_helper::PersistentDictionary&)settings {
std::string label;
settings.Get("label", &label);
item.collapsedRepresentationLabel = base::SysUTF8ToNSString(label);
@ -517,8 +516,8 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
settings.Get("showCloseButton", &showCloseButton);
item.showsCloseButton = showCloseButton;
mate::PersistentDictionary child;
std::vector<mate::PersistentDictionary> items;
gin_helper::PersistentDictionary child;
std::vector<gin_helper::PersistentDictionary> items;
if (settings.Get("child", &child) && child.Get("ordereredItems", &items)) {
item.popoverTouchBar =
[self touchBarFromItemIdentifiers:[self identifiersFromSettings:items]];
@ -530,12 +529,12 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
std::string s_id([id UTF8String]);
if (![self hasItemWithID:s_id])
return nil;
mate::PersistentDictionary settings = settings_[s_id];
gin_helper::PersistentDictionary settings = settings_[s_id];
mate::PersistentDictionary child;
gin_helper::PersistentDictionary child;
if (!settings.Get("child", &child))
return nil;
std::vector<mate::PersistentDictionary> items;
std::vector<gin_helper::PersistentDictionary> items;
if (!child.Get("ordereredItems", &items))
return nil;
@ -556,12 +555,12 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
}
- (void)updateGroup:(NSGroupTouchBarItem*)item
withSettings:(const mate::PersistentDictionary&)settings
withSettings:(const gin_helper::PersistentDictionary&)settings
API_AVAILABLE(macosx(10.12.2)) {
mate::PersistentDictionary child;
gin_helper::PersistentDictionary child;
if (!settings.Get("child", &child))
return;
std::vector<mate::PersistentDictionary> items;
std::vector<gin_helper::PersistentDictionary> items;
if (!child.Get("ordereredItems", &items))
return;
@ -576,7 +575,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
if (![self hasItemWithID:s_id])
return nil;
mate::PersistentDictionary settings = settings_[s_id];
gin_helper::PersistentDictionary settings = settings_[s_id];
base::scoped_nsobject<NSCustomTouchBarItem> item(
[[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]);
@ -593,7 +592,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
}
- (void)updateSegmentedControl:(NSCustomTouchBarItem*)item
withSettings:(const mate::PersistentDictionary&)settings
withSettings:(const gin_helper::PersistentDictionary&)settings
API_AVAILABLE(macosx(10.12.2)) {
NSSegmentedControl* control = item.view;
@ -625,7 +624,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
else
control.trackingMode = NSSegmentSwitchTrackingSelectOne;
std::vector<mate::Dictionary> segments;
std::vector<gin_helper::Dictionary> segments;
settings.Get("segments", &segments);
control.segmentCount = segments.size();
@ -661,7 +660,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
if (![self hasItemWithID:s_id])
return nil;
mate::PersistentDictionary settings = settings_[s_id];
gin_helper::PersistentDictionary settings = settings_[s_id];
base::scoped_nsobject<NSCustomTouchBarItem> item(
[[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]);
@ -684,7 +683,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
}
- (void)updateScrubber:(NSCustomTouchBarItem*)item
withSettings:(const mate::PersistentDictionary&)settings
withSettings:(const gin_helper::PersistentDictionary&)settings
API_AVAILABLE(macosx(10.12.2)) {
NSScrubber* scrubber = item.view;
@ -738,8 +737,8 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
if (![self hasItemWithID:s_id])
return 0;
mate::PersistentDictionary settings = settings_[s_id];
std::vector<mate::PersistentDictionary> items;
gin_helper::PersistentDictionary settings = settings_[s_id];
std::vector<gin_helper::PersistentDictionary> items;
settings.Get("items", &items);
return items.size();
}
@ -751,15 +750,15 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
if (![self hasItemWithID:s_id])
return nil;
mate::PersistentDictionary settings = settings_[s_id];
std::vector<mate::PersistentDictionary> items;
gin_helper::PersistentDictionary settings = settings_[s_id];
std::vector<gin_helper::PersistentDictionary> items;
if (!settings.Get("items", &items))
return nil;
if (index >= static_cast<NSInteger>(items.size()))
return nil;
mate::PersistentDictionary item = items[index];
gin_helper::PersistentDictionary item = items[index];
NSScrubberItemView* itemView;
std::string title;
@ -795,15 +794,15 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
if (![self hasItemWithID:s_id])
return defaultSize;
mate::PersistentDictionary settings = settings_[s_id];
std::vector<mate::PersistentDictionary> items;
gin_helper::PersistentDictionary settings = settings_[s_id];
std::vector<gin_helper::PersistentDictionary> items;
if (!settings.Get("items", &items))
return defaultSize;
if (itemIndex >= static_cast<NSInteger>(items.size()))
return defaultSize;
mate::PersistentDictionary item = items[itemIndex];
gin_helper::PersistentDictionary item = items[itemIndex];
std::string title;
if (item.Get("label", &title)) {

View file

@ -12,7 +12,6 @@
#include "content/public/browser/render_process_host.h"
#include "shell/browser/atom_permission_manager.h"
#include "shell/browser/media/media_stream_devices_controller.h"
#include "shell/common/native_mate_converters/gurl_converter.h"
namespace {

View file

@ -23,7 +23,7 @@
#include "services/service_manager/sandbox/switches.h"
#include "shell/browser/native_window.h"
#include "shell/browser/web_view_manager.h"
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/options_switches.h"

View file

@ -14,7 +14,6 @@
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "shell/browser/api/atom_api_web_contents.h"
#include "shell/common/native_mate_converters/gurl_converter.h"
#include "third_party/blink/public/common/page/page_zoom.h"
namespace electron {