Permalink
Fetching contributors…
Cannot retrieve contributors at this time
128 lines (118 sloc) 3.66 KB
diff --git a/browser/aura/views_delegate.cc b/browser/aura/views_delegate.cc
new file mode 100644
index 0000000..851b2a8
--- /dev/null
+++ b/browser/aura/views_delegate.cc
@@ -0,0 +1,22 @@
+// 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/aura/views_delegate.h"
+
+#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
+
+SprocketViewsDelegate::SprocketViewsDelegate() {
+}
+
+SprocketViewsDelegate::~SprocketViewsDelegate() {
+}
+
+void SprocketViewsDelegate::OnBeforeWidgetInit(
+ views::Widget::InitParams* params,
+ views::internal::NativeWidgetDelegate* delegate) {
+ if (!params->native_widget)
+ params->native_widget = new views::DesktopNativeWidgetAura(delegate);
+}
diff --git a/browser/aura/views_delegate.h b/browser/aura/views_delegate.h
new file mode 100644
index 0000000..047905b
--- /dev/null
+++ b/browser/aura/views_delegate.h
@@ -0,0 +1,25 @@
+// 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_AURA_VIEWS_DELEGATE_H_
+#define SPROCKET_BROWSER_AURA_VIEWS_DELEGATE_H_
+
+#include "ui/views/views_delegate.h"
+
+class SprocketViewsDelegate : public views::ViewsDelegate {
+
+ public:
+ SprocketViewsDelegate();
+ ~SprocketViewsDelegate() override;
+
+ void OnBeforeWidgetInit(
+ views::Widget::InitParams* params,
+ views::internal::NativeWidgetDelegate* delegate) override;
+
+ DISALLOW_COPY_AND_ASSIGN(SprocketViewsDelegate);
+};
+
+#endif // SPROCKET_BROWSER_AURA_VIEWS_DELEGATE_H_
diff --git a/browser/aura/window_aura.cc b/browser/aura/window_aura.cc
index 5dc747d..0b39db6 100644
--- a/browser/aura/window_aura.cc
+++ b/browser/aura/window_aura.cc
@@ -6,6 +6,7 @@
#include "sprocket/browser/window.h"
+#include "sprocket/browser/aura/views_delegate.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
@@ -14,13 +15,18 @@
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
+views::ViewsDelegate* SprocketWindow::views_delegate_ = NULL;
+
// static
void SprocketWindow::PlatformInitialize() {
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen());
+ views_delegate_ = new SprocketViewsDelegate;
}
// static
void SprocketWindow::PlatformExit() {
+ delete views_delegate_;
+ views_delegate_ = NULL;
aura::Env::DeleteInstance();
}
diff --git a/browser/window.h b/browser/window.h
index c81731d..cbdcb82 100644
--- a/browser/window.h
+++ b/browser/window.h
@@ -11,6 +11,7 @@
#include "ui/gfx/native_widget_types.h"
namespace views {
+class ViewsDelegate;
class Widget;
}
@@ -30,6 +31,8 @@ class SprocketWindow {
void PlatformCreateWindow(int width, int height);
+ static views::ViewsDelegate* views_delegate_;
+
gfx::NativeWindow window_;
views::Widget* window_widget_;
};
diff --git a/sprocket.gyp b/sprocket.gyp
index 30ebb65..3373926 100644
--- a/sprocket.gyp
+++ b/sprocket.gyp
@@ -24,8 +24,11 @@
'<(DEPTH)/content/content.gyp:content_resources',
'<(DEPTH)/content/content.gyp:content_utility',
'<(DEPTH)/content/content.gyp:content_browser',
+ '<(DEPTH)/ui/views/views.gyp:views',
],
'sources': [
+ 'browser/aura/views_delegate.cc',
+ 'browser/aura/views_delegate.h',
'browser/aura/window_aura.cc',
'browser/window.cc',
'browser/window.h',