return window_->IsVisibleOnAllWorkspaces();
}
-void Window::SetVibrancy(const std::string& type) {
- window_->SetVibrancy(type);
-}
+void Window::SetVibrancy(v8::Local<v8::Value> value, mate::Arguments* args) {
+ std::string type;
-void Window::RemoveVibrancy() {
- window_->RemoveVibrancy();
+ if (value->IsNull()) {
+ window_->SetVibrancy(std::string());
+ } else if (mate::ConvertFromV8(isolate(), value, &type)) {
+ window_->SetVibrancy(type);
+ } else {
+ args->ThrowError("Must pass a string or null");
+ }
}
int32_t Window::ID() const {
.SetMethod("isVisibleOnAllWorkspaces",
&Window::IsVisibleOnAllWorkspaces)
.SetMethod("setVibrancy", &Window::SetVibrancy)
- .SetMethod("removeVibrancy", &Window::RemoveVibrancy)
#if defined(OS_WIN)
.SetMethod("hookWindowMessage", &Window::HookWindowMessage)
.SetMethod("isWindowMessageHooked", &Window::IsWindowMessageHooked)
void SetVisibleOnAllWorkspaces(bool visible);
bool IsVisibleOnAllWorkspaces();
- void SetVibrancy(const std::string& type);
- void RemoveVibrancy();
+ void SetVibrancy(v8::Local<v8::Value> value, mate::Arguments* args);
int32_t ID() const;
v8::Local<v8::Value> WebContents(v8::Isolate* isolate);
parent_ = parent;
}
+void NativeWindow::SetVibrancy(const std::string& filename) {
+}
+
void NativeWindow::FocusOnWebView() {
web_contents()->GetRenderViewHost()->GetWidget()->Focus();
}
virtual bool IsVisibleOnAllWorkspaces() = 0;
// Vibrancy API
- virtual void SetVibrancy(const std::string& type) = 0;
- virtual void RemoveVibrancy() = 0;
+ virtual void SetVibrancy(const std::string& type);
// Webview APIs.
virtual void FocusOnWebView();
void SetVisibleOnAllWorkspaces(bool visible) override;
bool IsVisibleOnAllWorkspaces() override;
void SetVibrancy(const std::string& type) override;
- void RemoveVibrancy() override;
// content::RenderWidgetHost::InputEventObserver:
void OnInputEvent(const blink::WebInputEvent& event) override;
void NativeWindowMac::SetVibrancy(const std::string& type) {
if (!(base::mac::IsOSMavericks() || base::mac::IsOSYosemiteOrLater())) return;
- NSVisualEffectView *vview = (NSVisualEffectView *)vibrant_view_;
- if (vview == nil) {
- vview = [[NSVisualEffectView alloc] initWithFrame:
+ if (type.empty()) {
+ if (vibrant_view_ == nil) return;
+
+ [vibrant_view_ removeFromSuperview];
+ vibrant_view_ = nil;
+
+ return;
+ }
+
+ NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view_;
+ if (effect_view == nil) {
+ effect_view = [[NSVisualEffectView alloc] initWithFrame:
[[window_ contentView] bounds]];
- vibrant_view_ = (NSView *)vview;
+ vibrant_view_ = (NSView*)effect_view;
- [vview setAutoresizingMask:
+ [effect_view setAutoresizingMask:
NSViewWidthSizable | NSViewHeightSizable];
- [vview setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
- [vview setState:NSVisualEffectStateActive];
- [[window_ contentView] addSubview:vview
+ [effect_view setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
+ [effect_view setState:NSVisualEffectStateActive];
+ [[window_ contentView] addSubview:effect_view
positioned:NSWindowBelow
relativeTo:nil];
}
}
}
- [vview setMaterial:vibrancyType];
-}
-
-void NativeWindowMac::RemoveVibrancy() {
- if (vibrant_view_ == nil) return;
-
- [vibrant_view_ removeFromSuperview];
- vibrant_view_ = nil;
+ [effect_view setMaterial:vibrancyType];
}
void NativeWindowMac::OnInputEvent(const blink::WebInputEvent& event) {
`selection`, `menu`, `popover`, `sidebar`, `medium-light` or `ultra-dark`. See
the [macOS documentation][vibrancy-docs] for more details.
-Adds a vibrancy effect to the browser window.
+Adds a vibrancy effect to the browser window. Passing `null` or an empty string
+will remove the vibrancy effect on the window.
[vibrancy-docs]: https://developer.apple.com/reference/appkit/nsvisualeffectview?language=objc
-
-#### `win.removeVibrancy()` _macOS_
-
-Removes the vibrancy effect on the window.