OnWindowLeaveHtmlFullScreen());
}
+void NativeWindow::NotifyWindowExecuteWindowsCommand(
+ const std::string& command) {
+ FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
+ OnExecuteWindowsCommand(command));
+}
+
void NativeWindow::DevToolsFocused() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnDevToolsFocus());
}
void NotifyWindowLeaveFullScreen();
void NotifyWindowEnterHtmlFullScreen();
void NotifyWindowLeaveHtmlFullScreen();
+ void NotifyWindowExecuteWindowsCommand(const std::string& command);
void AddObserver(NativeWindowObserver* obs) {
observers_.AddObserver(obs);
}
-
void RemoveObserver(NativeWindowObserver* obs) {
observers_.RemoveObserver(obs);
}
}
bool has_frame() const { return has_frame_; }
+ bool transparent() const { return transparent_; }
SkRegion* draggable_region() const { return draggable_region_.get(); }
+ bool enable_larger_than_screen() const { return enable_larger_than_screen_; }
+ gfx::ImageSkia icon() const { return icon_; }
void set_has_dialog_attached(bool has_dialog_attached) {
has_dialog_attached_ = has_dialog_attached;
void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) override;
bool OnMessageReceived(const IPC::Message& message) override;
- // Whether window has standard frame.
- bool has_frame_;
-
- // Whether window is transparent.
- bool transparent_;
-
- // Whether window can be resized larger than screen.
- bool enable_larger_than_screen_;
-
- // Window icon.
- gfx::ImageSkia icon_;
-
- // Observers of this window.
- ObserverList<NativeWindowObserver> observers_;
-
private:
// Called when the window needs to update its draggable region.
void UpdateDraggableRegions(
const SkBitmap& bitmap,
content::ReadbackResponse response);
+ // Whether window has standard frame.
+ bool has_frame_;
+
+ // Whether window is transparent.
+ bool transparent_;
+
+ // For custom drag, the whole window is non-draggable and the draggable region
+ // has to been explicitly provided.
+ scoped_ptr<SkRegion> draggable_region_; // used in custom drag.
+
+ // Whether window can be resized larger than screen.
+ bool enable_larger_than_screen_;
+
+ // Window icon.
+ gfx::ImageSkia icon_;
+
// The windows has been closed.
bool is_closed_;
// The page this window is viewing.
brightray::InspectableWebContents* inspectable_web_contents_;
- // For custom drag, the whole window is non-draggable and the draggable region
- // has to been explicitly provided.
- scoped_ptr<SkRegion> draggable_region_; // used in custom drag.
+ // Observers of this window.
+ ObserverList<NativeWindowObserver> observers_;
base::WeakPtrFactory<NativeWindow> weak_factory_;
NSUInteger styleMask = NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask | NSResizableWindowMask;
- if (!useStandardWindow || transparent_ || !has_frame_) {
+ if (!useStandardWindow || transparent() || !has_frame()) {
styleMask |= NSTexturedBackgroundWindowMask;
}
backing:NSBackingStoreBuffered
defer:YES]);
[window_ setShell:this];
- [window_ setEnableLargerThanScreen:enable_larger_than_screen_];
+ [window_ setEnableLargerThanScreen:enable_larger_than_screen()];
window_delegate_.reset([[AtomNSWindowDelegate alloc] initWithShell:this]);
[window_ setDelegate:window_delegate_];
- if (transparent_) {
+ if (transparent()) {
// Make window has transparent background.
[window_ setOpaque:NO];
[window_ setHasShadow:NO];
}
// Remove non-transparent corners, see http://git.io/vfonD.
- if (!has_frame_)
+ if (!has_frame())
[window_ setOpaque:NO];
// We will manage window's lifetime ourselves.
// On OS X the initial window size doesn't include window frame.
bool use_content_size = false;
options.Get(switches::kUseContentSize, &use_content_size);
- if (!has_frame_ || !use_content_size)
+ if (!has_frame() || !use_content_size)
SetSize(gfx::Size(width, height));
// Enable the NSView to accept first mouse event.
}
void NativeWindowMac::SetContentSize(const gfx::Size& size) {
- if (!has_frame_) {
+ if (!has_frame()) {
SetSize(size);
return;
}
}
gfx::Size NativeWindowMac::GetContentSize() {
- if (!has_frame_)
+ if (!has_frame())
return GetSize();
NSRect bounds = [[window_ contentView] bounds];
void NativeWindowMac::SetTitle(const std::string& title) {
// We don't want the title to show in transparent window.
- if (transparent_)
+ if (transparent())
return;
[window_ setTitle:base::SysUTF8ToNSString(title)];
void NativeWindowMac::InstallView() {
NSView* view = inspectable_web_contents()->GetView()->GetNativeView();
- if (has_frame_) {
+ if (has_frame()) {
// Add layer with white background for the contents view.
base::scoped_nsobject<CALayer> layer([[CALayer alloc] init]);
[layer setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)];
options.Get(switches::kResizable, &resizable_);
#endif
- if (enable_larger_than_screen_)
+ if (enable_larger_than_screen())
// We need to set a default maximum window size here otherwise Windows
// will not allow us to resize the window larger than scree.
// Setting directly to INT_MAX somehow doesn't work, so we just devide
params.bounds = bounds;
params.delegate = this;
params.type = views::Widget::InitParams::TYPE_WINDOW;
- params.remove_standard_frame = !has_frame_;
+ params.remove_standard_frame = !has_frame();
- if (transparent_)
+ if (transparent())
params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
#if defined(USE_X11)
set_background(views::Background::CreateStandardPanelBackground());
AddChildView(web_view_);
- if (has_frame_ &&
+ if (has_frame() &&
options.Get(switches::kUseContentSize, &use_content_size_) &&
use_content_size_)
bounds = ContentBoundsToWindowBounds(bounds);
#if defined(OS_WIN)
- if (!has_frame_) {
+ if (!has_frame()) {
// Set Window style so that we get a minimize and maximize animation when
// frameless.
DWORD frame_style = WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX |
WS_CAPTION;
// We should not show a frame for transparent window.
- if (transparent_)
+ if (transparent())
frame_style &= ~(WS_THICKFRAME | WS_CAPTION);
::SetWindowLong(GetAcceleratedWidget(), GWL_STYLE, frame_style);
}
- if (transparent_) {
+ if (transparent()) {
// Transparent window on Windows has to have WS_EX_COMPOSITED style.
LONG ex_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE);
ex_style |= WS_EX_COMPOSITED;
// TODO(zcbenz): This was used to force using native frame on Windows 2003, we
// should check whether setting it in InitParams can work.
- if (has_frame_) {
+ if (has_frame()) {
window_->set_frame_type(views::Widget::FrameType::FRAME_TYPE_FORCE_NATIVE);
window_->FrameTypeChanged();
}
// The given window is most likely not rectangular since it uses
// transparency and has no standard frame, don't show a shadow for it.
- if (transparent_ && !has_frame_)
+ if (transparent() && !has_frame())
wm::SetShadowType(GetNativeWindow(), wm::SHADOW_TYPE_NONE);
window_->UpdateWindowIcon();
}
void NativeWindowViews::SetContentSize(const gfx::Size& size) {
- if (!has_frame_) {
+ if (!has_frame()) {
NativeWindow::SetSize(size);
return;
}
}
gfx::Size NativeWindowViews::GetContentSize() {
- if (!has_frame_)
+ if (!has_frame())
return GetSize();
gfx::Size content_size =
#endif
// Do not show menu bar in frameless window.
- if (!has_frame_)
+ if (!has_frame())
return;
if (!menu_bar_) {
}
gfx::ImageSkia NativeWindowViews::GetWindowAppIcon() {
- return icon_;
+ return icon();
}
gfx::ImageSkia NativeWindowViews::GetWindowIcon() {
return false;
// And the events on border for dragging resizable frameless window.
- if (!has_frame_ && CanResize()) {
+ if (!has_frame() && CanResize()) {
FramelessView* frame = static_cast<FramelessView*>(
window_->non_client_view()->frame_view());
return frame->ResizingBorderHitTest(location) == HTNOWHERE;
frame_view->Init(this, widget);
return frame_view;
#else
- if (has_frame_) {
+ if (has_frame()) {
return new NativeFrameView(this, widget);
} else {
FramelessView* frame_view = new FramelessView;
NotifyWindowMaximize();
} else {
std::string command = AppCommandToString(command_id);
- FOR_EACH_OBSERVER(NativeWindowObserver,
- observers_,
- OnExecuteWindowsCommand(command));
+ NotifyWindowExecuteWindowsCommand(command);
}
return false;
}