#include "browser/native_window_win.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "common/options_switches.h"
#include "content/public/browser/native_web_keyboard_event.h"
base::DictionaryValue* options)
: NativeWindow(web_contents, options),
window_(new views::Widget),
- web_view_(new views::WebView(NULL)) {
+ web_view_(new views::WebView(NULL)),
+ resizable_(true) {
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
+ params.delegate = this;
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
window_->Init(params);
}
void NativeWindowWin::SetTitle(const std::string& title) {
- title_ = title;
+ title_ = UTF8ToUTF16(title);
window_->UpdateWindowTitle();
}
std::string NativeWindowWin::GetTitle() {
- return title_;
+ return UTF16ToUTF8(title_);
}
void NativeWindowWin::FlashFrame(bool flash) {
event.os_event.wParam, event.os_event.lParam);
}
+bool NativeWindowWin::CanResize() const {
+ return resizable_;
+}
+
+bool NativeWindowWin::CanMaximize() const {
+ return resizable_;
+}
+
+string16 NativeWindowWin::GetWindowTitle() const {
+ return title_;
+}
+
+bool NativeWindowWin::ShouldHandleSystemCommands() const {
+ return true;
+}
+
+bool NativeWindowWin::ShouldShowWindowIcon() const {
+ return true;
+}
+
+views::Widget* NativeWindowWin::GetWidget() {
+ return window_.get();
+}
+
+const views::Widget* NativeWindowWin::GetWidget() const {
+ return window_.get();
+}
+
// static
NativeWindow* NativeWindow::Create(content::WebContents* web_contents,
base::DictionaryValue* options) {
#ifndef ATOM_BROWSER_NATIVE_WINDOW_WIN_H_
#define ATOM_BROWSER_NATIVE_WINDOW_WIN_H_
+#include "base/string16.h"
+
#include "base/memory/scoped_ptr.h"
#include "browser/native_window.h"
#include "ui/gfx/size.h"
+#include "ui/views/widget/widget_delegate.h"
namespace views {
class WebView;
namespace atom {
-class NativeWindowWin : public NativeWindow {
+class NativeWindowWin : public NativeWindow,
+ public views::WidgetDelegate {
public:
explicit NativeWindowWin(content::WebContents* web_contents,
base::DictionaryValue* options);
virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
protected:
- // Implementations of content::WebContentsDelegate.
+ // Overridden from content::WebContentsDelegate:
virtual void HandleKeyboardEvent(
content::WebContents*,
const content::NativeWebKeyboardEvent&) OVERRIDE;
+ // Overridden from views::WidgetDelegate:
+ virtual bool CanResize() const OVERRIDE;
+ virtual bool CanMaximize() const OVERRIDE;
+ virtual string16 GetWindowTitle() const OVERRIDE;
+ virtual bool ShouldHandleSystemCommands() const OVERRIDE;
+ virtual bool ShouldShowWindowIcon() const OVERRIDE;
+ virtual views::Widget* GetWidget() OVERRIDE;
+ virtual const views::Widget* GetWidget() const OVERRIDE;
+
private:
scoped_ptr<views::Widget> window_;
views::WebView* web_view_; // managed by window_.
bool resizable_;
- std::string title_;
+ string16 title_;
gfx::Size minimum_size_;
gfx::Size maximum_size_;