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

Unified Diff: ui/wm/core/window_util.cc

Issue 2854543002: Block incognito browser windows for voice interaction. (Closed)
Patch Set: address review comments Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/wm/core/window_util.h ('k') | ui/wm/core/window_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/wm/core/window_util.cc
diff --git a/ui/wm/core/window_util.cc b/ui/wm/core/window_util.cc
index 7d72e58248695bc4c56187d26406b4e2d4947e88..91fc77ccb44066cd6856c65fdbed38c58991fd93 100644
--- a/ui/wm/core/window_util.cc
+++ b/ui/wm/core/window_util.cc
@@ -14,22 +14,25 @@
namespace {
-// Invokes RecreateLayer() on all the children of |to_clone|, adding the newly
-// cloned children to |parent|.
+// Invokes |map_func| on all the children of |to_clone|, adding the newly
+// cloned children to |parent|. If |map_func| returns nullptr on
+// the layer owner, all its layer's children will not be cloned.
//
// WARNING: It is assumed that |parent| is ultimately owned by a LayerTreeOwner.
-void CloneChildren(ui::Layer* to_clone, ui::Layer* parent) {
+void CloneChildren(ui::Layer* to_clone,
+ ui::Layer* parent,
+ const wm::MapLayerFunc& map_func) {
typedef std::vector<ui::Layer*> Layers;
// Make a copy of the children since RecreateLayer() mutates it.
Layers children(to_clone->children());
for (Layers::const_iterator i = children.begin(); i != children.end(); ++i) {
ui::LayerOwner* owner = (*i)->owner();
- ui::Layer* old_layer = owner ? owner->RecreateLayer().release() : NULL;
+ ui::Layer* old_layer = owner ? map_func.Run(owner).release() : NULL;
if (old_layer) {
parent->Add(old_layer);
// RecreateLayer() moves the existing children to the new layer. Create a
// copy of those.
- CloneChildren(owner->layer(), old_layer);
+ CloneChildren(owner->layer(), old_layer, map_func);
}
}
}
@@ -132,8 +135,20 @@ aura::Window* GetToplevelWindow(aura::Window* window) {
std::unique_ptr<ui::LayerTreeOwner> RecreateLayers(ui::LayerOwner* root) {
DCHECK(root->OwnsLayer());
- auto old_layer = base::MakeUnique<ui::LayerTreeOwner>(root->RecreateLayer());
- CloneChildren(root->layer(), old_layer->root());
+ return RecreateLayersWithClosure(root, base::Bind([](ui::LayerOwner* owner) {
+ return owner->RecreateLayer();
+ }));
+}
+
+std::unique_ptr<ui::LayerTreeOwner> RecreateLayersWithClosure(
+ ui::LayerOwner* root,
+ const MapLayerFunc& map_func) {
+ DCHECK(root->OwnsLayer());
+ auto layer = map_func.Run(root);
+ if (!layer)
+ return nullptr;
+ auto old_layer = base::MakeUnique<ui::LayerTreeOwner>(std::move(layer));
+ CloneChildren(root->layer(), old_layer->root(), map_func);
return old_layer;
}
« no previous file with comments | « ui/wm/core/window_util.h ('k') | ui/wm/core/window_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698