Merge pull request #10508 from danielma/dma/native-tab-new-button

feat(NativeWindowMac): addTabbedWindow
This commit is contained in:
Cheng Zhao 2017-10-03 20:16:50 +09:00 committed by GitHub
commit 745fa707dd
8 changed files with 36 additions and 0 deletions

View file

@ -938,6 +938,10 @@ void Window::ToggleTabBar() {
window_->ToggleTabBar();
}
void Window::AddTabbedWindow(NativeWindow* window) {
window_->AddTabbedWindow(window);
}
void Window::SetVibrancy(mate::Arguments* args) {
std::string type;
@ -1085,6 +1089,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
.SetMethod("selectNextTab", &Window::SelectNextTab)
.SetMethod("moveTabToNewWindow", &Window::MoveTabToNewWindow)
.SetMethod("toggleTabBar", &Window::ToggleTabBar)
.SetMethod("addTabbedWindow", &Window::AddTabbedWindow)
#endif
.SetMethod("setVibrancy", &Window::SetVibrancy)
.SetMethod("_setTouchBarItems", &Window::SetTouchBar)

View file

@ -219,6 +219,7 @@ class Window : public mate::TrackableObject<Window>,
void MergeAllWindows();
void MoveTabToNewWindow();
void ToggleTabBar();
void AddTabbedWindow(NativeWindow* window);
void SetVibrancy(mate::Arguments* args);
void SetTouchBar(const std::vector<mate::PersistentDictionary>& items);

View file

@ -351,6 +351,9 @@ void NativeWindow::MoveTabToNewWindow() {
void NativeWindow::ToggleTabBar() {
}
void NativeWindow::AddTabbedWindow(NativeWindow* window) {
}
void NativeWindow::SetVibrancy(const std::string& filename) {
}

View file

@ -190,6 +190,7 @@ class NativeWindow : public base::SupportsUserData,
virtual void MergeAllWindows();
virtual void MoveTabToNewWindow();
virtual void ToggleTabBar();
virtual void AddTabbedWindow(NativeWindow* window);
// Webview APIs.
virtual void FocusOnWebView();

View file

@ -108,6 +108,7 @@ class NativeWindowMac : public NativeWindow,
void MergeAllWindows() override;
void MoveTabToNewWindow() override;
void ToggleTabBar() override;
void AddTabbedWindow(NativeWindow* window) override;
void SetVibrancy(const std::string& type) override;
void SetTouchBar(

View file

@ -474,6 +474,7 @@ enum {
@interface NSWindow (SierraSDK)
- (void)setTabbingMode:(NSInteger)mode;
- (void)setTabbingIdentifier:(NSString*)identifier;
- (void)addTabbedWindow:(NSWindow*)window ordered:(NSWindowOrderingMode)ordered;
- (IBAction)selectPreviousTab:(id)sender;
- (IBAction)selectNextTab:(id)sender;
- (IBAction)mergeAllWindows:(id)sender;
@ -1649,6 +1650,12 @@ void NativeWindowMac::ToggleTabBar() {
}
}
void NativeWindowMac::AddTabbedWindow(NativeWindow* window) {
if ([window_ respondsToSelector:@selector(addTabbedWindow:ordered:)]) {
[window_ addTabbedWindow:window->GetNativeWindow() ordered:NSWindowAbove];
}
}
void NativeWindowMac::SetVibrancy(const std::string& type) {
if (!base::mac::IsAtLeastOS10_10()) return;

View file

@ -1401,6 +1401,12 @@ there is more than one tab in the current window.
Toggles the visibility of the tab bar if native tabs are enabled and
there is only one tab in the current window.
#### `win.addTabbedWindow(browserWindow)` _macOS_
* `browserWindow` BrowserWindow
Adds a window as a tab on this window, after the tab for the window instance.
#### `win.setVibrancy(type)` _macOS_
* `type` String - Can be `appearance-based`, `light`, `dark`, `titlebar`,

View file

@ -709,6 +709,18 @@ describe('BrowserWindow module', function () {
})
})
describe('BrowserWindow.addTabbedWindow()', function () {
it('does not throw', function () {
if (process.platform !== 'darwin') {
return
}
assert.doesNotThrow(() => {
w.addTabbedWindow(new BrowserWindow({}))
})
})
})
describe('BrowserWindow.setVibrancy(type)', function () {
it('allows setting, changing, and removing the vibrancy', function () {
assert.doesNotThrow(function () {