OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/chromeos/arc/voice_interaction/arc_voice_interaction_fr
amework_service.h" | 5 #include "chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_fr
amework_service.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/accelerators/accelerator_controller.h" | 10 #include "ash/accelerators/accelerator_controller.h" |
| 11 #include "ash/public/cpp/shell_window_ids.h" |
11 #include "ash/shell.h" | 12 #include "ash/shell.h" |
12 #include "base/bind.h" | 13 #include "base/bind.h" |
13 #include "base/command_line.h" | 14 #include "base/command_line.h" |
14 #include "base/containers/flat_set.h" | 15 #include "base/containers/flat_set.h" |
15 #include "base/logging.h" | 16 #include "base/logging.h" |
16 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
17 #include "base/task_scheduler/post_task.h" | 18 #include "base/task_scheduler/post_task.h" |
18 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/browser/ui/browser_list.h" | 20 #include "chrome/browser/ui/browser_list.h" |
20 #include "chrome/browser/ui/browser_window.h" | 21 #include "chrome/browser/ui/browser_window.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 53 |
53 std::unique_ptr<ui::LayerTreeOwner> CreateLayerTreeForSnapshot( | 54 std::unique_ptr<ui::LayerTreeOwner> CreateLayerTreeForSnapshot( |
54 aura::Window* root_window) { | 55 aura::Window* root_window) { |
55 using LayerSet = base::flat_set<const ui::Layer*>; | 56 using LayerSet = base::flat_set<const ui::Layer*>; |
56 LayerSet blocked_layers; | 57 LayerSet blocked_layers; |
57 for (auto* browser : *BrowserList::GetInstance()) { | 58 for (auto* browser : *BrowserList::GetInstance()) { |
58 if (browser->profile()->IsOffTheRecord()) | 59 if (browser->profile()->IsOffTheRecord()) |
59 blocked_layers.insert(browser->window()->GetNativeWindow()->layer()); | 60 blocked_layers.insert(browser->window()->GetNativeWindow()->layer()); |
60 } | 61 } |
61 | 62 |
| 63 LayerSet excluded_layers; |
| 64 // For the best UX the metalayer has to be excluded from the snapshot. |
| 65 // It is currently impossible to identify the metalayer among others layers |
| 66 // under kShellWindowId_SystemModalContainer. Other layers in this container |
| 67 // are not relevant for this kind of snapshot, so it is safe to exclude all |
| 68 // of them. |
| 69 aura::Window* modal_container = ash::Shell::GetContainer( |
| 70 root_window, ash::kShellWindowId_SystemModalContainer); |
| 71 if (modal_container != nullptr) |
| 72 excluded_layers.insert(modal_container->layer()); |
| 73 |
62 auto layer_tree_owner = ::wm::RecreateLayersWithClosure( | 74 auto layer_tree_owner = ::wm::RecreateLayersWithClosure( |
63 root_window, base::BindRepeating( | 75 root_window, base::BindRepeating( |
64 [](LayerSet blocked_layers, | 76 [](LayerSet blocked_layers, LayerSet excluded_layers, |
65 ui::LayerOwner* owner) -> std::unique_ptr<ui::Layer> { | 77 ui::LayerOwner* owner) -> std::unique_ptr<ui::Layer> { |
66 // Parent layer is excluded meaning that it's pointless | 78 // Parent layer is excluded meaning that it's pointless |
67 // to clone current child and all its descendants. This | 79 // to clone current child and all its descendants. This |
68 // reduces the number of layers to create. | 80 // reduces the number of layers to create. |
69 if (blocked_layers.count(owner->layer()->parent())) | 81 if (blocked_layers.count(owner->layer()->parent())) |
70 return nullptr; | 82 return nullptr; |
71 if (blocked_layers.count(owner->layer())) { | 83 if (blocked_layers.count(owner->layer())) { |
72 auto layer = base::MakeUnique<ui::Layer>( | 84 auto layer = base::MakeUnique<ui::Layer>( |
73 ui::LayerType::LAYER_SOLID_COLOR); | 85 ui::LayerType::LAYER_SOLID_COLOR); |
74 layer->SetBounds(owner->layer()->bounds()); | 86 layer->SetBounds(owner->layer()->bounds()); |
75 layer->SetColor(SK_ColorBLACK); | 87 layer->SetColor(SK_ColorBLACK); |
76 return layer; | 88 return layer; |
77 } | 89 } |
| 90 if (excluded_layers.count(owner->layer())) |
| 91 return nullptr; |
78 return owner->RecreateLayer(); | 92 return owner->RecreateLayer(); |
79 }, | 93 }, |
80 std::move(blocked_layers))); | 94 std::move(blocked_layers), std::move(excluded_layers))); |
81 | 95 |
82 // layer_tree_owner cannot be null since we are starting off from the root | 96 // layer_tree_owner cannot be null since we are starting off from the root |
83 // window, which could never be incognito. | 97 // window, which could never be incognito. |
84 DCHECK(layer_tree_owner); | 98 DCHECK(layer_tree_owner); |
85 | 99 |
86 auto* root_layer = layer_tree_owner->root(); | 100 auto* root_layer = layer_tree_owner->root(); |
87 root_window->layer()->Add(root_layer); | 101 root_window->layer()->Add(root_layer); |
88 root_window->layer()->StackAtBottom(root_layer); | 102 root_window->layer()->StackAtBottom(root_layer); |
89 return layer_tree_owner; | 103 return layer_tree_owner; |
90 } | 104 } |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 SetMetalayerVisibility); | 276 SetMetalayerVisibility); |
263 if (!framework_instance) { | 277 if (!framework_instance) { |
264 if (!metalayer_closed_callback_.is_null()) | 278 if (!metalayer_closed_callback_.is_null()) |
265 base::ResetAndReturn(&metalayer_closed_callback_).Run(); | 279 base::ResetAndReturn(&metalayer_closed_callback_).Run(); |
266 return; | 280 return; |
267 } | 281 } |
268 framework_instance->SetMetalayerVisibility(visible); | 282 framework_instance->SetMetalayerVisibility(visible); |
269 } | 283 } |
270 | 284 |
271 } // namespace arc | 285 } // namespace arc |
OLD | NEW |