OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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 "wm/foreign_window_widget.h" |
| 6 |
| 7 #include "ash/shell.h" |
| 8 #include "ash/wm/property_util.h" |
| 9 #include "ui/aura/root_window.h" |
| 10 #include "ui/aura/window.h" |
| 11 #include "ui/gfx/canvas.h" |
| 12 #include "ui/views/widget/widget.h" |
| 13 #include "ui/views/widget/widget_delegate.h" |
| 14 #include "wm/foreign_window.h" |
| 15 |
| 16 namespace wm { |
| 17 |
| 18 ForeignWindowWidget::ForeignWindowWidget(ForeignWindow* foreign_window) |
| 19 : foreign_window_(foreign_window) { |
| 20 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 21 params.delegate = foreign_window->CreateWidgetDelegate(); |
| 22 // TODO(reveman): Add support for multiple root windows. |
| 23 params.context = ash::Shell::GetAllRootWindows()[0]; |
| 24 Init(params); |
| 25 set_focus_on_creation(false); |
| 26 GetNativeView()->SetName("ForeignWindowWidget"); |
| 27 SetPersistsAcrossAllWorkspaces( |
| 28 GetNativeView(), |
| 29 ash::WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); |
| 30 } |
| 31 |
| 32 ForeignWindowWidget::~ForeignWindowWidget() { |
| 33 } |
| 34 |
| 35 void ForeignWindowWidget::Close() { |
| 36 // Call base class Close() when native window has been destroyed. |
| 37 if (foreign_window_->HasBeenDestroyed()) { |
| 38 views::Widget::Close(); |
| 39 return; |
| 40 } |
| 41 |
| 42 foreign_window_->Close(); |
| 43 } |
| 44 |
| 45 // static |
| 46 views::Widget* ForeignWindowWidget::CreateWindow( |
| 47 ForeignWindow* foreign_window) { |
| 48 return new ForeignWindowWidget(foreign_window); |
| 49 } |
| 50 |
| 51 } // namespace wm |
OLD | NEW |