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

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: Address review 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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 tray_->AddTrayItem(tray_brightness); 449 tray_->AddTrayItem(tray_brightness);
447 tray_->AddTrayItem(new internal::TraySettings()); 450 tray_->AddTrayItem(new internal::TraySettings());
448 } 451 }
449 if (!status_widget_) 452 if (!status_widget_)
450 status_widget_ = internal::CreateStatusArea(tray_.get()); 453 status_widget_ = internal::CreateStatusArea(tray_.get());
451 454
452 aura::Window* default_container = 455 aura::Window* default_container =
453 GetContainer(internal::kShellWindowId_DefaultContainer); 456 GetContainer(internal::kShellWindowId_DefaultContainer);
454 launcher_.reset(new Launcher(default_container)); 457 launcher_.reset(new Launcher(default_container));
455 458
459 // This controller needs to be set before SetupManagedWindowMode.
460 desktop_background_controller_.reset(new DesktopBackgroundController);
461
456 if (window_mode_ == MODE_COMPACT) 462 if (window_mode_ == MODE_COMPACT)
457 SetupCompactWindowMode(); 463 SetupCompactWindowMode();
458 else 464 else
459 SetupManagedWindowMode(); 465 SetupManagedWindowMode();
460 466
461 if (!command_line->HasSwitch(switches::kAuraNoShadows)) 467 if (!command_line->HasSwitch(switches::kAuraNoShadows))
462 shadow_controller_.reset(new internal::ShadowController()); 468 shadow_controller_.reset(new internal::ShadowController());
463 469
464 focus_cycler_.reset(new internal::FocusCycler()); 470 focus_cycler_.reset(new internal::FocusCycler());
465 focus_cycler_->AddWidget(status_widget_); 471 focus_cycler_->AddWidget(status_widget_);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 if (workspace_controller_.get()) 537 if (workspace_controller_.get())
532 workspace_controller_->ShowMenu(widget, location); 538 workspace_controller_->ShowMenu(widget, location);
533 } 539 }
534 540
535 void Shell::ToggleAppList() { 541 void Shell::ToggleAppList() {
536 if (!app_list_.get()) 542 if (!app_list_.get())
537 app_list_.reset(new internal::AppList); 543 app_list_.reset(new internal::AppList);
538 app_list_->SetVisible(!app_list_->IsVisible()); 544 app_list_->SetVisible(!app_list_->IsVisible());
539 } 545 }
540 546
541 void Shell::SetDesktopBackgroundMode(BackgroundMode mode) { 547 void Shell::SetDesktopBackgroundWallpaper(const SkBitmap& wallpaper) {
542 if (mode == BACKGROUND_SOLID_COLOR) { 548 if (desktop_background_mode_ == BACKGROUND_SOLID_COLOR)
543 // Set a solid black background. 549 return;
544 // TODO(derat): Remove this in favor of having the compositor only clear the 550
545 // viewport when there are regions not covered by a layer: 551 DCHECK(root_window_layout_->background_widget());
546 // http://crbug.com/113445 552 static_cast<internal::DesktopBackgroundView*>(
547 ui::Layer* background_layer = new ui::Layer(ui::Layer::LAYER_SOLID_COLOR); 553 root_window_layout_->background_widget()->widget_delegate())->
548 background_layer->SetColor(SK_ColorBLACK); 554 SetWallpaper(wallpaper);
549 GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)-> 555 }
550 layer()->Add(background_layer); 556
551 root_window_layout_->SetBackgroundLayer(background_layer); 557 void Shell::SetDesktopBackgroundImageMode(const SkBitmap& wallpaper) {
552 root_window_layout_->SetBackgroundWidget(NULL); 558 root_window_layout_->SetBackgroundLayer(NULL);
553 } else { 559 root_window_layout_->SetBackgroundWidget(
554 // Create the desktop background image. 560 internal::CreateDesktopBackground(wallpaper));
555 root_window_layout_->SetBackgroundLayer(NULL); 561 desktop_background_mode_ = BACKGROUND_IMAGE;
556 root_window_layout_->SetBackgroundWidget( 562 }
557 internal::CreateDesktopBackground()); 563
558 } 564 void Shell::SetDesktopBackgroundSolidColorMode() {
559 desktop_background_mode_ = mode; 565 // Set a solid black background.
566 // TODO(derat): Remove this in favor of having the compositor only clear the
567 // viewport when there are regions not covered by a layer:
568 // http://crbug.com/113445
569 ui::Layer* background_layer = new ui::Layer(ui::Layer::LAYER_SOLID_COLOR);
570 background_layer->SetColor(SK_ColorBLACK);
571 GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)->
572 layer()->Add(background_layer);
573 root_window_layout_->SetBackgroundLayer(background_layer);
574 root_window_layout_->SetBackgroundWidget(NULL);
575 desktop_background_mode_ = BACKGROUND_SOLID_COLOR;
560 } 576 }
561 577
562 bool Shell::IsScreenLocked() const { 578 bool Shell::IsScreenLocked() const {
563 const aura::Window* lock_screen_container = GetContainer( 579 const aura::Window* lock_screen_container = GetContainer(
564 internal::kShellWindowId_LockScreenContainer); 580 internal::kShellWindowId_LockScreenContainer);
565 return lock_screen_container->StopsEventPropagation(); 581 return lock_screen_container->StopsEventPropagation();
566 } 582 }
567 583
568 bool Shell::IsModalWindowOpen() const { 584 bool Shell::IsModalWindowOpen() const {
569 const aura::Window* modal_container = GetContainer( 585 const aura::Window* modal_container = GetContainer(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 new internal::CompactStatusAreaLayoutManager(status_widget_); 644 new internal::CompactStatusAreaLayoutManager(status_widget_);
629 GetContainer(internal::kShellWindowId_StatusContainer)-> 645 GetContainer(internal::kShellWindowId_StatusContainer)->
630 SetLayoutManager(status_area_layout_manager); 646 SetLayoutManager(status_area_layout_manager);
631 default_container->SetLayoutManager(compact_layout_manager); 647 default_container->SetLayoutManager(compact_layout_manager);
632 648
633 // Keep the launcher for its data model, but hide it. Do this before 649 // 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. 650 // maximizing the windows so the work area is the right size.
635 launcher_->widget()->Hide(); 651 launcher_->widget()->Hide();
636 652
637 // Set a solid black background. 653 // Set a solid black background.
638 SetDesktopBackgroundMode(BACKGROUND_SOLID_COLOR); 654 SetDesktopBackgroundSolidColorMode();
639 } 655 }
640 656
641 void Shell::SetupManagedWindowMode() { 657 void Shell::SetupManagedWindowMode() {
642 DCHECK(root_window_layout_); 658 DCHECK(root_window_layout_);
643 DCHECK(status_widget_); 659 DCHECK(status_widget_);
644 660
645 internal::ShelfLayoutManager* shelf_layout_manager = 661 internal::ShelfLayoutManager* shelf_layout_manager =
646 new internal::ShelfLayoutManager(launcher_->widget(), status_widget_); 662 new internal::ShelfLayoutManager(launcher_->widget(), status_widget_);
647 GetContainer(internal::kShellWindowId_LauncherContainer)-> 663 GetContainer(internal::kShellWindowId_LauncherContainer)->
648 SetLayoutManager(shelf_layout_manager); 664 SetLayoutManager(shelf_layout_manager);
649 shelf_ = shelf_layout_manager; 665 shelf_ = shelf_layout_manager;
650 666
651 internal::StatusAreaLayoutManager* status_area_layout_manager = 667 internal::StatusAreaLayoutManager* status_area_layout_manager =
652 new internal::StatusAreaLayoutManager(shelf_layout_manager); 668 new internal::StatusAreaLayoutManager(shelf_layout_manager);
653 GetContainer(internal::kShellWindowId_StatusContainer)-> 669 GetContainer(internal::kShellWindowId_StatusContainer)->
654 SetLayoutManager(status_area_layout_manager); 670 SetLayoutManager(status_area_layout_manager);
655 671
656 aura::Window* default_container = 672 aura::Window* default_container =
657 GetContainer(internal::kShellWindowId_DefaultContainer); 673 GetContainer(internal::kShellWindowId_DefaultContainer);
658 // Workspace manager has its own layout managers. 674 // Workspace manager has its own layout managers.
659 workspace_controller_.reset( 675 workspace_controller_.reset(
660 new internal::WorkspaceController(default_container)); 676 new internal::WorkspaceController(default_container));
661 workspace_controller_->workspace_manager()->set_shelf(shelf_layout_manager); 677 workspace_controller_->workspace_manager()->set_shelf(shelf_layout_manager);
662 678
663 // Ensure launcher is visible. 679 // Ensure launcher is visible.
664 launcher_->widget()->Show(); 680 launcher_->widget()->Show();
665 681
666 // Create the desktop background image. 682 // Create the desktop background image.
667 SetDesktopBackgroundMode(BACKGROUND_IMAGE); 683 SetDesktopBackgroundImageMode(desktop_background_controller_->
684 GetPresetWallpaper());
668 } 685 }
669 686
670 void Shell::ResetLayoutManager(int container_id) { 687 void Shell::ResetLayoutManager(int container_id) {
671 GetContainer(container_id)->SetLayoutManager(NULL); 688 GetContainer(container_id)->SetLayoutManager(NULL);
672 } 689 }
673 690
674 void Shell::DisableWorkspaceGridLayout() { 691 void Shell::DisableWorkspaceGridLayout() {
675 if (workspace_controller_.get()) 692 if (workspace_controller_.get())
676 workspace_controller_->workspace_manager()->set_grid_size(0); 693 workspace_controller_->workspace_manager()->set_grid_size(0);
677 } 694 }
678 695
679 } // namespace ash 696 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698