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

Side by Side Diff: ash/shell.cc

Issue 1851883002: Cleanup shelf initialization and observation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Check for shelf before setting prefs in ChromeLauncherController. Created 4 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/shell.h" 5 #include "ash/shell.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 22 matching lines...) Expand all
33 #include "ash/ime/input_method_event_handler.h" 33 #include "ash/ime/input_method_event_handler.h"
34 #include "ash/keyboard/keyboard_ui.h" 34 #include "ash/keyboard/keyboard_ui.h"
35 #include "ash/keyboard_uma_event_filter.h" 35 #include "ash/keyboard_uma_event_filter.h"
36 #include "ash/magnifier/magnification_controller.h" 36 #include "ash/magnifier/magnification_controller.h"
37 #include "ash/magnifier/partial_magnification_controller.h" 37 #include "ash/magnifier/partial_magnification_controller.h"
38 #include "ash/media_delegate.h" 38 #include "ash/media_delegate.h"
39 #include "ash/new_window_delegate.h" 39 #include "ash/new_window_delegate.h"
40 #include "ash/root_window_controller.h" 40 #include "ash/root_window_controller.h"
41 #include "ash/session/session_state_delegate.h" 41 #include "ash/session/session_state_delegate.h"
42 #include "ash/shelf/app_list_shelf_item_delegate.h" 42 #include "ash/shelf/app_list_shelf_item_delegate.h"
43 #include "ash/shelf/shelf.h"
43 #include "ash/shelf/shelf_delegate.h" 44 #include "ash/shelf/shelf_delegate.h"
44 #include "ash/shelf/shelf_item_delegate.h" 45 #include "ash/shelf/shelf_item_delegate.h"
45 #include "ash/shelf/shelf_item_delegate_manager.h" 46 #include "ash/shelf/shelf_item_delegate_manager.h"
46 #include "ash/shelf/shelf_layout_manager.h"
47 #include "ash/shelf/shelf_model.h" 47 #include "ash/shelf/shelf_model.h"
48 #include "ash/shelf/shelf_widget.h" 48 #include "ash/shelf/shelf_widget.h"
49 #include "ash/shelf/shelf_window_watcher.h" 49 #include "ash/shelf/shelf_window_watcher.h"
50 #include "ash/shell_delegate.h" 50 #include "ash/shell_delegate.h"
51 #include "ash/shell_factory.h" 51 #include "ash/shell_factory.h"
52 #include "ash/shell_init_params.h" 52 #include "ash/shell_init_params.h"
53 #include "ash/shell_window_ids.h" 53 #include "ash/shell_window_ids.h"
54 #include "ash/system/locale/locale_notification_controller.h" 54 #include "ash/system/locale/locale_notification_controller.h"
55 #include "ash/system/status_area_widget.h" 55 #include "ash/system/status_area_widget.h"
56 #include "ash/system/toast/toast_manager.h" 56 #include "ash/system/toast/toast_manager.h"
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 void Shell::UpdateShelfVisibility() { 504 void Shell::UpdateShelfVisibility() {
505 RootWindowControllerList controllers = GetAllRootWindowControllers(); 505 RootWindowControllerList controllers = GetAllRootWindowControllers();
506 for (RootWindowControllerList::iterator iter = controllers.begin(); 506 for (RootWindowControllerList::iterator iter = controllers.begin();
507 iter != controllers.end(); ++iter) 507 iter != controllers.end(); ++iter)
508 if ((*iter)->shelf()) 508 if ((*iter)->shelf())
509 (*iter)->UpdateShelfVisibility(); 509 (*iter)->UpdateShelfVisibility();
510 } 510 }
511 511
512 void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior, 512 void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior,
513 aura::Window* root_window) { 513 aura::Window* root_window) {
514 ShelfWidget* shelf_widget = GetRootWindowController(root_window)->shelf(); 514 Shelf::ForWindow(root_window)->SetAutoHideBehavior(behavior);
515 shelf_widget->shelf_layout_manager()->SetAutoHideBehavior(behavior);
516 } 515 }
517 516
518 ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior( 517 ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior(
519 aura::Window* root_window) const { 518 aura::Window* root_window) const {
520 ShelfWidget* shelf_widget = GetRootWindowController(root_window)->shelf(); 519 return Shelf::ForWindow(root_window)->GetAutoHideBehavior();
521 return shelf_widget->shelf_layout_manager()->auto_hide_behavior();
522 } 520 }
523 521
524 void Shell::SetShelfAlignment(ShelfAlignment alignment, 522 void Shell::SetShelfAlignment(ShelfAlignment alignment,
525 aura::Window* root_window) { 523 aura::Window* root_window) {
526 ShelfWidget* shelf_widget = GetRootWindowController(root_window)->shelf(); 524 Shelf::ForWindow(root_window)->SetAlignment(alignment);
527 shelf_widget->shelf_layout_manager()->SetAlignment(alignment);
528 } 525 }
529 526
530 ShelfAlignment Shell::GetShelfAlignment(const aura::Window* root_window) const { 527 ShelfAlignment Shell::GetShelfAlignment(const aura::Window* root_window) const {
531 ShelfWidget* shelf_widget = GetRootWindowController(root_window)->shelf(); 528 return Shelf::ForWindow(root_window)->GetAlignment();
532 return shelf_widget->shelf_layout_manager()->GetAlignment();
533 } 529 }
534 530
535 void Shell::OnShelfAlignmentChanged(aura::Window* root_window) { 531 void Shell::OnShelfAlignmentChanged(aura::Window* root_window) {
536 FOR_EACH_OBSERVER(ShellObserver, observers_, 532 FOR_EACH_OBSERVER(ShellObserver, observers_,
537 OnShelfAlignmentChanged(root_window)); 533 OnShelfAlignmentChanged(root_window));
538 } 534 }
539 535
536 void Shell::OnShelfAutoHideBehaviorChanged(aura::Window* root_window) {
537 FOR_EACH_OBSERVER(ShellObserver, observers_,
538 OnShelfAutoHideBehaviorChanged(root_window));
539 }
540
540 void Shell::NotifyFullscreenStateChange(bool is_fullscreen, 541 void Shell::NotifyFullscreenStateChange(bool is_fullscreen,
541 aura::Window* root_window) { 542 aura::Window* root_window) {
542 FOR_EACH_OBSERVER(ShellObserver, observers_, OnFullscreenStateChanged( 543 FOR_EACH_OBSERVER(ShellObserver, observers_, OnFullscreenStateChanged(
543 is_fullscreen, root_window)); 544 is_fullscreen, root_window));
544 } 545 }
545 546
546 void Shell::CreateModalBackground(aura::Window* window) { 547 void Shell::CreateModalBackground(aura::Window* window) {
547 if (!modality_filter_) { 548 if (!modality_filter_) {
548 modality_filter_.reset(new SystemModalContainerEventFilter(this)); 549 modality_filter_.reset(new SystemModalContainerEventFilter(this));
549 AddPreTargetHandler(modality_filter_.get()); 550 AddPreTargetHandler(modality_filter_.get());
(...skipping 30 matching lines...) Expand all
580 ShelfWidget* shelf = GetPrimaryRootWindowController()->shelf(); 581 ShelfWidget* shelf = GetPrimaryRootWindowController()->shelf();
581 return shelf && shelf->status_area_widget(); 582 return shelf && shelf->status_area_widget();
582 } 583 }
583 584
584 SystemTray* Shell::GetPrimarySystemTray() { 585 SystemTray* Shell::GetPrimarySystemTray() {
585 return GetPrimaryRootWindowController()->GetSystemTray(); 586 return GetPrimaryRootWindowController()->GetSystemTray();
586 } 587 }
587 588
588 ShelfDelegate* Shell::GetShelfDelegate() { 589 ShelfDelegate* Shell::GetShelfDelegate() {
589 if (!shelf_delegate_) { 590 if (!shelf_delegate_) {
590 shelf_model_.reset(new ShelfModel);
591 // Creates ShelfItemDelegateManager before ShelfDelegate. 591 // Creates ShelfItemDelegateManager before ShelfDelegate.
592 shelf_item_delegate_manager_.reset( 592 shelf_item_delegate_manager_.reset(
593 new ShelfItemDelegateManager(shelf_model_.get())); 593 new ShelfItemDelegateManager(shelf_model_.get()));
594 594
595 shelf_delegate_.reset(delegate_->CreateShelfDelegate(shelf_model_.get())); 595 shelf_delegate_.reset(delegate_->CreateShelfDelegate(shelf_model_.get()));
596 scoped_ptr<ShelfItemDelegate> controller(new AppListShelfItemDelegate); 596 scoped_ptr<ShelfItemDelegate> controller(new AppListShelfItemDelegate);
597 597
598 // Finding the shelf model's location of the app list and setting its 598 // Finding the shelf model's location of the app list and setting its
599 // ShelfItemDelegate. 599 // ShelfItemDelegate.
600 int app_list_index = shelf_model_->GetItemIndexForType(TYPE_APP_LIST); 600 int app_list_index = shelf_model_->GetItemIndexForType(TYPE_APP_LIST);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 DoInitialAnimation(); 635 DoInitialAnimation();
636 } 636 }
637 637
638 //////////////////////////////////////////////////////////////////////////////// 638 ////////////////////////////////////////////////////////////////////////////////
639 // Shell, private: 639 // Shell, private:
640 640
641 Shell::Shell(ShellDelegate* delegate, base::SequencedWorkerPool* blocking_pool) 641 Shell::Shell(ShellDelegate* delegate, base::SequencedWorkerPool* blocking_pool)
642 : target_root_window_(nullptr), 642 : target_root_window_(nullptr),
643 scoped_target_root_window_(nullptr), 643 scoped_target_root_window_(nullptr),
644 delegate_(delegate), 644 delegate_(delegate),
645 shelf_model_(new ShelfModel),
645 window_positioner_(new WindowPositioner), 646 window_positioner_(new WindowPositioner),
646 activation_client_(nullptr), 647 activation_client_(nullptr),
647 #if defined(OS_CHROMEOS) 648 #if defined(OS_CHROMEOS)
648 display_configurator_(new ui::DisplayConfigurator()), 649 display_configurator_(new ui::DisplayConfigurator()),
649 #endif // defined(OS_CHROMEOS) 650 #endif // defined(OS_CHROMEOS)
650 native_cursor_manager_(nullptr), 651 native_cursor_manager_(nullptr),
651 simulate_modal_window_open_for_testing_(false), 652 simulate_modal_window_open_for_testing_(false),
652 is_touch_hud_projection_enabled_(false), 653 is_touch_hud_projection_enabled_(false),
653 blocking_pool_(blocking_pool) { 654 blocking_pool_(blocking_pool) {
654 DCHECK(delegate_.get()); 655 DCHECK(delegate_.get());
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 1214
1214 void Shell::OnWindowActivated( 1215 void Shell::OnWindowActivated(
1215 aura::client::ActivationChangeObserver::ActivationReason reason, 1216 aura::client::ActivationChangeObserver::ActivationReason reason,
1216 aura::Window* gained_active, 1217 aura::Window* gained_active,
1217 aura::Window* lost_active) { 1218 aura::Window* lost_active) {
1218 if (gained_active) 1219 if (gained_active)
1219 target_root_window_ = gained_active->GetRootWindow(); 1220 target_root_window_ = gained_active->GetRootWindow();
1220 } 1221 }
1221 1222
1222 } // namespace ash 1223 } // namespace ash
OLDNEW
« ash/shelf/shelf.cc ('K') | « ash/shell.h ('k') | ash/shell/shelf_delegate_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698