Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: components/exo/shell_surface.cc

Issue 1412093006: components: Add Exosphere component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ShellSurface::SetTitle Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/exo/shell_surface.h"
6
7 #include "ash/shell.h"
8 #include "ash/shell_window_ids.h"
9 #include "base/logging.h"
10 #include "base/trace_event/trace_event.h"
11 #include "base/trace_event/trace_event_argument.h"
12 #include "components/exo/surface.h"
13 #include "ui/aura/window.h"
14 #include "ui/views/widget/widget.h"
15
16 namespace exo {
17
18 ////////////////////////////////////////////////////////////////////////////////
19 // ShellSurface, public:
20
21 ShellSurface::ShellSurface(Surface* surface)
22 : surface_(surface), show_state_(ui::SHOW_STATE_DEFAULT) {
23 surface_->SetSurfaceDelegate(this);
24 }
25
26 ShellSurface::~ShellSurface() {
27 if (surface_)
28 surface_->SetSurfaceDelegate(nullptr);
29 if (widget_)
30 widget_->CloseNow();
31 }
32
33 void ShellSurface::SetFullscreen(bool fullscreen) {
34 TRACE_EVENT1("exo", "ShellSurface::SetFullscreen", "fullscreen", fullscreen);
35
36 show_state_ = fullscreen ? ui::SHOW_STATE_FULLSCREEN : ui::SHOW_STATE_DEFAULT;
37 if (widget_)
38 widget_->SetFullscreen(fullscreen);
39 }
40
41 void ShellSurface::SetTitle(const std::string& title) {
42 TRACE_EVENT1("exo", "ShellSurface::SetTitle", "title", title);
43
44 title_ = title;
45 if (widget_)
46 widget_->UpdateWindowTitle();
47 }
48
49 scoped_refptr<base::trace_event::TracedValue> ShellSurface::AsTracedValue()
50 const {
51 scoped_refptr<base::trace_event::TracedValue> value =
52 new base::trace_event::TracedValue;
53 value->SetString("title", title_);
54 return value;
55 }
56
57 ////////////////////////////////////////////////////////////////////////////////
58 // SurfaceDelegate overrides:
59
60 void ShellSurface::OnSurfaceDestroying() {
61 surface_ = nullptr;
62 }
63
64 void ShellSurface::OnSurfaceCommit() {
65 if (widget_)
66 return;
67
68 views::Widget::InitParams params(
69 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
70 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
71 params.delegate = this;
72 params.shadow_type = views::Widget::InitParams::SHADOW_TYPE_NONE;
73 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
74 params.show_state = show_state_;
75 params.parent = ash::Shell::GetContainer(
76 ash::Shell::GetPrimaryRootWindow(), ash::kShellWindowId_DefaultContainer);
77 widget_.reset(new views::Widget);
78 widget_->Init(params);
79 widget_->GetNativeWindow()->set_owned_by_parent(false);
80 widget_->GetNativeView()->SetName("ShellSurface");
81 widget_->Show();
82 }
83
84 ////////////////////////////////////////////////////////////////////////////////
85 // views::WidgetDelegate overrides:
86
87 std::string ShellSurface::GetWindowName() const {
88 return title_;
89 }
90
91 views::Widget* ShellSurface::GetWidget() {
92 return widget_.get();
93 }
94
95 const views::Widget* ShellSurface::GetWidget() const {
96 return widget_.get();
97 }
98
99 views::View* ShellSurface::GetContentsView() {
100 return surface_;
101 }
102
103 } // namespace exo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698