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

Side by Side Diff: ash/shell.cc

Issue 9580023: Enable user change background image in settings page in Aura build. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Move kPresetWallpaperIndex to desktop_background_resource Created 8 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 unified diff | Download patch | Annotate | Revision Log
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 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/shell_delegate.h" 18 #include "ash/shell_delegate.h"
16 #include "ash/shell_factory.h" 19 #include "ash/shell_factory.h"
17 #include "ash/shell_window_ids.h" 20 #include "ash/shell_window_ids.h"
18 #include "ash/system/audio/tray_volume.h" 21 #include "ash/system/audio/tray_volume.h"
19 #include "ash/system/brightness/tray_brightness.h" 22 #include "ash/system/brightness/tray_brightness.h"
20 #include "ash/system/settings/tray_settings.h" 23 #include "ash/system/settings/tray_settings.h"
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 474
472 window_modality_controller_.reset(new internal::WindowModalityController); 475 window_modality_controller_.reset(new internal::WindowModalityController);
473 AddRootWindowEventFilter(window_modality_controller_.get()); 476 AddRootWindowEventFilter(window_modality_controller_.get());
474 477
475 visibility_controller_.reset(new internal::VisibilityController); 478 visibility_controller_.reset(new internal::VisibilityController);
476 479
477 tooltip_controller_.reset(new internal::TooltipController); 480 tooltip_controller_.reset(new internal::TooltipController);
478 AddRootWindowEventFilter(tooltip_controller_.get()); 481 AddRootWindowEventFilter(tooltip_controller_.get());
479 482
480 drag_drop_controller_.reset(new internal::DragDropController); 483 drag_drop_controller_.reset(new internal::DragDropController);
484 desktop_background_controller_.reset(new DesktopBackgroundController);
481 power_button_controller_.reset(new PowerButtonController); 485 power_button_controller_.reset(new PowerButtonController);
482 video_detector_.reset(new VideoDetector); 486 video_detector_.reset(new VideoDetector);
483 window_cycle_controller_.reset(new WindowCycleController); 487 window_cycle_controller_.reset(new WindowCycleController);
484 } 488 }
485 489
486 Shell::WindowMode Shell::ComputeWindowMode(CommandLine* command_line) const { 490 Shell::WindowMode Shell::ComputeWindowMode(CommandLine* command_line) const {
487 // Some devices don't perform well with overlapping windows. 491 // Some devices don't perform well with overlapping windows.
488 if (command_line->HasSwitch(switches::kAuraForceCompactWindowMode)) 492 if (command_line->HasSwitch(switches::kAuraForceCompactWindowMode))
489 return MODE_COMPACT; 493 return MODE_COMPACT;
490 494
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 if (workspace_controller_.get()) 535 if (workspace_controller_.get())
532 workspace_controller_->ShowMenu(widget, location); 536 workspace_controller_->ShowMenu(widget, location);
533 } 537 }
534 538
535 void Shell::ToggleAppList() { 539 void Shell::ToggleAppList() {
536 if (!app_list_.get()) 540 if (!app_list_.get())
537 app_list_.reset(new internal::AppList); 541 app_list_.reset(new internal::AppList);
538 app_list_->SetVisible(!app_list_->IsVisible()); 542 app_list_->SetVisible(!app_list_->IsVisible());
539 } 543 }
540 544
541 void Shell::SetDesktopBackgroundMode(BackgroundMode mode) { 545 void Shell::SetDesktopBackgroundWallpaper(const SkBitmap& wallpaper) {
542 if (mode == BACKGROUND_SOLID_COLOR) { 546 if (desktop_background_mode_ == BACKGROUND_SOLID_COLOR)
543 // Set a solid black background. 547 return;
544 // TODO(derat): Remove this in favor of having the compositor only clear the 548 DCHECK(root_window_layout_->background_widget());
545 // viewport when there are regions not covered by a layer: 549 static_cast<internal::DesktopBackgroundView*>(
546 // http://crbug.com/113445 550 root_window_layout_->background_widget()->widget_delegate())->
547 ui::Layer* background_layer = new ui::Layer(ui::Layer::LAYER_SOLID_COLOR); 551 SetWallpaper(wallpaper);
548 background_layer->SetColor(SK_ColorBLACK); 552 }
549 GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)-> 553
550 layer()->Add(background_layer); 554 void Shell::SetDesktopBackgrondImage(const SkBitmap& wallpaper) {
551 root_window_layout_->SetBackgroundLayer(background_layer); 555 root_window_layout_->SetBackgroundLayer(NULL);
552 root_window_layout_->SetBackgroundWidget(NULL); 556 root_window_layout_->SetBackgroundWidget(
553 } else { 557 internal::CreateDesktopBackground(wallpaper));
554 // Create the desktop background image. 558 desktop_background_mode_ = BACKGROUND_IMAGE;
555 root_window_layout_->SetBackgroundLayer(NULL); 559 }
556 root_window_layout_->SetBackgroundWidget( 560
557 internal::CreateDesktopBackground()); 561 void Shell::SetDesktopBackgroundSolidColor() {
558 } 562 // Set a solid black background.
559 desktop_background_mode_ = mode; 563 // TODO(derat): Remove this in favor of having the compositor only clear the
564 // viewport when there are regions not covered by a layer:
565 // http://crbug.com/113445
566 ui::Layer* background_layer = new ui::Layer(ui::Layer::LAYER_SOLID_COLOR);
567 background_layer->SetColor(SK_ColorBLACK);
568 GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)->
569 layer()->Add(background_layer);
570 root_window_layout_->SetBackgroundLayer(background_layer);
571 root_window_layout_->SetBackgroundWidget(NULL);
572 desktop_background_mode_ = BACKGROUND_SOLID_COLOR;
560 } 573 }
561 574
562 bool Shell::IsScreenLocked() const { 575 bool Shell::IsScreenLocked() const {
563 const aura::Window* lock_screen_container = GetContainer( 576 const aura::Window* lock_screen_container = GetContainer(
564 internal::kShellWindowId_LockScreenContainer); 577 internal::kShellWindowId_LockScreenContainer);
565 return lock_screen_container->StopsEventPropagation(); 578 return lock_screen_container->StopsEventPropagation();
566 } 579 }
567 580
568 bool Shell::IsModalWindowOpen() const { 581 bool Shell::IsModalWindowOpen() const {
569 const aura::Window* modal_container = GetContainer( 582 const aura::Window* modal_container = GetContainer(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 new internal::CompactStatusAreaLayoutManager(status_widget_); 641 new internal::CompactStatusAreaLayoutManager(status_widget_);
629 GetContainer(internal::kShellWindowId_StatusContainer)-> 642 GetContainer(internal::kShellWindowId_StatusContainer)->
630 SetLayoutManager(status_area_layout_manager); 643 SetLayoutManager(status_area_layout_manager);
631 default_container->SetLayoutManager(compact_layout_manager); 644 default_container->SetLayoutManager(compact_layout_manager);
632 645
633 // Keep the launcher for its data model, but hide it. Do this before 646 // Keep the launcher for its data model, but hide it. Do this before
634 // maximizing the windows so the work area is the right size. 647 // maximizing the windows so the work area is the right size.
635 launcher_->widget()->Hide(); 648 launcher_->widget()->Hide();
636 649
637 // Set a solid black background. 650 // Set a solid black background.
638 SetDesktopBackgroundMode(BACKGROUND_SOLID_COLOR); 651 SetDesktopBackgroundSolidColor();
639 } 652 }
640 653
641 void Shell::SetupManagedWindowMode() { 654 void Shell::SetupManagedWindowMode() {
642 DCHECK(root_window_layout_); 655 DCHECK(root_window_layout_);
643 DCHECK(status_widget_); 656 DCHECK(status_widget_);
644 657
645 internal::ShelfLayoutManager* shelf_layout_manager = 658 internal::ShelfLayoutManager* shelf_layout_manager =
646 new internal::ShelfLayoutManager(launcher_->widget(), status_widget_); 659 new internal::ShelfLayoutManager(launcher_->widget(), status_widget_);
647 GetContainer(internal::kShellWindowId_LauncherContainer)-> 660 GetContainer(internal::kShellWindowId_LauncherContainer)->
648 SetLayoutManager(shelf_layout_manager); 661 SetLayoutManager(shelf_layout_manager);
649 shelf_ = shelf_layout_manager; 662 shelf_ = shelf_layout_manager;
650 663
651 internal::StatusAreaLayoutManager* status_area_layout_manager = 664 internal::StatusAreaLayoutManager* status_area_layout_manager =
652 new internal::StatusAreaLayoutManager(shelf_layout_manager); 665 new internal::StatusAreaLayoutManager(shelf_layout_manager);
653 GetContainer(internal::kShellWindowId_StatusContainer)-> 666 GetContainer(internal::kShellWindowId_StatusContainer)->
654 SetLayoutManager(status_area_layout_manager); 667 SetLayoutManager(status_area_layout_manager);
655 668
656 aura::Window* default_container = 669 aura::Window* default_container =
657 GetContainer(internal::kShellWindowId_DefaultContainer); 670 GetContainer(internal::kShellWindowId_DefaultContainer);
658 // Workspace manager has its own layout managers. 671 // Workspace manager has its own layout managers.
659 workspace_controller_.reset( 672 workspace_controller_.reset(
660 new internal::WorkspaceController(default_container)); 673 new internal::WorkspaceController(default_container));
661 workspace_controller_->workspace_manager()->set_shelf(shelf_layout_manager); 674 workspace_controller_->workspace_manager()->set_shelf(shelf_layout_manager);
662 675
663 // Ensure launcher is visible. 676 // Ensure launcher is visible.
664 launcher_->widget()->Show(); 677 launcher_->widget()->Show();
665 678
666 // Create the desktop background image. 679 // Create the desktop background image.
667 SetDesktopBackgroundMode(BACKGROUND_IMAGE); 680 SetDesktopBackgrondImage(desktop_background_controller_->
681 GetPresetWallpaper());
668 } 682 }
669 683
670 void Shell::ResetLayoutManager(int container_id) { 684 void Shell::ResetLayoutManager(int container_id) {
671 GetContainer(container_id)->SetLayoutManager(NULL); 685 GetContainer(container_id)->SetLayoutManager(NULL);
672 } 686 }
673 687
674 void Shell::DisableWorkspaceGridLayout() { 688 void Shell::DisableWorkspaceGridLayout() {
675 if (workspace_controller_.get()) 689 if (workspace_controller_.get())
676 workspace_controller_->workspace_manager()->set_grid_size(0); 690 workspace_controller_->workspace_manager()->set_grid_size(0);
677 } 691 }
678 692
679 } // namespace ash 693 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698