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

Side by Side Diff: ui/views/mus/desktop_window_tree_host_mus.cc

Issue 2473233005: Wires up transients for DesktopWindowTreeHostMus (Closed)
Patch Set: super nitty nits Created 4 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
« no previous file with comments | « ui/views/mus/desktop_window_tree_host_mus.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/mus/desktop_window_tree_host_mus.h" 5 #include "ui/views/mus/desktop_window_tree_host_mus.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "ui/aura/client/aura_constants.h" 8 #include "ui/aura/client/aura_constants.h"
9 #include "ui/aura/client/drag_drop_client.h" 9 #include "ui/aura/client/drag_drop_client.h"
10 #include "ui/aura/client/focus_client.h" 10 #include "ui/aura/client/focus_client.h"
(...skipping 28 matching lines...) Expand all
39 bool DesktopWindowTreeHostMus::IsDocked() const { 39 bool DesktopWindowTreeHostMus::IsDocked() const {
40 return window()->GetProperty(aura::client::kShowStateKey) == 40 return window()->GetProperty(aura::client::kShowStateKey) ==
41 ui::SHOW_STATE_DOCKED; 41 ui::SHOW_STATE_DOCKED;
42 } 42 }
43 43
44 void DesktopWindowTreeHostMus::Init(aura::Window* content_window, 44 void DesktopWindowTreeHostMus::Init(aura::Window* content_window,
45 const Widget::InitParams& params) {} 45 const Widget::InitParams& params) {}
46 46
47 void DesktopWindowTreeHostMus::OnNativeWidgetCreated( 47 void DesktopWindowTreeHostMus::OnNativeWidgetCreated(
48 const Widget::InitParams& params) { 48 const Widget::InitParams& params) {
49 if (params.parent && params.parent->GetHost()) {
50 parent_ = static_cast<DesktopWindowTreeHostMus*>(params.parent->GetHost());
51 parent_->children_.insert(this);
52 }
49 native_widget_delegate_->OnNativeWidgetCreated(true); 53 native_widget_delegate_->OnNativeWidgetCreated(true);
50 } 54 }
51 55
52 std::unique_ptr<corewm::Tooltip> DesktopWindowTreeHostMus::CreateTooltip() { 56 std::unique_ptr<corewm::Tooltip> DesktopWindowTreeHostMus::CreateTooltip() {
53 return base::MakeUnique<corewm::TooltipAura>(); 57 return base::MakeUnique<corewm::TooltipAura>();
54 } 58 }
55 59
56 std::unique_ptr<aura::client::DragDropClient> 60 std::unique_ptr<aura::client::DragDropClient>
57 DesktopWindowTreeHostMus::CreateDragDropClient( 61 DesktopWindowTreeHostMus::CreateDragDropClient(
58 DesktopNativeCursorManager* cursor_manager) { 62 DesktopNativeCursorManager* cursor_manager) {
59 // aura-mus handles installing a DragDropClient. 63 // aura-mus handles installing a DragDropClient.
60 return nullptr; 64 return nullptr;
61 } 65 }
62 66
63 void DesktopWindowTreeHostMus::Close() { 67 void DesktopWindowTreeHostMus::Close() {
64 if (close_widget_factory_.HasWeakPtrs()) 68 if (close_widget_factory_.HasWeakPtrs())
65 return; 69 return;
66 70
67 // Close doesn't delete this immediately, as 'this' may still be on the stack 71 // Close doesn't delete this immediately, as 'this' may still be on the stack
68 // resulting in possible crashes when the stack unwindes. 72 // resulting in possible crashes when the stack unwindes.
69 base::ThreadTaskRunnerHandle::Get()->PostTask( 73 base::ThreadTaskRunnerHandle::Get()->PostTask(
70 FROM_HERE, base::Bind(&DesktopWindowTreeHostMus::CloseNow, 74 FROM_HERE, base::Bind(&DesktopWindowTreeHostMus::CloseNow,
71 close_widget_factory_.GetWeakPtr())); 75 close_widget_factory_.GetWeakPtr()));
72 } 76 }
73 77
74 void DesktopWindowTreeHostMus::CloseNow() { 78 void DesktopWindowTreeHostMus::CloseNow() {
75 native_widget_delegate_->OnNativeWidgetDestroying(); 79 native_widget_delegate_->OnNativeWidgetDestroying();
80
81 // If we have children, close them. Use a copy for iteration because they'll
82 // remove themselves from |children_|.
83 std::set<DesktopWindowTreeHostMus*> children_copy = children_;
84 for (DesktopWindowTreeHostMus* child : children_copy)
85 child->CloseNow();
86 DCHECK(children_.empty());
87
88 if (parent_) {
89 parent_->children_.erase(this);
90 parent_ = nullptr;
91 }
92
76 DestroyCompositor(); 93 DestroyCompositor();
77 desktop_native_widget_aura_->OnHostClosed(); 94 desktop_native_widget_aura_->OnHostClosed();
78 } 95 }
79 96
80 aura::WindowTreeHost* DesktopWindowTreeHostMus::AsWindowTreeHost() { 97 aura::WindowTreeHost* DesktopWindowTreeHostMus::AsWindowTreeHost() {
81 return this; 98 return this;
82 } 99 }
83 100
84 void DesktopWindowTreeHostMus::ShowWindowWithState(ui::WindowShowState state) { 101 void DesktopWindowTreeHostMus::ShowWindowWithState(ui::WindowShowState state) {
85 if (state == ui::SHOW_STATE_MAXIMIZED || state == ui::SHOW_STATE_FULLSCREEN || 102 if (state == ui::SHOW_STATE_MAXIMIZED || state == ui::SHOW_STATE_FULLSCREEN ||
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 Widget* widget = native_widget_delegate_->AsWidget(); 353 Widget* widget = native_widget_delegate_->AsWidget();
337 window()->SetProperty(aura::client::kCanMaximizeKey, 354 window()->SetProperty(aura::client::kCanMaximizeKey,
338 widget->widget_delegate()->CanMaximize()); 355 widget->widget_delegate()->CanMaximize());
339 window()->SetProperty(aura::client::kCanMinimizeKey, 356 window()->SetProperty(aura::client::kCanMinimizeKey,
340 widget->widget_delegate()->CanMinimize()); 357 widget->widget_delegate()->CanMinimize());
341 window()->SetProperty(aura::client::kCanResizeKey, 358 window()->SetProperty(aura::client::kCanResizeKey,
342 widget->widget_delegate()->CanResize()); 359 widget->widget_delegate()->CanResize());
343 } 360 }
344 361
345 } // namespace views 362 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/desktop_window_tree_host_mus.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698