OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 "ash/mus/frame/detached_title_area_renderer.h" |
| 6 |
| 7 #include "ash/common/frame/header_view.h" |
| 8 #include "ash/mus/frame/detached_title_area_renderer_host.h" |
| 9 #include "services/ui/public/cpp/window.h" |
| 10 #include "ui/views/mus/native_widget_mus.h" |
| 11 #include "ui/views/view.h" |
| 12 #include "ui/views/widget/widget.h" |
| 13 |
| 14 namespace ash { |
| 15 namespace mus { |
| 16 |
| 17 DetachedTitleAreaRenderer::DetachedTitleAreaRenderer( |
| 18 DetachedTitleAreaRendererHost* host, |
| 19 views::Widget* frame, |
| 20 ui::Window* window, |
| 21 Source source) |
| 22 : host_(host), frame_(frame), widget_(new views::Widget) { |
| 23 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
| 24 params.delegate = this; |
| 25 params.name = "DetachedTitleAreaRenderer"; |
| 26 params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; |
| 27 params.native_widget = new views::NativeWidgetMus( |
| 28 widget_, window, ui::mojom::SurfaceType::UNDERLAY); |
| 29 widget_->Init(params); |
| 30 HeaderView* header_view = new HeaderView(frame_); |
| 31 if (source == Source::CLIENT) { |
| 32 // HeaderView behaves differently when the widget it is associated with is |
| 33 // fullscreen (HeaderView is normally the |
| 34 // ImmersiveFullscreenControllerDelegate). Set this as when creating for |
| 35 // the client HeaderView is not the ImmersiveFullscreenControllerDelegate. |
| 36 header_view->set_is_immersive_delegate(false); |
| 37 } |
| 38 widget_->SetContentsView(header_view); |
| 39 widget_->GetRootView()->SetSize(window->bounds().size()); |
| 40 widget_->ShowInactive(); |
| 41 } |
| 42 |
| 43 void DetachedTitleAreaRenderer::Destroy() { |
| 44 host_ = nullptr; |
| 45 if (widget_) |
| 46 widget_->CloseNow(); |
| 47 } |
| 48 |
| 49 views::Widget* DetachedTitleAreaRenderer::GetWidget() { |
| 50 return widget_; |
| 51 } |
| 52 |
| 53 const views::Widget* DetachedTitleAreaRenderer::GetWidget() const { |
| 54 return widget_; |
| 55 } |
| 56 |
| 57 void DetachedTitleAreaRenderer::DeleteDelegate() { |
| 58 if (host_) |
| 59 host_->OnDetachedTitleAreaRendererDestroyed(this); |
| 60 delete this; |
| 61 } |
| 62 |
| 63 DetachedTitleAreaRenderer::~DetachedTitleAreaRenderer() {} |
| 64 |
| 65 } // namespace mus |
| 66 } // namespace ash |
OLD | NEW |