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

Side by Side Diff: ash/common/wm_window.cc

Issue 2320273002: Refactors DimWindow and moves to ash/common (Closed)
Patch Set: git add wm_window Created 4 years, 3 months 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 "ash/mus/bridge/wm_shelf_mus.h"
6
7 #include "ash/common/shelf/shelf_widget.h"
8 #include "ash/common/wm_root_window_controller.h"
9 #include "ash/common/wm_shell.h"
10 #include "ash/common/wm_window.h" 5 #include "ash/common/wm_window.h"
11 6
7 #include "base/memory/ptr_util.h"
8 #include "base/supports_user_data.h"
9
12 namespace ash { 10 namespace ash {
13 namespace mus {
14 11
15 WmShelfMus::WmShelfMus(WmWindow* root_window) { 12 class WmWindow::SupportsUserDataImpl : public base::SupportsUserData {
James Cook 2016/09/09 00:03:35 Is the whole point of this to get around the prote
sky 2016/09/09 03:50:04 I think it's better to keep SUDs destructor protec
16 DCHECK(root_window); 13 public:
17 WmShell::Get()->CreateShelfDelegate(); 14 SupportsUserDataImpl() {}
18 CreateShelfWidget(root_window); 15 ~SupportsUserDataImpl() override {}
19 InitializeShelf(); 16
20 WmShell::Get()->NotifyShelfCreatedForRootWindow(root_window); 17 private:
21 shelf_widget()->PostCreateShelf(); 18 DISALLOW_COPY_AND_ASSIGN(SupportsUserDataImpl);
19 };
20
21 base::SupportsUserData* WmWindow::GetUserData() {
22 return user_data_.get();
22 } 23 }
23 24
24 WmShelfMus::~WmShelfMus() { 25 WmWindow::WmWindow() : user_data_(base::MakeUnique<SupportsUserDataImpl>()) {}
25 ShutdownShelfWidget(); 26
26 DestroyShelfWidget(); 27 WmWindow::~WmWindow() {
27 ShutdownShelf(); 28 // Subclasses should explicitly destroy |user_data_| in destructor to ensure
29 // pure virtual methods are still valid while destroying |user_data_|.
James Cook 2016/09/09 00:03:35 Thanks for documenting this.
30 DCHECK(!user_data_);
28 } 31 }
29 32
30 void WmShelfMus::WillDeleteShelfLayoutManager() { 33 void WmWindow::DestroyUserData() {
31 ShutdownShelfWidget(); 34 user_data_.reset();
32 WmShelf::WillDeleteShelfLayoutManager();
33 } 35 }
34 36
35 } // namespace mus
36 } // namespace ash 37 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698