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

Side by Side Diff: ash/root_window_controller.cc

Issue 2235233006: ash: Refactor Shelf ownership and ShelfView creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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
« no previous file with comments | « ash/root_window_controller.h ('k') | ash/shelf/shelf.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/root_window_controller.h" 5 #include "ash/root_window_controller.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/aura/aura_layout_manager_adapter.h" 10 #include "ash/aura/aura_layout_manager_adapter.h"
11 #include "ash/aura/wm_shelf_aura.h" 11 #include "ash/aura/wm_shelf_aura.h"
12 #include "ash/aura/wm_window_aura.h" 12 #include "ash/aura/wm_window_aura.h"
13 #include "ash/common/ash_constants.h" 13 #include "ash/common/ash_constants.h"
14 #include "ash/common/ash_switches.h" 14 #include "ash/common/ash_switches.h"
15 #include "ash/common/focus_cycler.h" 15 #include "ash/common/focus_cycler.h"
16 #include "ash/common/login_status.h" 16 #include "ash/common/login_status.h"
17 #include "ash/common/root_window_controller_common.h" 17 #include "ash/common/root_window_controller_common.h"
18 #include "ash/common/session/session_state_delegate.h" 18 #include "ash/common/session/session_state_delegate.h"
19 #include "ash/common/shelf/shelf_delegate.h"
19 #include "ash/common/shelf/shelf_types.h" 20 #include "ash/common/shelf/shelf_types.h"
20 #include "ash/common/shell_delegate.h" 21 #include "ash/common/shell_delegate.h"
21 #include "ash/common/shell_window_ids.h" 22 #include "ash/common/shell_window_ids.h"
22 #include "ash/common/system/status_area_widget.h" 23 #include "ash/common/system/status_area_widget.h"
23 #include "ash/common/system/tray/system_tray_delegate.h" 24 #include "ash/common/system/tray/system_tray_delegate.h"
24 #include "ash/common/wm/always_on_top_controller.h" 25 #include "ash/common/wm/always_on_top_controller.h"
25 #include "ash/common/wm/container_finder.h" 26 #include "ash/common/wm/container_finder.h"
26 #include "ash/common/wm/dock/docked_window_layout_manager.h" 27 #include "ash/common/wm/dock/docked_window_layout_manager.h"
27 #include "ash/common/wm/fullscreen_window_finder.h" 28 #include "ash/common/wm/fullscreen_window_finder.h"
28 #include "ash/common/wm/panels/panel_layout_manager.h" 29 #include "ash/common/wm/panels/panel_layout_manager.h"
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 454
454 aura::Window* RootWindowController::GetContainer(int container_id) { 455 aura::Window* RootWindowController::GetContainer(int container_id) {
455 return GetRootWindow()->GetChildById(container_id); 456 return GetRootWindow()->GetChildById(container_id);
456 } 457 }
457 458
458 const aura::Window* RootWindowController::GetContainer(int container_id) const { 459 const aura::Window* RootWindowController::GetContainer(int container_id) const {
459 return ash_host_->AsWindowTreeHost()->window()->GetChildById(container_id); 460 return ash_host_->AsWindowTreeHost()->window()->GetChildById(container_id);
460 } 461 }
461 462
462 void RootWindowController::ShowShelf() { 463 void RootWindowController::ShowShelf() {
463 if (!shelf_widget_->shelf()) 464 if (!shelf_)
464 return; 465 return;
465 shelf_widget_->shelf()->SetVisible(true); 466 shelf_widget_->SetShelfVisibility(true);
466 shelf_widget_->status_area_widget()->Show(); 467 shelf_widget_->status_area_widget()->Show();
467 } 468 }
468 469
469 void RootWindowController::CreateShelf() { 470 void RootWindowController::CreateShelf() {
470 if (shelf_widget_->shelf()) 471 if (shelf_)
471 return; 472 return;
472 shelf_widget_->CreateShelf(); 473 ShelfView* shelf_view = shelf_widget_->CreateShelfView();
474
475 shelf_.reset(
476 new Shelf(wm_shelf_aura_.get(), shelf_view, shelf_widget_.get()));
477 shelf_widget_->set_shelf(shelf_.get());
478 // Must be initialized before the delegate is notified because the delegate
479 // may try to access the WmShelf.
480 wm_shelf_aura_->SetShelf(shelf_.get());
481 WmShell::Get()->shelf_delegate()->OnShelfCreated(shelf_.get());
473 482
474 if (panel_layout_manager_) 483 if (panel_layout_manager_)
475 panel_layout_manager_->SetShelf(wm_shelf_aura_.get()); 484 panel_layout_manager_->SetShelf(wm_shelf_aura_.get());
476 if (docked_layout_manager_) { 485 if (docked_layout_manager_) {
477 docked_layout_manager_->SetShelf(wm_shelf_aura_.get()); 486 docked_layout_manager_->SetShelf(wm_shelf_aura_.get());
478 if (shelf_widget_->shelf_layout_manager()) 487 if (shelf_widget_->shelf_layout_manager())
479 docked_layout_manager_->AddObserver( 488 docked_layout_manager_->AddObserver(
480 shelf_widget_->shelf_layout_manager()); 489 shelf_widget_->shelf_layout_manager());
481 } 490 }
482 491
483 // Notify shell observers that the shelf has been created. 492 // Notify shell observers that the shelf has been created.
484 WmShell::Get()->NotifyShelfCreatedForRootWindow( 493 WmShell::Get()->NotifyShelfCreatedForRootWindow(
485 WmWindowAura::Get(GetRootWindow())); 494 WmWindowAura::Get(GetRootWindow()));
486 495
487 shelf_widget_->PostCreateShelf(); 496 shelf_widget_->PostCreateShelf();
488 } 497 }
489 498
490 Shelf* RootWindowController::GetShelf() const { 499 Shelf* RootWindowController::GetShelf() const {
491 // TODO(jamescook): Shelf should be owned by this class, not by ShelfWidget. 500 return shelf_.get();
492 return shelf_widget_->shelf();
493 } 501 }
494 502
495 void RootWindowController::UpdateAfterLoginStatusChange(LoginStatus status) { 503 void RootWindowController::UpdateAfterLoginStatusChange(LoginStatus status) {
496 if (status != LoginStatus::NOT_LOGGED_IN) 504 if (status != LoginStatus::NOT_LOGGED_IN)
497 mouse_event_target_.reset(); 505 mouse_event_target_.reset();
498 if (shelf_widget_->status_area_widget()) 506 if (shelf_widget_->status_area_widget())
499 shelf_widget_->status_area_widget()->UpdateAfterLoginStatusChange(status); 507 shelf_widget_->status_area_widget()->UpdateAfterLoginStatusChange(status);
500 } 508 }
501 509
502 void RootWindowController::HandleInitialDesktopBackgroundAnimationStarted() { 510 void RootWindowController::HandleInitialDesktopBackgroundAnimationStarted() {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 while (!root_window->children().empty()) { 609 while (!root_window->children().empty()) {
602 aura::Window* window = root_window->children()[0]; 610 aura::Window* window = root_window->children()[0];
603 if (window->owned_by_parent()) { 611 if (window->owned_by_parent()) {
604 delete window; 612 delete window;
605 } else { 613 } else {
606 root_window->RemoveChild(window); 614 root_window->RemoveChild(window);
607 } 615 }
608 } 616 }
609 617
610 shelf_widget_.reset(); 618 shelf_widget_.reset();
619 shelf_.reset();
611 } 620 }
612 621
613 void RootWindowController::MoveWindowsTo(aura::Window* dst) { 622 void RootWindowController::MoveWindowsTo(aura::Window* dst) {
614 // Clear the workspace controller, so it doesn't incorrectly update the shelf. 623 // Clear the workspace controller, so it doesn't incorrectly update the shelf.
615 workspace_controller_.reset(); 624 workspace_controller_.reset();
616 ReparentAllWindows(GetRootWindow(), dst); 625 ReparentAllWindows(GetRootWindow(), dst);
617 } 626 }
618 627
619 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { 628 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() {
620 return shelf_widget_->shelf_layout_manager(); 629 return shelf_widget_->shelf_layout_manager();
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 aura::Window* primary_root_window = Shell::GetInstance() 957 aura::Window* primary_root_window = Shell::GetInstance()
949 ->window_tree_host_manager() 958 ->window_tree_host_manager()
950 ->GetPrimaryRootWindow(); 959 ->GetPrimaryRootWindow();
951 return GetRootWindowSettings(primary_root_window)->controller; 960 return GetRootWindowSettings(primary_root_window)->controller;
952 } 961 }
953 962
954 return GetRootWindowSettings(root_window)->controller; 963 return GetRootWindowSettings(root_window)->controller;
955 } 964 }
956 965
957 } // namespace ash 966 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller.h ('k') | ash/shelf/shelf.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698