: NativeWindow(web_contents, options),
window_(new views::Widget),
web_view_(new views::WebView(NULL)),
+ use_content_size_(false),
resizable_(true) {
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
params.delegate = this;
options->GetInteger(switches::kWidth, &width);
options->GetInteger(switches::kHeight, &height);
- bool use_content_size = false;
- options->GetBoolean(switches::kUseContentSize, &use_content_size);
- if (has_frame_ && use_content_size) {
- gfx::Size window = window_->GetWindowBoundsInScreen().size();
- gfx::Size client = window_->GetClientAreaBoundsInScreen().size();
- width += window.width() - client.width();
- height += window.height() - client.height();
- }
-
gfx::Size size(width, height);
- window_->CenterWindow(size);
+ options->GetBoolean(switches::kUseContentSize, &use_content_size_);
+ if (has_frame_ && use_content_size_)
+ ClientAreaSizeToWindowSize(&size);
+ window_->CenterWindow(size);
window_->UpdateWindowIcon();
web_view_->SetWebContents(web_contents);
}
void NativeWindowWin::SetContentSize(const gfx::Size& size) {
- // FIXME
+ gfx::Size resized(size);
+ ClientAreaSizeToWindowSize(&resized);
+ SetSize(resized);
}
gfx::Size NativeWindowWin::GetContentSize() {
RegisterAccelerators();
// Resize the window so SetMenu won't change client area size.
- gfx::Size size = GetSize();
- size.set_height(size.height() + GetSystemMetrics(SM_CYMENU));
- SetSize(size);
+ if (use_content_size_) {
+ gfx::Size size = GetSize();
+ size.set_height(size.height() + GetSystemMetrics(SM_CYMENU));
+ SetSize(size);
+ }
}
void NativeWindowWin::UpdateDraggableRegions(
return new NativeWindowFramelessView(widget, this);
}
+void NativeWindowWin::ClientAreaSizeToWindowSize(gfx::Size* size) {
+ gfx::Size window = window_->GetWindowBoundsInScreen().size();
+ gfx::Size client = window_->GetClientAreaBoundsInScreen().size();
+ size->set_width(size->width() + window.width() - client.width());
+ size->set_height(size->height() + window.height() - client.height());
+}
+
void NativeWindowWin::OnViewWasResized() {
// Set the window shape of the RWHV.
gfx::Size sz = web_view_->size();