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

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

Issue 2473233005: Wires up transients for DesktopWindowTreeHostMus (Closed)
Patch Set: 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
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 DCHECK(parent_);
msw 2016/11/04 23:21:43 nit: seems unnecessary to DCHECK a non-null value
sky 2016/11/04 23:30:50 Done.
52 parent_->children_.insert(this);
53 }
49 native_widget_delegate_->OnNativeWidgetCreated(true); 54 native_widget_delegate_->OnNativeWidgetCreated(true);
50 } 55 }
51 56
52 std::unique_ptr<corewm::Tooltip> DesktopWindowTreeHostMus::CreateTooltip() { 57 std::unique_ptr<corewm::Tooltip> DesktopWindowTreeHostMus::CreateTooltip() {
53 return base::MakeUnique<corewm::TooltipAura>(); 58 return base::MakeUnique<corewm::TooltipAura>();
54 } 59 }
55 60
56 std::unique_ptr<aura::client::DragDropClient> 61 std::unique_ptr<aura::client::DragDropClient>
57 DesktopWindowTreeHostMus::CreateDragDropClient( 62 DesktopWindowTreeHostMus::CreateDragDropClient(
58 DesktopNativeCursorManager* cursor_manager) { 63 DesktopNativeCursorManager* cursor_manager) {
59 // aura-mus handles installing a DragDropClient. 64 // aura-mus handles installing a DragDropClient.
60 return nullptr; 65 return nullptr;
61 } 66 }
62 67
63 void DesktopWindowTreeHostMus::Close() { 68 void DesktopWindowTreeHostMus::Close() {
64 if (close_widget_factory_.HasWeakPtrs()) 69 if (close_widget_factory_.HasWeakPtrs())
65 return; 70 return;
66 71
67 // Close doesn't delete this immediately, as 'this' may still be on the stack 72 // Close doesn't delete this immediately, as 'this' may still be on the stack
68 // resulting in possible crashes when the stack unwindes. 73 // resulting in possible crashes when the stack unwindes.
69 base::ThreadTaskRunnerHandle::Get()->PostTask( 74 base::ThreadTaskRunnerHandle::Get()->PostTask(
70 FROM_HERE, base::Bind(&DesktopWindowTreeHostMus::CloseNow, 75 FROM_HERE, base::Bind(&DesktopWindowTreeHostMus::CloseNow,
71 close_widget_factory_.GetWeakPtr())); 76 close_widget_factory_.GetWeakPtr()));
72 } 77 }
73 78
74 void DesktopWindowTreeHostMus::CloseNow() { 79 void DesktopWindowTreeHostMus::CloseNow() {
80 // If we have children, close them. Use a copy for iteration because they'll
81 // remove themselves from |children_|.
82 std::set<DesktopWindowTreeHostMus*> children_copy = children_;
83 for (DesktopWindowTreeHostMus* child : children_copy)
msw 2016/11/04 23:21:43 totally optional nit: convert the corresponding De
sky 2016/11/04 23:30:50 I'm leaving that code alone.
84 child->CloseNow();
85 DCHECK(children_.empty());
86
87 if (parent_) {
88 parent_->children_.erase(this);
89 parent_ = nullptr;
90 }
91
75 native_widget_delegate_->OnNativeWidgetDestroying(); 92 native_widget_delegate_->OnNativeWidgetDestroying();
msw 2016/11/04 23:21:43 q: DesktopWindowTreeHostX11 orders this before chi
sky 2016/11/04 23:30:50 Good catch. Updated.
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
« ui/views/mus/desktop_window_tree_host_mus.h ('K') | « 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