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

Side by Side Diff: ui/views/controls/menu/menu_controller_aura.cc

Issue 37733003: Make GetRootWindow() return a Window instead of a RootWindow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/controls/menu/menu_controller.h" 5 #include "ui/views/controls/menu/menu_controller.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "ui/aura/client/activation_change_observer.h" 8 #include "ui/aura/client/activation_change_observer.h"
9 #include "ui/aura/client/activation_client.h" 9 #include "ui/aura/client/activation_client.h"
10 #include "ui/aura/client/dispatcher_client.h" 10 #include "ui/aura/client/dispatcher_client.h"
11 #include "ui/aura/client/drag_drop_client.h" 11 #include "ui/aura/client/drag_drop_client.h"
12 #include "ui/aura/root_window.h" 12 #include "ui/aura/window.h"
13 #include "ui/aura/window_observer.h" 13 #include "ui/aura/window_observer.h"
14 #include "ui/gfx/screen.h" 14 #include "ui/gfx/screen.h"
15 #include "ui/views/widget/widget.h" 15 #include "ui/views/widget/widget.h"
16 16
17 namespace views { 17 namespace views {
18 18
19 namespace { 19 namespace {
20 20
21 // ActivationChangeObserverImpl is used to observe activation changes and close 21 // ActivationChangeObserverImpl is used to observe activation changes and close
22 // the menu. Additionally it listens for the root window to be destroyed and 22 // the menu. Additionally it listens for the root window to be destroyed and
23 // cancel the menu as well. 23 // cancel the menu as well.
24 class ActivationChangeObserverImpl 24 class ActivationChangeObserverImpl
25 : public aura::client::ActivationChangeObserver, 25 : public aura::client::ActivationChangeObserver,
26 public aura::WindowObserver, 26 public aura::WindowObserver,
27 public ui::EventHandler { 27 public ui::EventHandler {
28 public: 28 public:
29 ActivationChangeObserverImpl(MenuController* controller, 29 ActivationChangeObserverImpl(MenuController* controller,
30 aura::RootWindow* root) 30 aura::Window* root)
31 : controller_(controller), 31 : controller_(controller),
32 root_(root) { 32 root_(root) {
33 aura::client::GetActivationClient(root_)->AddObserver(this); 33 aura::client::GetActivationClient(root_)->AddObserver(this);
34 root_->AddObserver(this); 34 root_->AddObserver(this);
35 root_->AddPreTargetHandler(this); 35 root_->AddPreTargetHandler(this);
36 } 36 }
37 37
38 virtual ~ActivationChangeObserverImpl() { 38 virtual ~ActivationChangeObserverImpl() {
39 Cleanup(); 39 Cleanup();
40 } 40 }
(...skipping 23 matching lines...) Expand all
64 aura::client::ActivationClient* client = 64 aura::client::ActivationClient* client =
65 aura::client::GetActivationClient(root_); 65 aura::client::GetActivationClient(root_);
66 if (client) 66 if (client)
67 client->RemoveObserver(this); 67 client->RemoveObserver(this);
68 root_->RemovePreTargetHandler(this); 68 root_->RemovePreTargetHandler(this);
69 root_->RemoveObserver(this); 69 root_->RemoveObserver(this);
70 root_ = NULL; 70 root_ = NULL;
71 } 71 }
72 72
73 MenuController* controller_; 73 MenuController* controller_;
74 aura::RootWindow* root_; 74 aura::Window* root_;
75 75
76 DISALLOW_COPY_AND_ASSIGN(ActivationChangeObserverImpl); 76 DISALLOW_COPY_AND_ASSIGN(ActivationChangeObserverImpl);
77 }; 77 };
78 78
79 aura::RootWindow* GetOwnerRootWindow(views::Widget* owner) { 79 aura::Window* GetOwnerRootWindow(views::Widget* owner) {
80 return owner ? owner->GetNativeWindow()->GetRootWindow() : NULL; 80 return owner ? owner->GetNativeWindow()->GetRootWindow() : NULL;
81 } 81 }
82 82
83 } // namespace 83 } // namespace
84 84
85 void MenuController::RunMessageLoop(bool nested_menu) { 85 void MenuController::RunMessageLoop(bool nested_menu) {
86 // |owner_| may be NULL. 86 // |owner_| may be NULL.
87 aura::RootWindow* root = GetOwnerRootWindow(owner_); 87 aura::Window* root = GetOwnerRootWindow(owner_);
88 if (root) { 88 if (root) {
89 scoped_ptr<ActivationChangeObserverImpl> observer; 89 scoped_ptr<ActivationChangeObserverImpl> observer;
90 if (!nested_menu) 90 if (!nested_menu)
91 observer.reset(new ActivationChangeObserverImpl(this, root)); 91 observer.reset(new ActivationChangeObserverImpl(this, root));
92 aura::client::GetDispatcherClient(root)-> 92 aura::client::GetDispatcherClient(root)->
93 RunWithDispatcher(this, owner_->GetNativeWindow(), true); 93 RunWithDispatcher(this, owner_->GetNativeWindow(), true);
94 } else { 94 } else {
95 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); 95 base::MessageLoopForUI* loop = base::MessageLoopForUI::current();
96 base::MessageLoop::ScopedNestableTaskAllower allow(loop); 96 base::MessageLoop::ScopedNestableTaskAllower allow(loop);
97 base::RunLoop run_loop(this); 97 base::RunLoop run_loop(this);
98 run_loop.Run(); 98 run_loop.Run();
99 } 99 }
100 } 100 }
101 101
102 bool MenuController::ShouldQuitNow() const { 102 bool MenuController::ShouldQuitNow() const {
103 aura::RootWindow* root = GetOwnerRootWindow(owner_); 103 aura::Window* root = GetOwnerRootWindow(owner_);
104 return !aura::client::GetDragDropClient(root) || 104 return !aura::client::GetDragDropClient(root) ||
105 !aura::client::GetDragDropClient(root)->IsDragDropInProgress(); 105 !aura::client::GetDragDropClient(root)->IsDragDropInProgress();
106 } 106 }
107 107
108 gfx::Screen* MenuController::GetScreen() { 108 gfx::Screen* MenuController::GetScreen() {
109 aura::RootWindow* root = GetOwnerRootWindow(owner_); 109 aura::Window* root = GetOwnerRootWindow(owner_);
110 return root ? 110 return root ?
111 gfx::Screen::GetScreenFor(root) : gfx::Screen::GetNativeScreen(); 111 gfx::Screen::GetScreenFor(root) : gfx::Screen::GetNativeScreen();
112 } 112 }
113 113
114 114
115 } // namespace views 115 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/display_change_listener_aura.cc ('k') | ui/views/corewm/capture_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698