Permalink
Fetching contributors…
Cannot retrieve contributors at this time
110 lines (109 sloc) 2.73 KB
diff --git a/browser/window.cc b/browser/window.cc
new file mode 100644
index 0000000..f6c67a5
--- /dev/null
+++ b/browser/window.cc
@@ -0,0 +1,47 @@
+// Copyright (c) 2015 University of Szeged.
+// Copyright (c) 2015 The Chromium Authors.
+// All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sprocket/browser/window.h"
+
+#include "base/message_loop/message_loop.h"
+
+const int kDefaultWindowWidth = 800;
+const int kDefaultWindowHeight = 600;
+
+// static
+gfx::Size SprocketWindow::AdjustWindowSize(const gfx::Size& initial_size) {
+ if (!initial_size.IsEmpty())
+ return initial_size;
+
+ static gfx::Size default_window_size = gfx::Size(
+ kDefaultWindowWidth, kDefaultWindowHeight);
+
+ return default_window_size;
+}
+
+// static
+void SprocketWindow::Initialize() {
+ PlatformInitialize();
+}
+
+// static
+void SprocketWindow::Deinitialize() {
+ PlatformExit();
+}
+
+// static
+SprocketWindow* SprocketWindow::CreateNewWindow(const gfx::Size& initial_size) {
+ SprocketWindow* window = new SprocketWindow;
+
+ const gfx::Size& size = SprocketWindow::AdjustWindowSize(initial_size);
+ window->PlatformCreateWindow(size.width(), size.height());
+
+ return window;
+}
+
+SprocketWindow::~SprocketWindow() {
+ base::MessageLoop::current()->PostTask(FROM_HERE, base::MessageLoop::QuitClosure());
+}
diff --git a/browser/window.h b/browser/window.h
new file mode 100644
index 0000000..c81731d
--- /dev/null
+++ b/browser/window.h
@@ -0,0 +1,37 @@
+// Copyright (c) 2015 University of Szeged.
+// Copyright (c) 2015 The Chromium Authors.
+// All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SPROCKET_BROWSER_UI_WINDOW_H_
+#define SPROCKET_BROWSER_UI_WINDOW_H_
+
+#include "ui/gfx/geometry/size.h"
+#include "ui/gfx/native_widget_types.h"
+
+namespace views {
+class Widget;
+}
+
+class SprocketWindow {
+
+ public:
+ ~SprocketWindow();
+ static gfx::Size AdjustWindowSize(const gfx::Size& initial_size);
+
+ static void Initialize();
+ static void Deinitialize();
+ static SprocketWindow* CreateNewWindow(const gfx::Size& initial_size);
+
+ private:
+ static void PlatformInitialize();
+ static void PlatformExit();
+
+ void PlatformCreateWindow(int width, int height);
+
+ gfx::NativeWindow window_;
+ views::Widget* window_widget_;
+};
+
+#endif // SPROCKET_BROWSER_UI_WINDOW_H_
diff --git a/sprocket.gyp b/sprocket.gyp
index c173616..a3803a1 100644
--- a/sprocket.gyp
+++ b/sprocket.gyp
@@ -26,6 +26,8 @@
'<(DEPTH)/content/content.gyp:content_browser',
],
'sources': [
+ 'browser/window.cc',
+ 'browser/window.h',
],
},
{