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

Side by Side Diff: ash/shelf/shelf_layout_manager.cc

Issue 2808723004: Renames WmShell to ShellPort (Closed)
Patch Set: feedback Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/shelf/shelf_layout_manager.h" 5 #include "ash/shelf/shelf_layout_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/animation/animation_change_type.h" 11 #include "ash/animation/animation_change_type.h"
12 #include "ash/keyboard/keyboard_observer_register.h" 12 #include "ash/keyboard/keyboard_observer_register.h"
13 #include "ash/public/cpp/shell_window_ids.h" 13 #include "ash/public/cpp/shell_window_ids.h"
14 #include "ash/root_window_controller.h" 14 #include "ash/root_window_controller.h"
15 #include "ash/session/session_controller.h" 15 #include "ash/session/session_controller.h"
16 #include "ash/shelf/shelf_constants.h" 16 #include "ash/shelf/shelf_constants.h"
17 #include "ash/shelf/shelf_layout_manager_observer.h" 17 #include "ash/shelf/shelf_layout_manager_observer.h"
18 #include "ash/shelf/shelf_widget.h" 18 #include "ash/shelf/shelf_widget.h"
19 #include "ash/shelf/wm_shelf.h" 19 #include "ash/shelf/wm_shelf.h"
20 #include "ash/shell.h" 20 #include "ash/shell.h"
21 #include "ash/shell_port.h"
21 #include "ash/system/status_area_widget.h" 22 #include "ash/system/status_area_widget.h"
22 #include "ash/wm/fullscreen_window_finder.h" 23 #include "ash/wm/fullscreen_window_finder.h"
23 #include "ash/wm/mru_window_tracker.h" 24 #include "ash/wm/mru_window_tracker.h"
24 #include "ash/wm/screen_pinning_controller.h" 25 #include "ash/wm/screen_pinning_controller.h"
25 #include "ash/wm/window_state.h" 26 #include "ash/wm/window_state.h"
26 #include "ash/wm/window_state_aura.h" 27 #include "ash/wm/window_state_aura.h"
27 #include "ash/wm/wm_screen_util.h" 28 #include "ash/wm/wm_screen_util.h"
28 #include "ash/wm_shell.h"
29 #include "ash/wm_window.h" 29 #include "ash/wm_window.h"
30 #include "base/auto_reset.h" 30 #include "base/auto_reset.h"
31 #include "base/command_line.h" 31 #include "base/command_line.h"
32 #include "base/i18n/rtl.h" 32 #include "base/i18n/rtl.h"
33 #include "ui/base/ui_base_switches.h" 33 #include "ui/base/ui_base_switches.h"
34 #include "ui/compositor/layer.h" 34 #include "ui/compositor/layer.h"
35 #include "ui/compositor/layer_animation_observer.h" 35 #include "ui/compositor/layer_animation_observer.h"
36 #include "ui/compositor/layer_animator.h" 36 #include "ui/compositor/layer_animator.h"
37 #include "ui/compositor/scoped_layer_animation_settings.h" 37 #include "ui/compositor/scoped_layer_animation_settings.h"
38 #include "ui/display/display.h" 38 #include "ui/display/display.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 gesture_drag_amount_(0.f), 153 gesture_drag_amount_(0.f),
154 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN), 154 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN),
155 update_shelf_observer_(nullptr), 155 update_shelf_observer_(nullptr),
156 chromevox_panel_height_(0), 156 chromevox_panel_height_(0),
157 duration_override_in_ms_(0), 157 duration_override_in_ms_(0),
158 shelf_background_type_(SHELF_BACKGROUND_OVERLAP), 158 shelf_background_type_(SHELF_BACKGROUND_OVERLAP),
159 keyboard_observer_(this) { 159 keyboard_observer_(this) {
160 DCHECK(shelf_widget_); 160 DCHECK(shelf_widget_);
161 DCHECK(wm_shelf_); 161 DCHECK(wm_shelf_);
162 Shell::Get()->AddShellObserver(this); 162 Shell::Get()->AddShellObserver(this);
163 WmShell::Get()->AddLockStateObserver(this); 163 ShellPort::Get()->AddLockStateObserver(this);
164 Shell::Get()->activation_client()->AddObserver(this); 164 Shell::Get()->activation_client()->AddObserver(this);
165 Shell::Get()->session_controller()->AddSessionStateObserver(this); 165 Shell::Get()->session_controller()->AddSessionStateObserver(this);
166 state_.session_state = Shell::Get()->session_controller()->GetSessionState(); 166 state_.session_state = Shell::Get()->session_controller()->GetSessionState();
167 } 167 }
168 168
169 ShelfLayoutManager::~ShelfLayoutManager() { 169 ShelfLayoutManager::~ShelfLayoutManager() {
170 if (update_shelf_observer_) 170 if (update_shelf_observer_)
171 update_shelf_observer_->Detach(); 171 update_shelf_observer_->Detach();
172 172
173 for (auto& observer : observers_) 173 for (auto& observer : observers_)
174 observer.WillDeleteShelfLayoutManager(); 174 observer.WillDeleteShelfLayoutManager();
175 Shell::Get()->RemoveShellObserver(this); 175 Shell::Get()->RemoveShellObserver(this);
176 WmShell::Get()->RemoveLockStateObserver(this); 176 ShellPort::Get()->RemoveLockStateObserver(this);
177 Shell::Get()->session_controller()->RemoveSessionStateObserver(this); 177 Shell::Get()->session_controller()->RemoveSessionStateObserver(this);
178 } 178 }
179 179
180 void ShelfLayoutManager::PrepareForShutdown() { 180 void ShelfLayoutManager::PrepareForShutdown() {
181 in_shutdown_ = true; 181 in_shutdown_ = true;
182 // Stop observing changes to avoid updating a partially destructed shelf. 182 // Stop observing changes to avoid updating a partially destructed shelf.
183 Shell::Get()->activation_client()->RemoveObserver(this); 183 Shell::Get()->activation_client()->RemoveObserver(this);
184 } 184 }
185 185
186 bool ShelfLayoutManager::IsVisible() const { 186 bool ShelfLayoutManager::IsVisible() const {
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 441
442 keyboard_bounds_ = new_bounds; 442 keyboard_bounds_ = new_bounds;
443 LayoutShelfAndUpdateBounds(change_work_area); 443 LayoutShelfAndUpdateBounds(change_work_area);
444 444
445 // On login screen if keyboard has been just hidden, update bounds just once 445 // On login screen if keyboard has been just hidden, update bounds just once
446 // but ignore target_bounds.work_area_insets since shelf overlaps with login 446 // but ignore target_bounds.work_area_insets since shelf overlaps with login
447 // window. 447 // window.
448 if (Shell::Get()->session_controller()->IsUserSessionBlocked() && 448 if (Shell::Get()->session_controller()->IsUserSessionBlocked() &&
449 keyboard_is_about_to_hide) { 449 keyboard_is_about_to_hide) {
450 WmWindow* window = WmWindow::Get(shelf_widget_->GetNativeWindow()); 450 WmWindow* window = WmWindow::Get(shelf_widget_->GetNativeWindow());
451 WmShell::Get()->SetDisplayWorkAreaInsets(window, gfx::Insets()); 451 ShellPort::Get()->SetDisplayWorkAreaInsets(window, gfx::Insets());
452 } 452 }
453 } 453 }
454 454
455 void ShelfLayoutManager::OnKeyboardClosed() { 455 void ShelfLayoutManager::OnKeyboardClosed() {
456 keyboard_observer_.RemoveAll(); 456 keyboard_observer_.RemoveAll();
457 } 457 }
458 458
459 ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const { 459 ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const {
460 if (state_.pre_lock_screen_animation_active) 460 if (state_.pre_lock_screen_animation_active)
461 return SHELF_BACKGROUND_DEFAULT; 461 return SHELF_BACKGROUND_DEFAULT;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 // don't set display work area, as it is not real user-set alignment. 630 // don't set display work area, as it is not real user-set alignment.
631 if (!state_.IsScreenLocked() && 631 if (!state_.IsScreenLocked() &&
632 wm_shelf_->GetAlignment() != SHELF_ALIGNMENT_BOTTOM_LOCKED && 632 wm_shelf_->GetAlignment() != SHELF_ALIGNMENT_BOTTOM_LOCKED &&
633 change_work_area) { 633 change_work_area) {
634 gfx::Insets insets; 634 gfx::Insets insets;
635 // If user session is blocked (login to new user session or add user to 635 // If user session is blocked (login to new user session or add user to
636 // the existing session - multi-profile) then give 100% of work area only 636 // the existing session - multi-profile) then give 100% of work area only
637 // if keyboard is not shown. 637 // if keyboard is not shown.
638 if (!state_.IsAddingSecondaryUser() || !keyboard_bounds_.IsEmpty()) 638 if (!state_.IsAddingSecondaryUser() || !keyboard_bounds_.IsEmpty())
639 insets = target_bounds.work_area_insets; 639 insets = target_bounds.work_area_insets;
640 WmShell::Get()->SetDisplayWorkAreaInsets(shelf_window, insets); 640 ShellPort::Get()->SetDisplayWorkAreaInsets(shelf_window, insets);
641 } 641 }
642 } 642 }
643 643
644 // Set an empty border to avoid the shelf view and status area overlapping. 644 // Set an empty border to avoid the shelf view and status area overlapping.
645 // TODO(msw): Avoid setting bounds of views within the shelf widget here. 645 // TODO(msw): Avoid setting bounds of views within the shelf widget here.
646 gfx::Rect shelf_bounds = gfx::Rect(target_bounds.shelf_bounds_in_root.size()); 646 gfx::Rect shelf_bounds = gfx::Rect(target_bounds.shelf_bounds_in_root.size());
647 shelf_widget_->GetContentsView()->SetBorder(views::CreateEmptyBorder( 647 shelf_widget_->GetContentsView()->SetBorder(views::CreateEmptyBorder(
648 shelf_bounds.InsetsFrom(target_bounds.shelf_bounds_in_shelf))); 648 shelf_bounds.InsetsFrom(target_bounds.shelf_bounds_in_shelf)));
649 shelf_widget_->GetContentsView()->Layout(); 649 shelf_widget_->GetContentsView()->Layout();
650 650
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 gesture_drag_status_ = GESTURE_DRAG_NONE; 1140 gesture_drag_status_ = GESTURE_DRAG_NONE;
1141 } 1141 }
1142 1142
1143 void ShelfLayoutManager::CancelGestureDrag() { 1143 void ShelfLayoutManager::CancelGestureDrag() {
1144 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; 1144 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS;
1145 UpdateVisibilityState(); 1145 UpdateVisibilityState();
1146 gesture_drag_status_ = GESTURE_DRAG_NONE; 1146 gesture_drag_status_ = GESTURE_DRAG_NONE;
1147 } 1147 }
1148 1148
1149 } // namespace ash 1149 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698