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

Unified Diff: ash/wm/system_modal_container_layout_manager.cc

Issue 2320273002: Refactors DimWindow and moves to ash/common (Closed)
Patch Set: git add wm_window Created 4 years, 3 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
Index: ash/wm/system_modal_container_layout_manager.cc
diff --git a/ash/wm/system_modal_container_layout_manager.cc b/ash/wm/system_modal_container_layout_manager.cc
index 36c7890e97e08d2f0978281f20bf80a4be4681c4..967bea210a20c0ef2a083c3094ca6a3e6dc66e90 100644
--- a/ash/wm/system_modal_container_layout_manager.cc
+++ b/ash/wm/system_modal_container_layout_manager.cc
@@ -6,11 +6,12 @@
#include <cmath>
+#include "ash/aura/wm_window_aura.h"
#include "ash/common/session/session_state_delegate.h"
#include "ash/common/shell_window_ids.h"
+#include "ash/common/wm/window_dimmer.h"
#include "ash/common/wm_shell.h"
#include "ash/shell.h"
-#include "ash/wm/dim_window.h"
#include "ash/wm/window_util.h"
#include "base/stl_util.h"
#include "ui/aura/client/aura_constants.h"
@@ -38,9 +39,7 @@ const int kCenterPixelDelta = 32;
SystemModalContainerLayoutManager::SystemModalContainerLayoutManager(
aura::Window* container)
- : SnapToPixelLayoutManager(container),
- container_(container),
- modal_background_(nullptr) {}
+ : SnapToPixelLayoutManager(container), container_(container) {}
SystemModalContainerLayoutManager::~SystemModalContainerLayoutManager() {}
@@ -53,7 +52,8 @@ void SystemModalContainerLayoutManager::OnWindowResized() {
void SystemModalContainerLayoutManager::OnWindowAddedToLayout(
aura::Window* child) {
- DCHECK(child == modal_background_ ||
+ DCHECK((window_dimmer_ &&
+ WmWindowAura::Get(child) == window_dimmer_->window()) ||
child->type() == ui::wm::WINDOW_TYPE_NORMAL ||
child->type() == ui::wm::WINDOW_TYPE_POPUP);
DCHECK(
@@ -110,11 +110,12 @@ void SystemModalContainerLayoutManager::OnWindowPropertyChanged(
void SystemModalContainerLayoutManager::OnWindowDestroying(
aura::Window* window) {
- if (modal_background_ == window) {
- if (keyboard::KeyboardController::GetInstance())
- keyboard::KeyboardController::GetInstance()->RemoveObserver(this);
- modal_background_ = nullptr;
- }
+ if (!window_dimmer_ || window_dimmer_->window() != WmWindowAura::Get(window))
+ return;
+
+ if (keyboard::KeyboardController::GetInstance())
+ keyboard::KeyboardController::GetInstance()->RemoveObserver(this);
+ window_dimmer_ = nullptr;
}
void SystemModalContainerLayoutManager::OnWindowVisibilityChanged(
@@ -155,28 +156,27 @@ bool SystemModalContainerLayoutManager::ActivateNextModalWindow() {
}
void SystemModalContainerLayoutManager::CreateModalBackground() {
- if (!modal_background_) {
- modal_background_ = new DimWindow(container_);
- modal_background_->SetName(
+ if (!window_dimmer_) {
+ window_dimmer_ = new WindowDimmer(WmWindowAura::Get(container_));
+ window_dimmer_->window()->SetName(
"SystemModalContainerLayoutManager.ModalBackground");
// There isn't always a keyboard controller.
if (keyboard::KeyboardController::GetInstance())
keyboard::KeyboardController::GetInstance()->AddObserver(this);
}
- modal_background_->Show();
+ window_dimmer_->window()->Show();
}
void SystemModalContainerLayoutManager::DestroyModalBackground() {
- // modal_background_ can be NULL when a root window is shutting down.
- if (modal_background_) {
- if (keyboard::KeyboardController::GetInstance())
- keyboard::KeyboardController::GetInstance()->RemoveObserver(this);
- modal_background_->Hide();
- // Explicitly delete instead of using scoped_ptr as the owner of the
- // window is its parent.
- delete modal_background_;
- modal_background_ = nullptr;
- }
+ // |window_dimmer_| can be null when a root window is shutting down.
+ if (!window_dimmer_)
+ return;
+
+ if (keyboard::KeyboardController::GetInstance())
+ keyboard::KeyboardController::GetInstance()->RemoveObserver(this);
+ // Destroy() triggers deletion.
+ window_dimmer_->Destroy();
+ DCHECK(!window_dimmer_);
}
// static
@@ -189,7 +189,8 @@ bool SystemModalContainerLayoutManager::IsModalBackground(
SystemModalContainerLayoutManager* layout_manager =
static_cast<SystemModalContainerLayoutManager*>(
window->parent()->layout_manager());
- return layout_manager->modal_background_ == window;
+ return layout_manager->window_dimmer_ &&
+ layout_manager->window_dimmer_->window() == WmWindowAura::Get(window);
}
////////////////////////////////////////////////////////////////////////////////

Powered by Google App Engine
This is Rietveld 408576698