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

Unified Diff: ash/common/shelf/shelf_layout_manager.cc

Issue 2747543002: ash: Start/stop observing KeyboardController via ShellObserver (Closed)
Patch Set: rebase Created 3 years, 9 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/common/shelf/shelf_layout_manager.cc
diff --git a/ash/common/shelf/shelf_layout_manager.cc b/ash/common/shelf/shelf_layout_manager.cc
index 35de24c20de2088de87458b55086224cbc0b5725..b936dd5360d77db544aaa5a8dac0e16b3be5893a 100644
--- a/ash/common/shelf/shelf_layout_manager.cc
+++ b/ash/common/shelf/shelf_layout_manager.cc
@@ -93,7 +93,7 @@ class ShelfLayoutManager::UpdateShelfObserver
shelf_->update_shelf_observer_ = this;
}
- void Detach() { shelf_ = NULL; }
+ void Detach() { shelf_ = nullptr; }
void OnImplicitAnimationsCompleted() override {
if (shelf_)
@@ -104,10 +104,10 @@ class ShelfLayoutManager::UpdateShelfObserver
private:
~UpdateShelfObserver() override {
if (shelf_)
- shelf_->update_shelf_observer_ = NULL;
+ shelf_->update_shelf_observer_ = nullptr;
}
- // Shelf we're in. NULL if deleted before we're deleted.
+ // Shelf we're in. nullptr if deleted before we're deleted.
ShelfLayoutManager* shelf_;
DISALLOW_COPY_AND_ASSIGN(UpdateShelfObserver);
@@ -150,10 +150,11 @@ ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf_widget,
gesture_drag_status_(GESTURE_DRAG_NONE),
gesture_drag_amount_(0.f),
gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN),
- update_shelf_observer_(NULL),
+ update_shelf_observer_(nullptr),
chromevox_panel_height_(0),
duration_override_in_ms_(0),
- shelf_background_type_(SHELF_BACKGROUND_OVERLAP) {
+ shelf_background_type_(SHELF_BACKGROUND_OVERLAP),
+ keyboard_observer_(this) {
DCHECK(shelf_widget_);
DCHECK(wm_shelf_);
Shell::GetInstance()->AddShellObserver(this);
@@ -182,7 +183,7 @@ void ShelfLayoutManager::PrepareForShutdown() {
}
bool ShelfLayoutManager::IsVisible() const {
- // status_area_widget() may be NULL during the shutdown.
+ // status_area_widget() may be nullptr during the shutdown.
return shelf_widget_->status_area_widget() &&
shelf_widget_->status_area_widget()->IsVisible() &&
(state_.visibility_state == SHELF_VISIBLE ||
@@ -210,7 +211,7 @@ gfx::Size ShelfLayoutManager::GetPreferredSize() {
void ShelfLayoutManager::LayoutShelfAndUpdateBounds(bool change_work_area) {
TargetBounds target_bounds;
CalculateTargetBounds(state_, &target_bounds);
- UpdateBoundsAndOpacity(target_bounds, false, change_work_area, NULL);
+ UpdateBoundsAndOpacity(target_bounds, false, change_work_area, nullptr);
// Update insets in ShelfWindowTargeter when shelf bounds change.
for (auto& observer : observers_)
@@ -435,7 +436,9 @@ void ShelfLayoutManager::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {
}
}
-void ShelfLayoutManager::OnKeyboardClosed() {}
+void ShelfLayoutManager::OnKeyboardClosed() {
+ keyboard_observer_.RemoveAll();
+}
ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const {
if (state_.pre_lock_screen_animation_active)
@@ -463,6 +466,18 @@ void ShelfLayoutManager::SetChromeVoxPanelHeight(int height) {
LayoutShelf();
}
+void ShelfLayoutManager::StartObservingKeyboard(
+ keyboard::KeyboardController* keyboard_controller) {
+ DCHECK(!keyboard_observer_.IsObservingSources());
+ keyboard_observer_.Add(keyboard_controller);
+}
+
+void ShelfLayoutManager::StopObservingKeyboard(
+ keyboard::KeyboardController* keyboard_controller) {
+ if (keyboard_observer_.IsObserving(keyboard_controller))
+ keyboard_observer_.Remove(keyboard_controller);
+}
+
////////////////////////////////////////////////////////////////////////////////
// ShelfLayoutManager, private:
@@ -537,7 +552,7 @@ void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) {
CalculateTargetBounds(state_, &target_bounds);
UpdateBoundsAndOpacity(
target_bounds, true /* animate */, true /* change_work_area */,
- delay_background_change ? update_shelf_observer_ : NULL);
+ delay_background_change ? update_shelf_observer_ : nullptr);
// OnAutoHideStateChanged Should be emitted when:
// - firstly state changed to auto-hide from other state
@@ -1019,7 +1034,7 @@ void ShelfLayoutManager::SessionStateChanged(
TargetBounds target_bounds;
CalculateTargetBounds(state_, &target_bounds);
UpdateBoundsAndOpacity(target_bounds, true /* animate */,
- true /* change_work_area */, NULL);
+ true /* change_work_area */, nullptr);
UpdateVisibilityState();
}

Powered by Google App Engine
This is Rietveld 408576698