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

@ -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)) {