Bring mac code into conformance with -Wunguarded-availability
This commit is contained in:
parent
27cee90e5e
commit
f3c00e96aa
12 changed files with 234 additions and 207 deletions
|
@ -145,9 +145,13 @@ void Browser::SetUserActivity(const std::string& type,
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Browser::GetCurrentActivityType() {
|
std::string Browser::GetCurrentActivityType() {
|
||||||
|
if (@available(macOS 10.10, *)) {
|
||||||
NSUserActivity* userActivity =
|
NSUserActivity* userActivity =
|
||||||
[[AtomApplication sharedApplication] getCurrentActivity];
|
[[AtomApplication sharedApplication] getCurrentActivity];
|
||||||
return base::SysNSStringToUTF8(userActivity.activityType);
|
return base::SysNSStringToUTF8(userActivity.activityType);
|
||||||
|
} else {
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Browser::InvalidateCurrentActivity() {
|
void Browser::InvalidateCurrentActivity() {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
NSUserActivityDelegate> {
|
NSUserActivityDelegate> {
|
||||||
@private
|
@private
|
||||||
BOOL handlingSendEvent_;
|
BOOL handlingSendEvent_;
|
||||||
base::scoped_nsobject<NSUserActivity> currentActivity_;
|
base::scoped_nsobject<NSUserActivity> currentActivity_ API_AVAILABLE(macosx(10.10));
|
||||||
NSCondition* handoffLock_;
|
NSCondition* handoffLock_;
|
||||||
BOOL updateReceived_;
|
BOOL updateReceived_;
|
||||||
base::Callback<bool()> shouldShutdown_;
|
base::Callback<bool()> shouldShutdown_;
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
// CrAppControlProtocol:
|
// CrAppControlProtocol:
|
||||||
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent;
|
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent;
|
||||||
|
|
||||||
- (NSUserActivity*)getCurrentActivity;
|
- (NSUserActivity*)getCurrentActivity API_AVAILABLE(macosx(10.10));
|
||||||
- (void)setCurrentActivity:(NSString*)type
|
- (void)setCurrentActivity:(NSString*)type
|
||||||
withUserInfo:(NSDictionary*)userInfo
|
withUserInfo:(NSDictionary*)userInfo
|
||||||
withWebpageURL:(NSURL*)webpageURL;
|
withWebpageURL:(NSURL*)webpageURL;
|
||||||
|
|
|
@ -58,6 +58,7 @@ inline void dispatch_sync_main(dispatch_block_t block) {
|
||||||
- (void)setCurrentActivity:(NSString*)type
|
- (void)setCurrentActivity:(NSString*)type
|
||||||
withUserInfo:(NSDictionary*)userInfo
|
withUserInfo:(NSDictionary*)userInfo
|
||||||
withWebpageURL:(NSURL*)webpageURL {
|
withWebpageURL:(NSURL*)webpageURL {
|
||||||
|
if (@available(macOS 10.10, *)) {
|
||||||
currentActivity_ = base::scoped_nsobject<NSUserActivity>(
|
currentActivity_ = base::scoped_nsobject<NSUserActivity>(
|
||||||
[[NSUserActivity alloc] initWithActivityType:type]);
|
[[NSUserActivity alloc] initWithActivityType:type]);
|
||||||
[currentActivity_ setUserInfo:userInfo];
|
[currentActivity_ setUserInfo:userInfo];
|
||||||
|
@ -66,6 +67,7 @@ inline void dispatch_sync_main(dispatch_block_t block) {
|
||||||
[currentActivity_ becomeCurrent];
|
[currentActivity_ becomeCurrent];
|
||||||
[currentActivity_ setNeedsSave:YES];
|
[currentActivity_ setNeedsSave:YES];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (NSUserActivity*)getCurrentActivity {
|
- (NSUserActivity*)getCurrentActivity {
|
||||||
return currentActivity_.get();
|
return currentActivity_.get();
|
||||||
|
@ -90,7 +92,7 @@ inline void dispatch_sync_main(dispatch_block_t block) {
|
||||||
[handoffLock_ unlock];
|
[handoffLock_ unlock];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)userActivityWillSave:(NSUserActivity *)userActivity {
|
- (void)userActivityWillSave:(NSUserActivity *)userActivity API_AVAILABLE(macosx(10.10)) {
|
||||||
__block BOOL shouldWait = NO;
|
__block BOOL shouldWait = NO;
|
||||||
dispatch_sync_main(^{
|
dispatch_sync_main(^{
|
||||||
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
|
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
|
||||||
|
@ -114,7 +116,7 @@ inline void dispatch_sync_main(dispatch_block_t block) {
|
||||||
[userActivity setNeedsSave:YES];
|
[userActivity setNeedsSave:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)userActivityWasContinued:(NSUserActivity *)userActivity {
|
- (void)userActivityWasContinued:(NSUserActivity *)userActivity API_AVAILABLE(macosx(10.10)) {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
|
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
|
||||||
std::unique_ptr<base::DictionaryValue> user_info =
|
std::unique_ptr<base::DictionaryValue> user_info =
|
||||||
|
|
|
@ -96,7 +96,8 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
|
||||||
|
|
||||||
- (BOOL)application:(NSApplication*)sender
|
- (BOOL)application:(NSApplication*)sender
|
||||||
continueUserActivity:(NSUserActivity*)userActivity
|
continueUserActivity:(NSUserActivity*)userActivity
|
||||||
restorationHandler:(void (^)(NSArray*restorableObjects))restorationHandler {
|
restorationHandler:(void (^)(NSArray*restorableObjects))restorationHandler
|
||||||
|
API_AVAILABLE(macosx(10.10)) {
|
||||||
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
|
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
|
||||||
std::unique_ptr<base::DictionaryValue> user_info =
|
std::unique_ptr<base::DictionaryValue> user_info =
|
||||||
atom::NSDictionaryToDictionaryValue(userActivity.userInfo);
|
atom::NSDictionaryToDictionaryValue(userActivity.userInfo);
|
||||||
|
|
|
@ -50,7 +50,9 @@ const NSAutoresizingMaskOptions kDefaultAutoResizingMask =
|
||||||
postNotificationName:NSWindowWillMoveNotification
|
postNotificationName:NSWindowWillMoveNotification
|
||||||
object:self];
|
object:self];
|
||||||
|
|
||||||
|
if (@available(macOS 10.11, *)) {
|
||||||
[self.window performWindowDragWithEvent:event];
|
[self.window performWindowDragWithEvent:event];
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -314,22 +314,23 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||||
shell_->SetResizable(true);
|
shell_->SetResizable(true);
|
||||||
// Hide the native toolbar before entering fullscreen, so there is no visual
|
// Hide the native toolbar before entering fullscreen, so there is no visual
|
||||||
// artifacts.
|
// artifacts.
|
||||||
if (base::mac::IsAtLeastOS10_10() &&
|
if (@available(macOS 10.10, *)) {
|
||||||
shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
|
if (shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
|
||||||
NSWindow* window = shell_->GetNativeWindow();
|
NSWindow* window = shell_->GetNativeWindow();
|
||||||
[window setToolbar:nil];
|
[window setToolbar:nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)windowDidEnterFullScreen:(NSNotification*)notification {
|
- (void)windowDidEnterFullScreen:(NSNotification*)notification {
|
||||||
shell_->NotifyWindowEnterFullScreen();
|
shell_->NotifyWindowEnterFullScreen();
|
||||||
|
|
||||||
|
if (@available(macOS 10.10, *)) {
|
||||||
// For frameless window we don't show set title for normal mode since the
|
// For frameless window we don't show set title for normal mode since the
|
||||||
// titlebar is expected to be empty, but after entering fullscreen mode we
|
// titlebar is expected to be empty, but after entering fullscreen mode we
|
||||||
// have to set one, because title bar is visible here.
|
// have to set one, because title bar is visible here.
|
||||||
NSWindow* window = shell_->GetNativeWindow();
|
NSWindow* window = shell_->GetNativeWindow();
|
||||||
if ((shell_->transparent() || !shell_->has_frame()) &&
|
if ((shell_->transparent() || !shell_->has_frame()) &&
|
||||||
base::mac::IsAtLeastOS10_10() &&
|
|
||||||
// FIXME(zcbenz): Showing titlebar for hiddenInset window is weird under
|
// FIXME(zcbenz): Showing titlebar for hiddenInset window is weird under
|
||||||
// fullscreen mode.
|
// fullscreen mode.
|
||||||
// Show title if fullscreen_window_title flag is set
|
// Show title if fullscreen_window_title flag is set
|
||||||
|
@ -340,8 +341,7 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||||
|
|
||||||
// Restore the native toolbar immediately after entering fullscreen, if we do
|
// Restore the native toolbar immediately after entering fullscreen, if we do
|
||||||
// this before leaving fullscreen, traffic light buttons will be jumping.
|
// this before leaving fullscreen, traffic light buttons will be jumping.
|
||||||
if (base::mac::IsAtLeastOS10_10() &&
|
if (shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
|
||||||
shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
|
|
||||||
base::scoped_nsobject<NSToolbar> toolbar(
|
base::scoped_nsobject<NSToolbar> toolbar(
|
||||||
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
|
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
|
||||||
[toolbar setShowsBaselineSeparator:NO];
|
[toolbar setShowsBaselineSeparator:NO];
|
||||||
|
@ -352,23 +352,24 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||||
shell_->SetStyleMask(true, NSFullSizeContentViewWindowMask);
|
shell_->SetStyleMask(true, NSFullSizeContentViewWindowMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)windowWillExitFullScreen:(NSNotification*)notification {
|
- (void)windowWillExitFullScreen:(NSNotification*)notification {
|
||||||
|
if (@available(macOS 10.10, *)) {
|
||||||
// Restore the titlebar visibility.
|
// Restore the titlebar visibility.
|
||||||
NSWindow* window = shell_->GetNativeWindow();
|
NSWindow* window = shell_->GetNativeWindow();
|
||||||
if ((shell_->transparent() || !shell_->has_frame()) &&
|
if ((shell_->transparent() || !shell_->has_frame()) &&
|
||||||
base::mac::IsAtLeastOS10_10() &&
|
|
||||||
(shell_->title_bar_style() != atom::NativeWindowMac::HIDDEN_INSET ||
|
(shell_->title_bar_style() != atom::NativeWindowMac::HIDDEN_INSET ||
|
||||||
shell_->fullscreen_window_title())) {
|
shell_->fullscreen_window_title())) {
|
||||||
[window setTitleVisibility:NSWindowTitleHidden];
|
[window setTitleVisibility:NSWindowTitleHidden];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turn off the style for toolbar.
|
// Turn off the style for toolbar.
|
||||||
if (base::mac::IsAtLeastOS10_10() &&
|
if (shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
|
||||||
shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
|
|
||||||
shell_->SetStyleMask(false, NSFullSizeContentViewWindowMask);
|
shell_->SetStyleMask(false, NSFullSizeContentViewWindowMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)windowDidExitFullScreen:(NSNotification*)notification {
|
- (void)windowDidExitFullScreen:(NSNotification*)notification {
|
||||||
shell_->SetResizable(is_resizable_);
|
shell_->SetResizable(is_resizable_);
|
||||||
|
@ -487,7 +488,8 @@ enum {
|
||||||
enable_larger_than_screen_ = enable;
|
enable_larger_than_screen_ = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)resetTouchBar:(const std::vector<mate::PersistentDictionary>&)settings {
|
- (void)resetTouchBar:(const std::vector<mate::PersistentDictionary>&)settings
|
||||||
|
API_AVAILABLE(macosx(10.12.2)) {
|
||||||
if (![self respondsToSelector:@selector(touchBar)]) return;
|
if (![self respondsToSelector:@selector(touchBar)]) return;
|
||||||
|
|
||||||
atom_touch_bar_.reset([[AtomTouchBar alloc] initWithDelegate:self
|
atom_touch_bar_.reset([[AtomTouchBar alloc] initWithDelegate:self
|
||||||
|
@ -496,12 +498,13 @@ enum {
|
||||||
self.touchBar = nil;
|
self.touchBar = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)refreshTouchBarItem:(const std::string&)item_id {
|
- (void)refreshTouchBarItem:(const std::string&)item_id
|
||||||
|
API_AVAILABLE(macosx(10.12.2)) {
|
||||||
if (atom_touch_bar_ && self.touchBar)
|
if (atom_touch_bar_ && self.touchBar)
|
||||||
[atom_touch_bar_ refreshTouchBarItem:self.touchBar id:item_id];
|
[atom_touch_bar_ refreshTouchBarItem:self.touchBar id:item_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSTouchBar*)makeTouchBar {
|
- (NSTouchBar*)makeTouchBar API_AVAILABLE(macosx(10.12.2)) {
|
||||||
if (atom_touch_bar_)
|
if (atom_touch_bar_)
|
||||||
return [atom_touch_bar_ makeTouchBar];
|
return [atom_touch_bar_ makeTouchBar];
|
||||||
else
|
else
|
||||||
|
@ -509,14 +512,15 @@ enum {
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar
|
- (NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar
|
||||||
makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier {
|
makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier API_AVAILABLE(macosx(10.12.2)) {
|
||||||
if (touchBar && atom_touch_bar_)
|
if (touchBar && atom_touch_bar_)
|
||||||
return [atom_touch_bar_ makeItemForIdentifier:identifier];
|
return [atom_touch_bar_ makeItemForIdentifier:identifier];
|
||||||
else
|
else
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setEscapeTouchBarItem:(const mate::PersistentDictionary&)item {
|
- (void)setEscapeTouchBarItem:(const mate::PersistentDictionary&)item
|
||||||
|
API_AVAILABLE(macosx(10.12.2)) {
|
||||||
if (atom_touch_bar_ && self.touchBar)
|
if (atom_touch_bar_ && self.touchBar)
|
||||||
[atom_touch_bar_ setEscapeTouchBarItem:item forTouchBar:self.touchBar];
|
[atom_touch_bar_ setEscapeTouchBarItem:item forTouchBar:self.touchBar];
|
||||||
}
|
}
|
||||||
|
@ -828,11 +832,12 @@ NativeWindowMac::NativeWindowMac(const mate::Dictionary& options,
|
||||||
}
|
}
|
||||||
|
|
||||||
NSUInteger styleMask = NSTitledWindowMask;
|
NSUInteger styleMask = NSTitledWindowMask;
|
||||||
|
if (@available(macOS 10.10, *)) {
|
||||||
if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER &&
|
if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER &&
|
||||||
base::mac::IsAtLeastOS10_10() &&
|
|
||||||
(!useStandardWindow || transparent() || !has_frame())) {
|
(!useStandardWindow || transparent() || !has_frame())) {
|
||||||
styleMask = NSFullSizeContentViewWindowMask;
|
styleMask = NSFullSizeContentViewWindowMask;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (minimizable) {
|
if (minimizable) {
|
||||||
styleMask |= NSMiniaturizableWindowMask;
|
styleMask |= NSMiniaturizableWindowMask;
|
||||||
}
|
}
|
||||||
|
@ -885,7 +890,7 @@ NativeWindowMac::NativeWindowMac(const mate::Dictionary& options,
|
||||||
[window_ setDisableKeyOrMainWindow:YES];
|
[window_ setDisableKeyOrMainWindow:YES];
|
||||||
|
|
||||||
if (transparent() || !has_frame()) {
|
if (transparent() || !has_frame()) {
|
||||||
if (base::mac::IsAtLeastOS10_10()) {
|
if (@available(macOS 10.10, *)) {
|
||||||
// Don't show title bar.
|
// Don't show title bar.
|
||||||
[window_ setTitlebarAppearsTransparent:YES];
|
[window_ setTitlebarAppearsTransparent:YES];
|
||||||
[window_ setTitleVisibility:NSWindowTitleHidden];
|
[window_ setTitleVisibility:NSWindowTitleHidden];
|
||||||
|
@ -897,11 +902,11 @@ NativeWindowMac::NativeWindowMac(const mate::Dictionary& options,
|
||||||
// Create a tab only if tabbing identifier is specified and window has
|
// Create a tab only if tabbing identifier is specified and window has
|
||||||
// a native title bar.
|
// a native title bar.
|
||||||
if (tabbingIdentifier.empty() || transparent() || !has_frame()) {
|
if (tabbingIdentifier.empty() || transparent() || !has_frame()) {
|
||||||
if ([window_ respondsToSelector:@selector(tabbingMode)]) {
|
if (@available(macOS 10.12, *)) {
|
||||||
[window_ setTabbingMode:NSWindowTabbingModeDisallowed];
|
[window_ setTabbingMode:NSWindowTabbingModeDisallowed];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ([window_ respondsToSelector:@selector(tabbingIdentifier)]) {
|
if (@available(macOS 10.12, *)) {
|
||||||
[window_ setTabbingIdentifier:base::SysUTF8ToNSString(tabbingIdentifier)];
|
[window_ setTabbingIdentifier:base::SysUTF8ToNSString(tabbingIdentifier)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -911,14 +916,14 @@ NativeWindowMac::NativeWindowMac(const mate::Dictionary& options,
|
||||||
|
|
||||||
// Hide the title bar background
|
// Hide the title bar background
|
||||||
if (title_bar_style_ != NORMAL) {
|
if (title_bar_style_ != NORMAL) {
|
||||||
if (base::mac::IsAtLeastOS10_10()) {
|
if (@available(macOS 10.10, *)) {
|
||||||
[window_ setTitlebarAppearsTransparent:YES];
|
[window_ setTitlebarAppearsTransparent:YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide the title bar.
|
// Hide the title bar.
|
||||||
if (title_bar_style_ == HIDDEN_INSET) {
|
if (title_bar_style_ == HIDDEN_INSET) {
|
||||||
if (base::mac::IsAtLeastOS10_10()) {
|
if (@available(macOS 10.10, *)) {
|
||||||
base::scoped_nsobject<NSToolbar> toolbar(
|
base::scoped_nsobject<NSToolbar> toolbar(
|
||||||
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
|
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
|
||||||
[toolbar setShowsBaselineSeparator:NO];
|
[toolbar setShowsBaselineSeparator:NO];
|
||||||
|
@ -1650,31 +1655,31 @@ void NativeWindowMac::SetAutoHideCursor(bool auto_hide) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SelectPreviousTab() {
|
void NativeWindowMac::SelectPreviousTab() {
|
||||||
if ([window_ respondsToSelector:@selector(selectPreviousTab:)]) {
|
if (@available(macOS 10.12, *)) {
|
||||||
[window_ selectPreviousTab:nil];
|
[window_ selectPreviousTab:nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SelectNextTab() {
|
void NativeWindowMac::SelectNextTab() {
|
||||||
if ([window_ respondsToSelector:@selector(selectNextTab:)]) {
|
if (@available(macOS 10.12, *)) {
|
||||||
[window_ selectNextTab:nil];
|
[window_ selectNextTab:nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::MergeAllWindows() {
|
void NativeWindowMac::MergeAllWindows() {
|
||||||
if ([window_ respondsToSelector:@selector(mergeAllWindows:)]) {
|
if (@available(macOS 10.12, *)) {
|
||||||
[window_ mergeAllWindows:nil];
|
[window_ mergeAllWindows:nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::MoveTabToNewWindow() {
|
void NativeWindowMac::MoveTabToNewWindow() {
|
||||||
if ([window_ respondsToSelector:@selector(moveTabToNewWindow:)]) {
|
if (@available(macOS 10.12, *)) {
|
||||||
[window_ moveTabToNewWindow:nil];
|
[window_ moveTabToNewWindow:nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::ToggleTabBar() {
|
void NativeWindowMac::ToggleTabBar() {
|
||||||
if ([window_ respondsToSelector:@selector(toggleTabBar:)]) {
|
if (@available(macOS 10.12, *)) {
|
||||||
[window_ toggleTabBar:nil];
|
[window_ toggleTabBar:nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1683,15 +1688,14 @@ bool NativeWindowMac::AddTabbedWindow(NativeWindow* window) {
|
||||||
if (window_.get() == window->GetNativeWindow()) {
|
if (window_.get() == window->GetNativeWindow()) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if ([window_ respondsToSelector:@selector(addTabbedWindow:ordered:)])
|
if (@available(macOS 10.12, *))
|
||||||
[window_ addTabbedWindow:window->GetNativeWindow() ordered:NSWindowAbove];
|
[window_ addTabbedWindow:window->GetNativeWindow() ordered:NSWindowAbove];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SetVibrancy(const std::string& type) {
|
void NativeWindowMac::SetVibrancy(const std::string& type) {
|
||||||
if (!base::mac::IsAtLeastOS10_10()) return;
|
if (@available(macOS 10.10, *)) {
|
||||||
|
|
||||||
NSView* vibrant_view = [window_ vibrantView];
|
NSView* vibrant_view = [window_ vibrantView];
|
||||||
|
|
||||||
if (type.empty()) {
|
if (type.empty()) {
|
||||||
|
@ -1743,7 +1747,7 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
|
||||||
vibrancyType = NSVisualEffectMaterialTitlebar;
|
vibrancyType = NSVisualEffectMaterialTitlebar;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (base::mac::IsAtLeastOS10_11()) {
|
if (@available(macOS 10.11, *)) {
|
||||||
// TODO(kevinsawicki): Use NSVisualEffectMaterial* constants directly once
|
// TODO(kevinsawicki): Use NSVisualEffectMaterial* constants directly once
|
||||||
// they are available in the minimum SDK version
|
// they are available in the minimum SDK version
|
||||||
if (type == "selection") {
|
if (type == "selection") {
|
||||||
|
@ -1769,6 +1773,7 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
|
||||||
|
|
||||||
[effect_view setMaterial:vibrancyType];
|
[effect_view setMaterial:vibrancyType];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SetTouchBar(
|
void NativeWindowMac::SetTouchBar(
|
||||||
const std::vector<mate::PersistentDictionary>& items) {
|
const std::vector<mate::PersistentDictionary>& items) {
|
||||||
|
|
|
@ -31,16 +31,16 @@
|
||||||
window:(atom::NativeWindow*)window
|
window:(atom::NativeWindow*)window
|
||||||
settings:(const std::vector<mate::PersistentDictionary>&)settings;
|
settings:(const std::vector<mate::PersistentDictionary>&)settings;
|
||||||
|
|
||||||
- (NSTouchBar*)makeTouchBar;
|
- (NSTouchBar*)makeTouchBar API_AVAILABLE(macosx(10.12.2));
|
||||||
- (NSTouchBar*)touchBarFromItemIdentifiers:(NSMutableArray*)items;
|
- (NSTouchBar*)touchBarFromItemIdentifiers:(NSMutableArray*)items API_AVAILABLE(macosx(10.12.2));
|
||||||
- (NSMutableArray*)identifiersFromSettings:
|
- (NSMutableArray*)identifiersFromSettings:
|
||||||
(const std::vector<mate::PersistentDictionary>&)settings;
|
(const std::vector<mate::PersistentDictionary>&)settings;
|
||||||
- (void)refreshTouchBarItem:(NSTouchBar*)touchBar
|
- (void)refreshTouchBarItem:(NSTouchBar*)touchBar
|
||||||
id:(const std::string&)item_id;
|
id:(const std::string&)item_id API_AVAILABLE(macosx(10.12.2));
|
||||||
- (void)addNonDefaultTouchBarItems:
|
- (void)addNonDefaultTouchBarItems:
|
||||||
(const std::vector<mate::PersistentDictionary>&)items;
|
(const std::vector<mate::PersistentDictionary>&)items;
|
||||||
- (void)setEscapeTouchBarItem:(const mate::PersistentDictionary&)item
|
- (void)setEscapeTouchBarItem:(const mate::PersistentDictionary&)item
|
||||||
forTouchBar:(NSTouchBar*)touchBar;
|
forTouchBar:(NSTouchBar*)touchBar API_AVAILABLE(macosx(10.12.2));
|
||||||
|
|
||||||
- (NSString*)idFromIdentifier:(NSString*)identifier
|
- (NSString*)idFromIdentifier:(NSString*)identifier
|
||||||
withPrefix:(NSString*)prefix;
|
withPrefix:(NSString*)prefix;
|
||||||
|
@ -51,35 +51,36 @@
|
||||||
|
|
||||||
// Selector actions
|
// Selector actions
|
||||||
- (void)buttonAction:(id)sender;
|
- (void)buttonAction:(id)sender;
|
||||||
- (void)colorPickerAction:(id)sender;
|
- (void)colorPickerAction:(id)sender API_AVAILABLE(macosx(10.12.2));
|
||||||
- (void)sliderAction:(id)sender;
|
- (void)sliderAction:(id)sender API_AVAILABLE(macosx(10.12.2));
|
||||||
|
|
||||||
// Helpers to create touch bar items
|
// Helpers to create touch bar items
|
||||||
- (NSTouchBarItem*)makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier;
|
- (NSTouchBarItem*)makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier
|
||||||
|
API_AVAILABLE(macosx(10.12.2));
|
||||||
- (NSTouchBarItem*)makeButtonForID:(NSString*)id
|
- (NSTouchBarItem*)makeButtonForID:(NSString*)id
|
||||||
withIdentifier:(NSString*)identifier;
|
withIdentifier:(NSString*)identifier API_AVAILABLE(macosx(10.12.2));
|
||||||
- (NSTouchBarItem*)makeLabelForID:(NSString*)id
|
- (NSTouchBarItem*)makeLabelForID:(NSString*)id
|
||||||
withIdentifier:(NSString*)identifier;
|
withIdentifier:(NSString*)identifier API_AVAILABLE(macosx(10.12.2));
|
||||||
- (NSTouchBarItem*)makeColorPickerForID:(NSString*)id
|
- (NSTouchBarItem*)makeColorPickerForID:(NSString*)id
|
||||||
withIdentifier:(NSString*)identifier;
|
withIdentifier:(NSString*)identifier API_AVAILABLE(macosx(10.12.2));
|
||||||
- (NSTouchBarItem*)makeSliderForID:(NSString*)id
|
- (NSTouchBarItem*)makeSliderForID:(NSString*)id
|
||||||
withIdentifier:(NSString*)identifier;
|
withIdentifier:(NSString*)identifier API_AVAILABLE(macosx(10.12.2));
|
||||||
- (NSTouchBarItem*)makePopoverForID:(NSString*)id
|
- (NSTouchBarItem*)makePopoverForID:(NSString*)id
|
||||||
withIdentifier:(NSString*)identifier;
|
withIdentifier:(NSString*)identifier API_AVAILABLE(macosx(10.12.2));
|
||||||
- (NSTouchBarItem*)makeGroupForID:(NSString*)id
|
- (NSTouchBarItem*)makeGroupForID:(NSString*)id
|
||||||
withIdentifier:(NSString*)identifier;
|
withIdentifier:(NSString*)identifier API_AVAILABLE(macosx(10.12.2));
|
||||||
|
|
||||||
// Helpers to update touch bar items
|
// Helpers to update touch bar items
|
||||||
- (void)updateButton:(NSCustomTouchBarItem*)item
|
- (void)updateButton:(NSCustomTouchBarItem*)item
|
||||||
withSettings:(const mate::PersistentDictionary&)settings;
|
withSettings:(const mate::PersistentDictionary&)settings API_AVAILABLE(macosx(10.12.2));
|
||||||
- (void)updateLabel:(NSCustomTouchBarItem*)item
|
- (void)updateLabel:(NSCustomTouchBarItem*)item
|
||||||
withSettings:(const mate::PersistentDictionary&)settings;
|
withSettings:(const mate::PersistentDictionary&)settings API_AVAILABLE(macosx(10.12.2));
|
||||||
- (void)updateColorPicker:(NSColorPickerTouchBarItem*)item
|
- (void)updateColorPicker:(NSColorPickerTouchBarItem*)item
|
||||||
withSettings:(const mate::PersistentDictionary&)settings;
|
withSettings:(const mate::PersistentDictionary&)settings API_AVAILABLE(macosx(10.12.2));
|
||||||
- (void)updateSlider:(NSSliderTouchBarItem*)item
|
- (void)updateSlider:(NSSliderTouchBarItem*)item
|
||||||
withSettings:(const mate::PersistentDictionary&)settings;
|
withSettings:(const mate::PersistentDictionary&)settings API_AVAILABLE(macosx(10.12.2));
|
||||||
- (void)updatePopover:(NSPopoverTouchBarItem*)item
|
- (void)updatePopover:(NSPopoverTouchBarItem*)item
|
||||||
withSettings:(const mate::PersistentDictionary&)settings;
|
withSettings:(const mate::PersistentDictionary&)settings API_AVAILABLE(macosx(10.12.2));
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
- (NSMutableArray*)identifiersFromSettings:(const std::vector<mate::PersistentDictionary>&)dicts {
|
- (NSMutableArray*)identifiersFromSettings:(const std::vector<mate::PersistentDictionary>&)dicts {
|
||||||
NSMutableArray* identifiers = [NSMutableArray array];
|
NSMutableArray* identifiers = [NSMutableArray array];
|
||||||
|
|
||||||
|
if (@available(macOS 10.12.2, *)) {
|
||||||
for (const auto& item : dicts) {
|
for (const auto& item : dicts) {
|
||||||
std::string type;
|
std::string type;
|
||||||
std::string item_id;
|
std::string item_id;
|
||||||
|
@ -77,6 +78,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[identifiers addObject:NSTouchBarItemIdentifierOtherItemsProxy];
|
[identifiers addObject:NSTouchBarItemIdentifierOtherItemsProxy];
|
||||||
|
}
|
||||||
|
|
||||||
return identifiers;
|
return identifiers;
|
||||||
}
|
}
|
||||||
|
@ -116,7 +118,8 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
- (void)refreshTouchBarItem:(NSTouchBar*)touchBar
|
- (void)refreshTouchBarItem:(NSTouchBar*)touchBar
|
||||||
id:(NSTouchBarItemIdentifier)identifier
|
id:(NSTouchBarItemIdentifier)identifier
|
||||||
withType:(const std::string&)item_type
|
withType:(const std::string&)item_type
|
||||||
withSettings:(const mate::PersistentDictionary&)settings {
|
withSettings:(const mate::PersistentDictionary&)settings
|
||||||
|
API_AVAILABLE(macosx(10.12.2)) {
|
||||||
NSTouchBarItem* item = [touchBar itemForIdentifier:identifier];
|
NSTouchBarItem* item = [touchBar itemForIdentifier:identifier];
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
|
|
||||||
|
@ -245,14 +248,14 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
details);
|
details);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)scrubber:(NSScrubber*)scrubber didSelectItemAtIndex:(NSInteger)selectedIndex {
|
- (void)scrubber:(NSScrubber*)scrubber didSelectItemAtIndex:(NSInteger)selectedIndex API_AVAILABLE(macosx(10.12.2)) {
|
||||||
base::DictionaryValue details;
|
base::DictionaryValue details;
|
||||||
details.SetInteger("selectedIndex", selectedIndex);
|
details.SetInteger("selectedIndex", selectedIndex);
|
||||||
details.SetString("type", "select");
|
details.SetString("type", "select");
|
||||||
window_->NotifyTouchBarItemInteraction([scrubber.identifier UTF8String], details);
|
window_->NotifyTouchBarItemInteraction([scrubber.identifier UTF8String], details);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)scrubber:(NSScrubber*)scrubber didHighlightItemAtIndex:(NSInteger)highlightedIndex {
|
- (void)scrubber:(NSScrubber*)scrubber didHighlightItemAtIndex:(NSInteger)highlightedIndex API_AVAILABLE(macosx(10.12.2)) {
|
||||||
base::DictionaryValue details;
|
base::DictionaryValue details;
|
||||||
details.SetInteger("highlightedIndex", highlightedIndex);
|
details.SetInteger("highlightedIndex", highlightedIndex);
|
||||||
details.SetString("type", "highlight");
|
details.SetString("type", "highlight");
|
||||||
|
@ -494,7 +497,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateGroup:(NSGroupTouchBarItem*)item
|
- (void)updateGroup:(NSGroupTouchBarItem*)item
|
||||||
withSettings:(const mate::PersistentDictionary&)settings {
|
withSettings:(const mate::PersistentDictionary&)settings API_AVAILABLE(macosx(10.12.2)) {
|
||||||
|
|
||||||
mate::PersistentDictionary child;
|
mate::PersistentDictionary child;
|
||||||
if (!settings.Get("child", &child)) return;
|
if (!settings.Get("child", &child)) return;
|
||||||
|
@ -505,7 +508,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSTouchBarItem*)makeSegmentedControlForID:(NSString*)id
|
- (NSTouchBarItem*)makeSegmentedControlForID:(NSString*)id
|
||||||
withIdentifier:(NSString*)identifier {
|
withIdentifier:(NSString*)identifier API_AVAILABLE(macosx(10.12.2)) {
|
||||||
std::string s_id([id UTF8String]);
|
std::string s_id([id UTF8String]);
|
||||||
if (![self hasItemWithID:s_id]) return nil;
|
if (![self hasItemWithID:s_id]) return nil;
|
||||||
|
|
||||||
|
@ -525,7 +528,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateSegmentedControl:(NSCustomTouchBarItem*)item
|
- (void)updateSegmentedControl:(NSCustomTouchBarItem*)item
|
||||||
withSettings:(const mate::PersistentDictionary&)settings {
|
withSettings:(const mate::PersistentDictionary&)settings API_AVAILABLE(macosx(10.12.2)) {
|
||||||
|
|
||||||
NSSegmentedControl* control = item.view;
|
NSSegmentedControl* control = item.view;
|
||||||
|
|
||||||
|
@ -582,7 +585,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSTouchBarItem*)makeScrubberForID:(NSString*)id
|
- (NSTouchBarItem*)makeScrubberForID:(NSString*)id
|
||||||
withIdentifier:(NSString*)identifier {
|
withIdentifier:(NSString*)identifier API_AVAILABLE(macosx(10.12.2)) {
|
||||||
std::string s_id([id UTF8String]);
|
std::string s_id([id UTF8String]);
|
||||||
if (![self hasItemWithID:s_id]) return nil;
|
if (![self hasItemWithID:s_id]) return nil;
|
||||||
|
|
||||||
|
@ -606,7 +609,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateScrubber:(NSCustomTouchBarItem*)item
|
- (void)updateScrubber:(NSCustomTouchBarItem*)item
|
||||||
withSettings:(const mate::PersistentDictionary&)settings {
|
withSettings:(const mate::PersistentDictionary&)settings API_AVAILABLE(macosx(10.12.2)) {
|
||||||
NSScrubber* scrubber = item.view;
|
NSScrubber* scrubber = item.view;
|
||||||
|
|
||||||
bool showsArrowButtons = false;
|
bool showsArrowButtons = false;
|
||||||
|
@ -649,7 +652,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
[scrubber reloadData];
|
[scrubber reloadData];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSInteger)numberOfItemsForScrubber:(NSScrubber*)scrubber {
|
- (NSInteger)numberOfItemsForScrubber:(NSScrubber*)scrubber API_AVAILABLE(macosx(10.12.2)) {
|
||||||
std::string s_id([[scrubber identifier] UTF8String]);
|
std::string s_id([[scrubber identifier] UTF8String]);
|
||||||
if (![self hasItemWithID:s_id]) return 0;
|
if (![self hasItemWithID:s_id]) return 0;
|
||||||
|
|
||||||
|
@ -660,7 +663,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSScrubberItemView*)scrubber:(NSScrubber*)scrubber
|
- (NSScrubberItemView*)scrubber:(NSScrubber*)scrubber
|
||||||
viewForItemAtIndex:(NSInteger)index {
|
viewForItemAtIndex:(NSInteger)index API_AVAILABLE(macosx(10.12.2)) {
|
||||||
std::string s_id([[scrubber identifier] UTF8String]);
|
std::string s_id([[scrubber identifier] UTF8String]);
|
||||||
if (![self hasItemWithID:s_id]) return nil;
|
if (![self hasItemWithID:s_id]) return nil;
|
||||||
|
|
||||||
|
@ -694,7 +697,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSSize)scrubber:(NSScrubber *)scrubber layout:(NSScrubberFlowLayout *)layout sizeForItemAtIndex:(NSInteger)itemIndex
|
- (NSSize)scrubber:(NSScrubber *)scrubber layout:(NSScrubberFlowLayout *)layout sizeForItemAtIndex:(NSInteger)itemIndex
|
||||||
{
|
API_AVAILABLE(macosx(10.12.2)) {
|
||||||
NSInteger width = 50;
|
NSInteger width = 50;
|
||||||
NSInteger height = 30;
|
NSInteger height = 30;
|
||||||
NSInteger margin = 15;
|
NSInteger margin = 15;
|
||||||
|
|
|
@ -259,7 +259,7 @@ static const NSTouchBarItemIdentifier NSTouchBarItemIdentifierOtherItemsProxy =
|
||||||
@class NSTouchBarItem;
|
@class NSTouchBarItem;
|
||||||
|
|
||||||
@interface NSWindow (TouchBarSDK)
|
@interface NSWindow (TouchBarSDK)
|
||||||
@property(strong, readonly) NSTouchBar* touchBar;
|
@property(strong, readonly) NSTouchBar* touchBar API_AVAILABLE(macosx(10.12.2));
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif // MAC_OS_X_VERSION_10_12_1
|
#endif // MAC_OS_X_VERSION_10_12_1
|
||||||
|
|
|
@ -29,7 +29,8 @@ class CocoaNotification : public Notification {
|
||||||
void NotificationDisplayed();
|
void NotificationDisplayed();
|
||||||
void NotificationReplied(const std::string& reply);
|
void NotificationReplied(const std::string& reply);
|
||||||
void NotificationActivated();
|
void NotificationActivated();
|
||||||
void NotificationActivated(NSUserNotificationAction* action);
|
void NotificationActivated(NSUserNotificationAction* action)
|
||||||
|
API_AVAILABLE(macosx(10.10));
|
||||||
|
|
||||||
NSUserNotification* notification() const { return notification_; }
|
NSUserNotification* notification() const { return notification_; }
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ void CocoaNotification::Show(const NotificationOptions& options) {
|
||||||
} else {
|
} else {
|
||||||
// All of the rest are appended to the list of additional actions
|
// All of the rest are appended to the list of additional actions
|
||||||
NSString* actionIdentifier = [NSString stringWithFormat:@"%@Action%d", identifier, i];
|
NSString* actionIdentifier = [NSString stringWithFormat:@"%@Action%d", identifier, i];
|
||||||
|
if (@available(macOS 10.10, *)) {
|
||||||
NSUserNotificationAction* notificationAction =
|
NSUserNotificationAction* notificationAction =
|
||||||
[NSUserNotificationAction actionWithIdentifier:actionIdentifier
|
[NSUserNotificationAction actionWithIdentifier:actionIdentifier
|
||||||
title:base::SysUTF16ToNSString(action.text)];
|
title:base::SysUTF16ToNSString(action.text)];
|
||||||
|
@ -76,11 +77,14 @@ void CocoaNotification::Show(const NotificationOptions& options) {
|
||||||
additional_action_indices_.insert(std::make_pair(base::SysNSStringToUTF8(actionIdentifier), i));
|
additional_action_indices_.insert(std::make_pair(base::SysNSStringToUTF8(actionIdentifier), i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if ([additionalActions count] > 0 &&
|
if ([additionalActions count] > 0 &&
|
||||||
[notification_ respondsToSelector:@selector(setAdditionalActions:)]) {
|
[notification_ respondsToSelector:@selector(setAdditionalActions:)]) {
|
||||||
[notification_ setAdditionalActions:additionalActions]; // Requires macOS 10.10
|
if (@available(macOS 10.10, *)) {
|
||||||
|
[notification_ setAdditionalActions:additionalActions];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.has_reply) {
|
if (options.has_reply) {
|
||||||
|
|
|
@ -41,11 +41,15 @@
|
||||||
notification->NotificationActivated();
|
notification->NotificationActivated();
|
||||||
} else if (notif.activationType == NSUserNotificationActivationTypeReplied) {
|
} else if (notif.activationType == NSUserNotificationActivationTypeReplied) {
|
||||||
notification->NotificationReplied([notif.response.string UTF8String]);
|
notification->NotificationReplied([notif.response.string UTF8String]);
|
||||||
} else if (notif.activationType == NSUserNotificationActivationTypeAdditionalActionClicked) {
|
} else {
|
||||||
|
if (@available(macOS 10.10, *)) {
|
||||||
|
if (notif.activationType == NSUserNotificationActivationTypeAdditionalActionClicked) {
|
||||||
notification->NotificationActivated([notif additionalActivationAction]);
|
notification->NotificationActivated([notif additionalActivationAction]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center
|
- (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center
|
||||||
shouldPresentNotification:(NSUserNotification*)notification {
|
shouldPresentNotification:(NSUserNotification*)notification {
|
||||||
|
|
Loading…
Reference in a new issue