Chromium Code Reviews| 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); | |
|
xc
2017/05/19 00:10:42
Why metalayer view is in this container?
kaznacheev
2017/05/19 00:31:05
This is where Chrome puts all Android system windo
| |
| 71 if (modal_container != nullptr) { | |
|
Luis Héctor Chávez
2017/05/19 15:03:21
nit: elide braces. Same in L91.
Vladislav Kaznacheev
2017/05/19 17:11:20
Done.
| |
| 72 excluded_layers.insert(modal_container->layer()); | |
| 73 } | |
| 74 | |
| 62 auto layer_tree_owner = ::wm::RecreateLayersWithClosure( | 75 auto layer_tree_owner = ::wm::RecreateLayersWithClosure( |
| 63 root_window, base::BindRepeating( | 76 root_window, base::BindRepeating( |
| 64 [](LayerSet blocked_layers, | 77 [](LayerSet blocked_layers, LayerSet excluded_layers, |
| 65 ui::LayerOwner* owner) -> std::unique_ptr<ui::Layer> { | 78 ui::LayerOwner* owner) -> std::unique_ptr<ui::Layer> { |
| 66 // Parent layer is excluded meaning that it's pointless | 79 // Parent layer is excluded meaning that it's pointless |
| 67 // to clone current child and all its descendants. This | 80 // to clone current child and all its descendants. This |
| 68 // reduces the number of layers to create. | 81 // reduces the number of layers to create. |
| 69 if (blocked_layers.count(owner->layer()->parent())) | 82 if (blocked_layers.count(owner->layer()->parent())) |
| 70 return nullptr; | 83 return nullptr; |
| 71 if (blocked_layers.count(owner->layer())) { | 84 if (blocked_layers.count(owner->layer())) { |
| 72 auto layer = base::MakeUnique<ui::Layer>( | 85 auto layer = base::MakeUnique<ui::Layer>( |
| 73 ui::LayerType::LAYER_SOLID_COLOR); | 86 ui::LayerType::LAYER_SOLID_COLOR); |
| 74 layer->SetBounds(owner->layer()->bounds()); | 87 layer->SetBounds(owner->layer()->bounds()); |
| 75 layer->SetColor(SK_ColorBLACK); | 88 layer->SetColor(SK_ColorBLACK); |
| 76 return layer; | 89 return layer; |
| 77 } | 90 } |
| 91 if (excluded_layers.count(owner->layer())) { | |
| 92 return nullptr; | |
| 93 } | |
| 78 return owner->RecreateLayer(); | 94 return owner->RecreateLayer(); |
| 79 }, | 95 }, |
| 80 std::move(blocked_layers))); | 96 std::move(blocked_layers), std::move(excluded_layers))); |
| 81 | 97 |
| 82 // layer_tree_owner cannot be null since we are starting off from the root | 98 // layer_tree_owner cannot be null since we are starting off from the root |
| 83 // window, which could never be incognito. | 99 // window, which could never be incognito. |
| 84 DCHECK(layer_tree_owner); | 100 DCHECK(layer_tree_owner); |
| 85 | 101 |
| 86 auto* root_layer = layer_tree_owner->root(); | 102 auto* root_layer = layer_tree_owner->root(); |
| 87 root_window->layer()->Add(root_layer); | 103 root_window->layer()->Add(root_layer); |
| 88 root_window->layer()->StackAtBottom(root_layer); | 104 root_window->layer()->StackAtBottom(root_layer); |
| 89 return layer_tree_owner; | 105 return layer_tree_owner; |
| 90 } | 106 } |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 SetMetalayerVisibility); | 278 SetMetalayerVisibility); |
| 263 if (!framework_instance) { | 279 if (!framework_instance) { |
| 264 if (!metalayer_closed_callback_.is_null()) | 280 if (!metalayer_closed_callback_.is_null()) |
| 265 base::ResetAndReturn(&metalayer_closed_callback_).Run(); | 281 base::ResetAndReturn(&metalayer_closed_callback_).Run(); |
| 266 return; | 282 return; |
| 267 } | 283 } |
| 268 framework_instance->SetMetalayerVisibility(visible); | 284 framework_instance->SetMetalayerVisibility(visible); |
| 269 } | 285 } |
| 270 | 286 |
| 271 } // namespace arc | 287 } // namespace arc |
| OLD | NEW |