OLD | NEW |
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 "chrome/browser/ui/views/tabs/window_finder_mus.h" | 5 #include "chrome/browser/ui/views/tabs/window_finder_mus.h" |
6 | 6 |
| 7 #include "content/public/common/service_manager_connection.h" // nogncheck |
| 8 #include "services/service_manager/runner/common/client_util.h" // nogncheck |
7 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
8 #include "ui/views/mus/native_widget_mus.h" | 10 #include "ui/views/mus/native_widget_mus.h" |
9 #include "ui/views/mus/window_manager_connection.h" | 11 #include "ui/views/mus/window_manager_connection.h" |
10 | 12 |
11 WindowFinderMus::WindowFinderMus() {} | 13 bool GetLocalProcessWindowAtPointMus( |
| 14 const gfx::Point& screen_point, |
| 15 const std::set<gfx::NativeWindow>& ignore, |
| 16 gfx::NativeWindow* out) { |
12 | 17 |
13 WindowFinderMus::~WindowFinderMus() {} | 18 content::ServiceManagerConnection* service_manager_connection = |
| 19 content::ServiceManagerConnection::GetForProcess(); |
| 20 if (!service_manager_connection || !service_manager::ServiceManagerIsRemote()) |
| 21 return false; |
14 | 22 |
15 gfx::NativeWindow WindowFinderMus::GetLocalProcessWindowAtPoint( | |
16 const gfx::Point& screen_point, | |
17 const std::set<gfx::NativeWindow>& ignore) { | |
18 std::set<ui::Window*> mus_windows = | 23 std::set<ui::Window*> mus_windows = |
19 views::WindowManagerConnection::Get()->GetRoots(); | 24 views::WindowManagerConnection::Get()->GetRoots(); |
20 // TODO(erg): Needs to deal with stacking order here. | 25 // TODO(erg): Needs to deal with stacking order here. |
21 | 26 |
22 // For every mus window, look at the associated aura window and see if we're | 27 // For every mus window, look at the associated aura window and see if we're |
23 // in that. | 28 // in that. |
24 for (ui::Window* mus : mus_windows) { | 29 for (ui::Window* mus : mus_windows) { |
25 views::Widget* widget = views::NativeWidgetMus::GetWidgetForWindow(mus); | 30 views::Widget* widget = views::NativeWidgetMus::GetWidgetForWindow(mus); |
26 if (widget && widget->GetWindowBoundsInScreen().Contains(screen_point)) { | 31 if (widget && widget->GetWindowBoundsInScreen().Contains(screen_point)) { |
27 aura::Window* content_window = widget->GetNativeWindow(); | 32 aura::Window* content_window = widget->GetNativeWindow(); |
28 | 33 |
29 // If we were instructed to ignore this window, ignore it. | 34 // If we were instructed to ignore this window, ignore it. |
30 if (base::ContainsKey(ignore, content_window)) | 35 if (base::ContainsKey(ignore, content_window)) |
31 continue; | 36 continue; |
32 | 37 |
33 return content_window; | 38 *out = content_window; |
| 39 return true; |
34 } | 40 } |
35 } | 41 } |
36 | 42 |
37 return nullptr; | 43 return false; |
38 } | 44 } |
OLD | NEW |