Commit 76990a0b authored by Shawn Gallea's avatar Shawn Gallea Committed by Commit Bot

Simplify WebviewLayoutManager

This prevents crashes when web_contents_window_ was null.

Bug: b/136460199
Test: Compile cast_shell
Change-Id: I6f48801e69745bcfc5fb29a7db0632e10a0bd8a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1876890Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Commit-Queue: Shawn Gallea <sagallea@google.com>
Cr-Commit-Position: refs/heads/master@{#708741}
parent db4075c2
......@@ -125,7 +125,7 @@ void WebContentController::ProcessRequest(
void WebContentController::AttachTo(aura::Window* window, int window_id) {
content::WebContents* contents = GetWebContents();
auto* contents_window = contents->GetNativeView();
window->SetLayoutManager(new WebviewLayoutManager(window, contents_window));
window->SetLayoutManager(new WebviewLayoutManager(window));
contents_window->set_id(window_id);
contents_window->SetBounds(gfx::Rect(window->bounds().size()));
// The aura window is hidden to avoid being shown via the usual layer method,
......
......@@ -8,14 +8,13 @@
namespace chromecast {
WebviewLayoutManager::WebviewLayoutManager(aura::Window* parent,
aura::Window* web_contents_window)
: parent_(parent), web_contents_window_(web_contents_window) {}
WebviewLayoutManager::WebviewLayoutManager(aura::Window* root) : root_(root) {}
WebviewLayoutManager::~WebviewLayoutManager() {}
void WebviewLayoutManager::OnWindowResized() {
web_contents_window_->SetBounds(gfx::Rect(parent_->bounds().size()));
for (aura::Window* child : root_->children())
SetChildBoundsDirect(child, gfx::Rect(root_->bounds().size()));
}
void WebviewLayoutManager::OnWindowAddedToLayout(aura::Window* child) {}
......
......@@ -13,7 +13,7 @@ namespace chromecast {
// Resizes the provided window to be the parent window's size.
class WebviewLayoutManager : public aura::LayoutManager {
public:
WebviewLayoutManager(aura::Window* parent, aura::Window* web_contents_window);
WebviewLayoutManager(aura::Window* root);
~WebviewLayoutManager() override;
void OnWindowResized() override;
......@@ -26,8 +26,7 @@ class WebviewLayoutManager : public aura::LayoutManager {
const gfx::Rect& requested_bounds) override;
private:
aura::Window* parent_;
aura::Window* web_contents_window_;
aura::Window* root_;
DISALLOW_COPY_AND_ASSIGN(WebviewLayoutManager);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment