}
#endif
+ // 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_) {
window_->set_frame_type(views::Widget::FrameType::FRAME_TYPE_FORCE_NATIVE);
window_->FrameTypeChanged();
#endif
}
+void NativeWindowViews::SetAutoHideMenuBar(bool auto_hide) {
+ menu_bar_autohide_ = auto_hide;
+}
+
+bool NativeWindowViews::IsMenuBarAutoHide() {
+ return menu_bar_autohide_;
+}
+
+void NativeWindowViews::SetMenuBarVisibility(bool visible) {
+ if (!menu_bar_ || menu_bar_visible_ == visible)
+ return;
+
+ // Always show the accelerator when the auto-hide menu bar shows.
+ if (menu_bar_autohide_)
+ menu_bar_->SetAcceleratorVisibility(visible);
+
+ menu_bar_visible_ = visible;
+ if (visible) {
+ DCHECK_EQ(child_count(), 1);
+ AddChildView(menu_bar_.get());
+ } else {
+ DCHECK_EQ(child_count(), 2);
+ RemoveChildView(menu_bar_.get());
+ }
+
+ Layout();
+}
+
+bool NativeWindowViews::IsMenuBarVisible() {
+ return menu_bar_visible_;
+}
+
gfx::AcceleratedWidget NativeWindowViews::GetAcceleratedWidget() {
return GetNativeWindow()->GetHost()->GetAcceleratedWidget();
}
GetWebContents()->Focus();
// Hide menu bar when window is blured.
- if (!active && menu_bar_autohide_ && menu_bar_visible_) {
+ if (!active && menu_bar_autohide_ && menu_bar_visible_)
SetMenuBarVisibility(false);
- Layout();
- }
}
void NativeWindowViews::DeleteDelegate() {
void NativeWindowViews::HandleMouseDown() {
// Hide menu bar when web view is clicked.
- if (menu_bar_autohide_ && menu_bar_visible_) {
+ if (menu_bar_autohide_ && menu_bar_visible_)
SetMenuBarVisibility(false);
- Layout();
- }
}
void NativeWindowViews::HandleKeyboardEvent(
if (event.type == blink::WebInputEvent::RawKeyDown && !IsAltKey(event) &&
IsAltModifier(event)) {
if (!menu_bar_visible_ &&
- (menu_bar_->GetAcceleratorIndex(event.windowsKeyCode) != -1)) {
+ (menu_bar_->GetAcceleratorIndex(event.windowsKeyCode) != -1))
SetMenuBarVisibility(true);
- Layout();
- }
menu_bar_->ActivateAccelerator(event.windowsKeyCode);
return;
}
// When a single Alt is released right after a Alt is pressed:
menu_bar_alt_pressed_ = false;
SetMenuBarVisibility(!menu_bar_visible_);
- Layout();
} else {
// When any other keys except single Alt have been pressed/released:
menu_bar_alt_pressed_ = false;
return window_bounds;
}
-void NativeWindowViews::SetMenuBarVisibility(bool visible) {
- if (!menu_bar_)
- return;
-
- // Always show the accelerator when the auto-hide menu bar shows.
- if (menu_bar_autohide_)
- menu_bar_->SetAcceleratorVisibility(visible);
-
- menu_bar_visible_ = visible;
- if (visible) {
- DCHECK_EQ(child_count(), 1);
- AddChildView(menu_bar_.get());
- } else {
- DCHECK_EQ(child_count(), 2);
- RemoveChildView(menu_bar_.get());
- }
-}
-
// static
NativeWindow* NativeWindow::Create(content::WebContents* web_contents,
const mate::Dictionary& options) {
void SetMenu(ui::MenuModel* menu_model) override;
gfx::NativeWindow GetNativeWindow() override;
void SetProgressBar(double value) override;
+ void SetAutoHideMenuBar(bool auto_hide) override;
+ bool IsMenuBarAutoHide() override;
+ void SetMenuBarVisibility(bool visible) override;
+ bool IsMenuBarVisible() override;
gfx::AcceleratedWidget GetAcceleratedWidget();
// in client area we need to substract/add menu bar's height in convertions.
gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& content_bounds);
- // Show/Hide the menu bar.
- void SetMenuBarVisibility(bool visible);
-
scoped_ptr<views::Widget> window_;
views::View* web_view_; // Managed by inspectable_web_contents_.