views: Add menu should not change window size.

This commit is contained in:
Cheng Zhao 2014-07-21 20:58:15 +08:00
parent ffad6fe884
commit 1a79093378
3 changed files with 10 additions and 10 deletions

View file

@ -65,6 +65,7 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents,
menu_bar_(NULL),
web_view_(inspectable_web_contents()->GetView()->GetView()),
keyboard_event_handler_(new views::UnhandledKeyboardEventHandler),
use_content_size_(false),
resizable_(true) {
options.Get(switches::kResizable, &resizable_);
options.Get(switches::kTitle, &title_);
@ -102,10 +103,9 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents,
set_background(views::Background::CreateStandardPanelBackground());
AddChildView(web_view_);
bool use_content_size;
if (has_frame_ &&
options.Get(switches::kUseContentSize, &use_content_size) &&
use_content_size)
options.Get(switches::kUseContentSize, &use_content_size_) &&
use_content_size_)
bounds = ContentBoundsToWindowBounds(bounds);
window_->CenterWindow(bounds.size());
@ -302,7 +302,9 @@ void NativeWindowViews::SetMenu(ui::MenuModel* menu_model) {
gfx::Size content_size = GetContentSize();
menu_bar_ = new MenuBar;
AddChildViewAt(menu_bar_, 0);
SetContentSize(content_size);
if (use_content_size_)
SetContentSize(content_size);
}
menu_bar_->SetMenu(menu_model);

View file

@ -132,6 +132,7 @@ class NativeWindowViews : public NativeWindow,
// Map from accelerator to menu item's command id.
accelerator_util::AcceleratorTable accelerator_table_;
bool use_content_size_;
bool resizable_;
std::string title_;
gfx::Size minimum_size_;

View file

@ -103,12 +103,9 @@ describe 'browser-window module', ->
assert.equal contentSize[1], 400
it 'make window created with window size when not used', ->
# No way to reliably set size when window has not been shown on Linux.
return if process.platform is 'linux'
contentSize = w.getSize()
assert.equal contentSize[0], 400
assert.equal contentSize[1], 400
size = w.getSize()
assert.equal size[0], 400
assert.equal size[1], 400
describe 'beforeunload handler', ->
it 'returning true would not prevent close', (done) ->