| Index: ash/hostwm/host_window_container.cc
|
| diff --git a/ash/hostwm/host_window_container.cc b/ash/hostwm/host_window_container.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..738b0eb284a7aedc20d63115cd8870335ddd0b77
|
| --- /dev/null
|
| +++ b/ash/hostwm/host_window_container.cc
|
| @@ -0,0 +1,108 @@
|
| +// Copyright (c) 2012 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 "ash/hostwm/host_window_container.h"
|
| +#include "ash/wm/property_util.h"
|
| +#include "base/utf_string_conversions.h"
|
| +#include "ui/aura/hostwm/host_window_delegate.h"
|
| +#include "ui/aura/window.h"
|
| +#include "ui/gfx/canvas.h"
|
| +#include "ui/views/widget/widget.h"
|
| +
|
| +namespace ash {
|
| +namespace internal {
|
| +
|
| +class HostWindowWidget : public views::Widget {
|
| + public:
|
| + explicit HostWindowWidget(views::Widget* client_widget)
|
| + : client_widget_(client_widget) {
|
| + }
|
| +
|
| + virtual bool OnKeyEvent(const views::KeyEvent& event) OVERRIDE {
|
| + return false;
|
| + }
|
| +
|
| + virtual void Close() OVERRIDE {
|
| + aura::HostWindowDelegate* delegate = aura::GetHostWindowDelegate(
|
| + client_widget_->GetNativeWindow());
|
| + if (delegate) {
|
| + delegate->CloseWindow();
|
| + return;
|
| + }
|
| + Widget::Close();
|
| + }
|
| +
|
| + private:
|
| + views::Widget* client_widget_;
|
| +};
|
| +
|
| +views::Widget* HostWindowContainer::CreateHostWindowContainerWidget(
|
| + views::Widget* client_widget,
|
| + const gfx::Rect& bounds,
|
| + views::Widget::InitParams::Type type) {
|
| + HostWindowWidget* widget = new HostWindowWidget(client_widget);
|
| + views::Widget::InitParams params(type);
|
| + params.delegate = new HostWindowContainer(client_widget);
|
| + params.parent = NULL;
|
| + params.bounds = bounds;
|
| + widget->Init(params);
|
| + widget->GetNativeView()->SetName("HostWindowContainer");
|
| + SetPersistsAcrossAllWorkspaces(
|
| + widget->GetNativeView(),
|
| + WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES);
|
| + widget->GetNativeView()->AddChild(client_widget->GetNativeView());
|
| + return widget;
|
| +}
|
| +
|
| +HostWindowContainer::HostWindowContainer(views::Widget* client_widget)
|
| + : client_widget_(client_widget) {
|
| +}
|
| +
|
| +HostWindowContainer::~HostWindowContainer() {
|
| +}
|
| +
|
| +void HostWindowContainer::OnPaint(gfx::Canvas* canvas) {
|
| + canvas->FillRect(GetLocalBounds(), SK_ColorDKGRAY);
|
| +}
|
| +
|
| +gfx::Size HostWindowContainer::GetPreferredSize() {
|
| + // TODO(reveman): depends on host window state
|
| + return gfx::Size(1, 1);
|
| +}
|
| +
|
| +void HostWindowContainer::Layout() {
|
| + client_widget_->SetBounds(
|
| + gfx::Rect(gfx::Point(client_widget_->GetNativeView()->bounds().origin()),
|
| + gfx::Size(width(), height())));
|
| +}
|
| +
|
| +string16 HostWindowContainer::GetWindowTitle() const {
|
| + // TODO(danakj): return the real title
|
| + return ASCIIToUTF16("");
|
| +}
|
| +
|
| +views::View* HostWindowContainer::GetContentsView() {
|
| + return this;
|
| +}
|
| +
|
| +bool HostWindowContainer::CanResize() const {
|
| + aura::HostWindowDelegate* delegate = aura::GetHostWindowDelegate(
|
| + client_widget_->GetNativeWindow());
|
| + if (delegate)
|
| + return delegate->CanResize();
|
| +
|
| + return false;
|
| +}
|
| +
|
| +bool HostWindowContainer::CanMaximize() const {
|
| + // TODO(danakj): depends on host window state
|
| + return false;
|
| +}
|
| +
|
| +void HostWindowContainer::DeleteDelegate() {
|
| + delete this;
|
| +}
|
| +
|
| +} // namespace internal
|
| +} // namespace ash
|
|
|