| Index: components/exo/shell_surface.cc
|
| diff --git a/components/exo/shell_surface.cc b/components/exo/shell_surface.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e7c41c7b9629eb583b9b178a66684287929ae374
|
| --- /dev/null
|
| +++ b/components/exo/shell_surface.cc
|
| @@ -0,0 +1,103 @@
|
| +// Copyright 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 "components/exo/shell_surface.h"
|
| +
|
| +#include "ash/shell.h"
|
| +#include "ash/shell_window_ids.h"
|
| +#include "base/logging.h"
|
| +#include "base/trace_event/trace_event.h"
|
| +#include "base/trace_event/trace_event_argument.h"
|
| +#include "components/exo/surface.h"
|
| +#include "ui/aura/window.h"
|
| +#include "ui/views/widget/widget.h"
|
| +
|
| +namespace exo {
|
| +
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// ShellSurface, public:
|
| +
|
| +ShellSurface::ShellSurface(Surface* surface)
|
| + : surface_(surface), show_state_(ui::SHOW_STATE_DEFAULT) {
|
| + surface_->SetSurfaceDelegate(this);
|
| +}
|
| +
|
| +ShellSurface::~ShellSurface() {
|
| + if (surface_)
|
| + surface_->SetSurfaceDelegate(nullptr);
|
| + if (widget_)
|
| + widget_->CloseNow();
|
| +}
|
| +
|
| +void ShellSurface::SetFullscreen(bool fullscreen) {
|
| + TRACE_EVENT1("exo", "ShellSurface::SetFullscreen", "fullscreen", fullscreen);
|
| +
|
| + show_state_ = fullscreen ? ui::SHOW_STATE_FULLSCREEN : ui::SHOW_STATE_DEFAULT;
|
| + if (widget_)
|
| + widget_->SetFullscreen(fullscreen);
|
| +}
|
| +
|
| +void ShellSurface::SetTitle(const std::string& title) {
|
| + TRACE_EVENT1("exo", "ShellSurface::SetTitle", "title", title);
|
| +
|
| + title_ = title;
|
| + if (widget_)
|
| + widget_->UpdateWindowTitle();
|
| +}
|
| +
|
| +scoped_refptr<base::trace_event::TracedValue> ShellSurface::AsTracedValue()
|
| + const {
|
| + scoped_refptr<base::trace_event::TracedValue> value =
|
| + new base::trace_event::TracedValue;
|
| + value->SetString("title", title_);
|
| + return value;
|
| +}
|
| +
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// SurfaceDelegate overrides:
|
| +
|
| +void ShellSurface::OnSurfaceDestroying() {
|
| + surface_ = nullptr;
|
| +}
|
| +
|
| +void ShellSurface::OnSurfaceCommit() {
|
| + if (widget_)
|
| + return;
|
| +
|
| + views::Widget::InitParams params(
|
| + views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
|
| + params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
|
| + params.delegate = this;
|
| + params.shadow_type = views::Widget::InitParams::SHADOW_TYPE_NONE;
|
| + params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
|
| + params.show_state = show_state_;
|
| + params.parent = ash::Shell::GetContainer(
|
| + ash::Shell::GetPrimaryRootWindow(), ash::kShellWindowId_DefaultContainer);
|
| + widget_.reset(new views::Widget);
|
| + widget_->Init(params);
|
| + widget_->GetNativeWindow()->set_owned_by_parent(false);
|
| + widget_->GetNativeView()->SetName("ShellSurface");
|
| + widget_->Show();
|
| +}
|
| +
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// views::WidgetDelegate overrides:
|
| +
|
| +std::string ShellSurface::GetWindowName() const {
|
| + return title_;
|
| +}
|
| +
|
| +views::Widget* ShellSurface::GetWidget() {
|
| + return widget_.get();
|
| +}
|
| +
|
| +const views::Widget* ShellSurface::GetWidget() const {
|
| + return widget_.get();
|
| +}
|
| +
|
| +views::View* ShellSurface::GetContentsView() {
|
| + return surface_;
|
| +}
|
| +
|
| +} // namespace exo
|
|
|