| OLD | NEW |
| 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 | 8 |
| 9 #include "ash/app_list/app_list.h" | 9 #include "ash/app_list/app_list.h" |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| 11 #include "ash/desktop_background/desktop_background_controller.h" |
| 12 #include "ash/desktop_background/desktop_background_resources.h" |
| 13 #include "ash/desktop_background/desktop_background_view.h" |
| 11 #include "ash/drag_drop/drag_drop_controller.h" | 14 #include "ash/drag_drop/drag_drop_controller.h" |
| 12 #include "ash/focus_cycler.h" | 15 #include "ash/focus_cycler.h" |
| 13 #include "ash/ime/input_method_event_filter.h" | 16 #include "ash/ime/input_method_event_filter.h" |
| 14 #include "ash/launcher/launcher.h" | 17 #include "ash/launcher/launcher.h" |
| 15 #include "ash/screen_ash.h" | 18 #include "ash/screen_ash.h" |
| 16 #include "ash/shell_delegate.h" | 19 #include "ash/shell_delegate.h" |
| 17 #include "ash/shell_factory.h" | 20 #include "ash/shell_factory.h" |
| 18 #include "ash/shell_window_ids.h" | 21 #include "ash/shell_window_ids.h" |
| 19 #include "ash/system/audio/tray_volume.h" | 22 #include "ash/system/audio/tray_volume.h" |
| 20 #include "ash/system/brightness/tray_brightness.h" | 23 #include "ash/system/brightness/tray_brightness.h" |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 Shell::Shell(ShellDelegate* delegate) | 311 Shell::Shell(ShellDelegate* delegate) |
| 309 : root_window_(new aura::RootWindow), | 312 : root_window_(new aura::RootWindow), |
| 310 screen_(new ScreenAsh(root_window_.get())), | 313 screen_(new ScreenAsh(root_window_.get())), |
| 311 root_filter_(NULL), | 314 root_filter_(NULL), |
| 312 delegate_(delegate), | 315 delegate_(delegate), |
| 313 audio_controller_(NULL), | 316 audio_controller_(NULL), |
| 314 brightness_controller_(NULL), | 317 brightness_controller_(NULL), |
| 315 network_controller_(NULL), | 318 network_controller_(NULL), |
| 316 power_status_controller_(NULL), | 319 power_status_controller_(NULL), |
| 317 shelf_(NULL), | 320 shelf_(NULL), |
| 318 desktop_background_mode_(BACKGROUND_IMAGE), | |
| 319 root_window_layout_(NULL), | 321 root_window_layout_(NULL), |
| 320 status_widget_(NULL) { | 322 status_widget_(NULL) { |
| 321 gfx::Screen::SetInstance(screen_); | 323 gfx::Screen::SetInstance(screen_); |
| 322 } | 324 } |
| 323 | 325 |
| 324 Shell::~Shell() { | 326 Shell::~Shell() { |
| 325 RemoveRootWindowEventFilter(partial_screenshot_filter_.get()); | 327 RemoveRootWindowEventFilter(partial_screenshot_filter_.get()); |
| 326 RemoveRootWindowEventFilter(input_method_filter_.get()); | 328 RemoveRootWindowEventFilter(input_method_filter_.get()); |
| 327 RemoveRootWindowEventFilter(window_modality_controller_.get()); | 329 RemoveRootWindowEventFilter(window_modality_controller_.get()); |
| 328 #if !defined(OS_MACOSX) | 330 #if !defined(OS_MACOSX) |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 tray_->AddTrayItem(tray_brightness); | 481 tray_->AddTrayItem(tray_brightness); |
| 480 tray_->AddTrayItem(new internal::TraySettings()); | 482 tray_->AddTrayItem(new internal::TraySettings()); |
| 481 } | 483 } |
| 482 if (!status_widget_) | 484 if (!status_widget_) |
| 483 status_widget_ = internal::CreateStatusArea(tray_.get()); | 485 status_widget_ = internal::CreateStatusArea(tray_.get()); |
| 484 | 486 |
| 485 aura::Window* default_container = | 487 aura::Window* default_container = |
| 486 GetContainer(internal::kShellWindowId_DefaultContainer); | 488 GetContainer(internal::kShellWindowId_DefaultContainer); |
| 487 launcher_.reset(new Launcher(default_container)); | 489 launcher_.reset(new Launcher(default_container)); |
| 488 | 490 |
| 491 // This controller needs to be set before SetupManagedWindowMode. |
| 492 desktop_background_controller_.reset(new DesktopBackgroundController); |
| 493 |
| 489 InitLayoutManagers(); | 494 InitLayoutManagers(); |
| 490 | 495 |
| 491 if (!command_line->HasSwitch(switches::kAuraNoShadows)) | 496 if (!command_line->HasSwitch(switches::kAuraNoShadows)) |
| 492 shadow_controller_.reset(new internal::ShadowController()); | 497 shadow_controller_.reset(new internal::ShadowController()); |
| 493 | 498 |
| 494 focus_cycler_.reset(new internal::FocusCycler()); | 499 focus_cycler_.reset(new internal::FocusCycler()); |
| 495 focus_cycler_->AddWidget(status_widget_); | 500 focus_cycler_->AddWidget(status_widget_); |
| 496 focus_cycler_->AddWidget(launcher_->widget()); | 501 focus_cycler_->AddWidget(launcher_->widget()); |
| 497 launcher_->SetFocusCycler(focus_cycler_.get()); | 502 launcher_->SetFocusCycler(focus_cycler_.get()); |
| 498 | 503 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 if (workspace_controller_.get()) | 547 if (workspace_controller_.get()) |
| 543 workspace_controller_->ShowMenu(widget, location); | 548 workspace_controller_->ShowMenu(widget, location); |
| 544 } | 549 } |
| 545 | 550 |
| 546 void Shell::ToggleAppList() { | 551 void Shell::ToggleAppList() { |
| 547 if (!app_list_.get()) | 552 if (!app_list_.get()) |
| 548 app_list_.reset(new internal::AppList); | 553 app_list_.reset(new internal::AppList); |
| 549 app_list_->SetVisible(!app_list_->IsVisible()); | 554 app_list_->SetVisible(!app_list_->IsVisible()); |
| 550 } | 555 } |
| 551 | 556 |
| 552 void Shell::SetDesktopBackgroundMode(BackgroundMode mode) { | |
| 553 if (mode == BACKGROUND_SOLID_COLOR) { | |
| 554 // Set a solid black background. | |
| 555 // TODO(derat): Remove this in favor of having the compositor only clear the | |
| 556 // viewport when there are regions not covered by a layer: | |
| 557 // http://crbug.com/113445 | |
| 558 ui::Layer* background_layer = new ui::Layer(ui::Layer::LAYER_SOLID_COLOR); | |
| 559 background_layer->SetColor(SK_ColorBLACK); | |
| 560 GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)-> | |
| 561 layer()->Add(background_layer); | |
| 562 root_window_layout_->SetBackgroundLayer(background_layer); | |
| 563 root_window_layout_->SetBackgroundWidget(NULL); | |
| 564 } else { | |
| 565 // Create the desktop background image. | |
| 566 root_window_layout_->SetBackgroundLayer(NULL); | |
| 567 root_window_layout_->SetBackgroundWidget( | |
| 568 internal::CreateDesktopBackground()); | |
| 569 } | |
| 570 desktop_background_mode_ = mode; | |
| 571 } | |
| 572 | |
| 573 bool Shell::IsScreenLocked() const { | 557 bool Shell::IsScreenLocked() const { |
| 574 const aura::Window* lock_screen_container = GetContainer( | 558 const aura::Window* lock_screen_container = GetContainer( |
| 575 internal::kShellWindowId_LockScreenContainer); | 559 internal::kShellWindowId_LockScreenContainer); |
| 576 return lock_screen_container->StopsEventPropagation(); | 560 return lock_screen_container->StopsEventPropagation(); |
| 577 } | 561 } |
| 578 | 562 |
| 579 bool Shell::IsModalWindowOpen() const { | 563 bool Shell::IsModalWindowOpen() const { |
| 580 const aura::Window* modal_container = GetContainer( | 564 const aura::Window* modal_container = GetContainer( |
| 581 internal::kShellWindowId_SystemModalContainer); | 565 internal::kShellWindowId_SystemModalContainer); |
| 582 return !modal_container->children().empty(); | 566 return !modal_container->children().empty(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 GetContainer(internal::kShellWindowId_DefaultContainer); | 622 GetContainer(internal::kShellWindowId_DefaultContainer); |
| 639 // Workspace manager has its own layout managers. | 623 // Workspace manager has its own layout managers. |
| 640 workspace_controller_.reset( | 624 workspace_controller_.reset( |
| 641 new internal::WorkspaceController(default_container)); | 625 new internal::WorkspaceController(default_container)); |
| 642 workspace_controller_->workspace_manager()->set_shelf(shelf_layout_manager); | 626 workspace_controller_->workspace_manager()->set_shelf(shelf_layout_manager); |
| 643 | 627 |
| 644 // Ensure launcher is visible. | 628 // Ensure launcher is visible. |
| 645 launcher_->widget()->Show(); | 629 launcher_->widget()->Show(); |
| 646 | 630 |
| 647 // Create the desktop background image. | 631 // Create the desktop background image. |
| 648 SetDesktopBackgroundMode(BACKGROUND_IMAGE); | 632 desktop_background_controller_->SetDefaultDesktopBackgroundImage(); |
| 649 } | 633 } |
| 650 | 634 |
| 651 void Shell::DisableWorkspaceGridLayout() { | 635 void Shell::DisableWorkspaceGridLayout() { |
| 652 if (workspace_controller_.get()) | 636 if (workspace_controller_.get()) |
| 653 workspace_controller_->workspace_manager()->set_grid_size(0); | 637 workspace_controller_->workspace_manager()->set_grid_size(0); |
| 654 } | 638 } |
| 655 | 639 |
| 656 } // namespace ash | 640 } // namespace ash |
| OLD | NEW |