summaryrefslogtreecommitdiffstats
path: root/ash/desktop_background
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-13 04:06:58 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-13 04:06:58 +0000
commit135b70b85b0f2bfbe453d098e3f40604417ba391 (patch)
treed349aedfc7de209b884fffaf854a9d1d2d47cd0f /ash/desktop_background
parent2a7f4cafa748abf16f8c7af7b20bb568b05fa160 (diff)
downloadchromium_src-135b70b85b0f2bfbe453d098e3f40604417ba391.zip
chromium_src-135b70b85b0f2bfbe453d098e3f40604417ba391.tar.gz
chromium_src-135b70b85b0f2bfbe453d098e3f40604417ba391.tar.bz2
Revert 126319 - Enable user change background image in settings page in Aura build.
Only support change between default background images currently. Need more refactor work on code. BUG=105508 TEST= Review URL: http://codereview.chromium.org/9580023 TBR=bshe@chromium.org Review URL: https://chromiumcodereview.appspot.com/9695033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126328 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/desktop_background')
-rw-r--r--ash/desktop_background/desktop_background_controller.cc77
-rw-r--r--ash/desktop_background/desktop_background_controller.h66
-rw-r--r--ash/desktop_background/desktop_background_resources.cc67
-rw-r--r--ash/desktop_background/desktop_background_resources.h19
-rw-r--r--ash/desktop_background/desktop_background_view.cc15
-rw-r--r--ash/desktop_background/desktop_background_view.h9
6 files changed, 7 insertions, 246 deletions
diff --git a/ash/desktop_background/desktop_background_controller.cc b/ash/desktop_background/desktop_background_controller.cc
deleted file mode 100644
index cc4e017..0000000
--- a/ash/desktop_background/desktop_background_controller.cc
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/desktop_background/desktop_background_controller.h"
-
-#include "ash/desktop_background/desktop_background_resources.h"
-#include "ash/desktop_background/desktop_background_view.h"
-#include "ash/shell.h"
-#include "ash/shell_factory.h"
-#include "ash/shell_window_ids.h"
-#include "ash/wm/root_window_layout_manager.h"
-#include "base/logging.h"
-#include "grit/ui_resources.h"
-#include "ui/aura/window.h"
-#include "ui/gfx/compositor/layer.h"
-#include "ui/gfx/image/image.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/views/widget/widget.h"
-
-namespace ash {
-
-DesktopBackgroundController::DesktopBackgroundController() :
- previous_wallpaper_index_(GetDefaultWallpaperIndex()),
- desktop_background_mode_(BACKGROUND_IMAGE) {
-}
-
-DesktopBackgroundController::~DesktopBackgroundController() {
-}
-
-void DesktopBackgroundController::OnDesktopBackgroundChanged(int index) {
- internal::RootWindowLayoutManager* root_window_layout =
- Shell::GetInstance()->root_window_layout();
- if (desktop_background_mode_ == BACKGROUND_SOLID_COLOR)
- return;
-
- DCHECK(root_window_layout->background_widget()->widget_delegate());
- static_cast<internal::DesktopBackgroundView*>(
- root_window_layout->background_widget()->widget_delegate())->
- SetWallpaper(GetWallpaper(index));
- previous_wallpaper_index_ = index;
-}
-
-void DesktopBackgroundController::SetDesktopBackgroundImageMode(
- const SkBitmap& wallpaper) {
- internal::RootWindowLayoutManager* root_window_layout =
- Shell::GetInstance()->root_window_layout();
- root_window_layout->SetBackgroundLayer(NULL);
- root_window_layout->SetBackgroundWidget(
- internal::CreateDesktopBackground(wallpaper));
- desktop_background_mode_ = BACKGROUND_IMAGE;
-}
-
-void DesktopBackgroundController::SetDefaultDesktopBackgroundImage() {
- SetDesktopBackgroundImageMode(GetWallpaper(GetDefaultWallpaperIndex()));
-}
-
-void DesktopBackgroundController::SetPreviousDesktopBackgroundImage() {
- SetDesktopBackgroundImageMode(GetWallpaper(previous_wallpaper_index_));
-}
-
-void DesktopBackgroundController::SetDesktopBackgroundSolidColorMode() {
- // Set a solid black background.
- // TODO(derat): Remove this in favor of having the compositor only clear the
- // viewport when there are regions not covered by a layer:
- // http://crbug.com/113445
- Shell* shell = Shell::GetInstance();
- ui::Layer* background_layer = new ui::Layer(ui::Layer::LAYER_SOLID_COLOR);
- background_layer->SetColor(SK_ColorBLACK);
- shell->GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)->
- layer()->Add(background_layer);
- shell->root_window_layout()->SetBackgroundLayer(background_layer);
- shell->root_window_layout()->SetBackgroundWidget(NULL);
- desktop_background_mode_ = BACKGROUND_SOLID_COLOR;
-}
-
-} // namespace ash
diff --git a/ash/desktop_background/desktop_background_controller.h b/ash/desktop_background/desktop_background_controller.h
deleted file mode 100644
index e6ef435..0000000
--- a/ash/desktop_background/desktop_background_controller.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_
-#define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_
-#pragma once
-
-#include "ash/ash_export.h"
-#include "base/basictypes.h"
-
-class SkBitmap;
-
-namespace ash {
-
-// A class to listen for login and desktop background change events and set the
-// corresponding default wallpaper in Aura shell.
-class ASH_EXPORT DesktopBackgroundController {
- public:
- enum BackgroundMode {
- BACKGROUND_IMAGE,
- BACKGROUND_SOLID_COLOR
- };
-
- DesktopBackgroundController();
- virtual ~DesktopBackgroundController();
-
- // Get the desktop background mode.
- BackgroundMode desktop_background_mode() const {
- return desktop_background_mode_;
- }
-
- // Change the desktop background image to wallpaper with |index|.
- void OnDesktopBackgroundChanged(int index);
-
- // Sets the desktop background to image mode and create a new background
- // widget with |wallpaper|.
- void SetDesktopBackgroundImageMode(const SkBitmap& wallpaper);
-
- // Sets the desktop background to image mode and create a new background
- // widget with default wallpaper.
- void SetDefaultDesktopBackgroundImage();
-
- // Sets the desktop background to image mode and create a new background
- // widget with previous selected wallpaper at run time.
- void SetPreviousDesktopBackgroundImage();
-
- // Sets the desktop background to solid color mode and create a solid color
- // layout.
- void SetDesktopBackgroundSolidColorMode();
-
- private:
- // We need to cache the previously used wallpaper index. So when users switch
- // desktop background color mode at run time, we can directly switch back to
- // the user selected wallpaper in image mode.
- int previous_wallpaper_index_;
-
- // Can change at runtime.
- BackgroundMode desktop_background_mode_;
-
- DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundController);
-};
-
-} // namespace ash
-
-#endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_
diff --git a/ash/desktop_background/desktop_background_resources.cc b/ash/desktop_background/desktop_background_resources.cc
deleted file mode 100644
index f7dc840..0000000
--- a/ash/desktop_background/desktop_background_resources.cc
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/desktop_background/desktop_background_resources.h"
-
-#include "base/logging.h"
-#include "grit/ui_resources.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/gfx/image/image.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-
-namespace {
-
-const int kDefaultWallpaperResources[] = {
- IDR_AURA_WALLPAPER,
- IDR_AURA_WALLPAPER_1,
- IDR_AURA_WALLPAPER_2,
- IDR_AURA_WALLPAPER_3,
- IDR_AURA_WALLPAPER_4,
- IDR_AURA_WALLPAPER_5,
- IDR_AURA_WALLPAPER_6,
- IDR_AURA_WALLPAPER_7,
- IDR_AURA_WALLPAPER_8,
-};
-
-const int kDefaultWallpaperResourcesThumb[] = {
- IDR_AURA_WALLPAPER_THUMB,
- IDR_AURA_WALLPAPER_1_THUMB,
- IDR_AURA_WALLPAPER_2_THUMB,
- IDR_AURA_WALLPAPER_3_THUMB,
- IDR_AURA_WALLPAPER_4_THUMB,
- IDR_AURA_WALLPAPER_5_THUMB,
- IDR_AURA_WALLPAPER_6_THUMB,
- IDR_AURA_WALLPAPER_7_THUMB,
- IDR_AURA_WALLPAPER_8_THUMB,
-};
-
-const int kDefaultWallpaperCount = arraysize(kDefaultWallpaperResources);
-
-const int kDefaultWallpaperIndex = 0;
-
-} // namespace
-
-namespace ash {
-
-int GetDefaultWallpaperIndex() {
- return kDefaultWallpaperIndex;
-}
-
-int GetWallpaperCount() {
- return kDefaultWallpaperCount;
-}
-
-const SkBitmap& GetWallpaper(int index) {
- DCHECK(index >= 0 && index < kDefaultWallpaperCount);
- return *ui::ResourceBundle::GetSharedInstance().GetImageNamed(
- kDefaultWallpaperResources[index]).ToSkBitmap();
-}
-
-const SkBitmap& GetWallpaperThumbnail(int index) {
- DCHECK(index >= 0 && index < kDefaultWallpaperCount);
- return *ui::ResourceBundle::GetSharedInstance().GetImageNamed(
- kDefaultWallpaperResourcesThumb[index]).ToSkBitmap();
-}
-
-} // namespace ash
diff --git a/ash/desktop_background/desktop_background_resources.h b/ash/desktop_background/desktop_background_resources.h
deleted file mode 100644
index 1bcfdf8..0000000
--- a/ash/desktop_background/desktop_background_resources.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_RESOURCES_H_
-#define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_RESOURCES_H_
-
-class SkBitmap;
-
-namespace ash {
-
-int GetDefaultWallpaperIndex();
-int GetWallpaperCount();
-const SkBitmap& GetWallpaper(int index);
-const SkBitmap& GetWallpaperThumbnail(int index);
-
-} // namespace ash
-
-#endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_RESOURCES_H_
diff --git a/ash/desktop_background/desktop_background_view.cc b/ash/desktop_background/desktop_background_view.cc
index 96c4a6e..dbf256f 100644
--- a/ash/desktop_background/desktop_background_view.cc
+++ b/ash/desktop_background/desktop_background_view.cc
@@ -28,20 +28,15 @@ static int RoundPositive(double x) {
////////////////////////////////////////////////////////////////////////////////
// DesktopBackgroundView, public:
-DesktopBackgroundView::DesktopBackgroundView(const SkBitmap& wallpaper) {
- wallpaper_ = wallpaper;
+DesktopBackgroundView::DesktopBackgroundView() {
+ wallpaper_ = *ui::ResourceBundle::GetSharedInstance().GetImageNamed(
+ IDR_AURA_WALLPAPER_1).ToSkBitmap();
wallpaper_.buildMipMap(false);
}
DesktopBackgroundView::~DesktopBackgroundView() {
}
-void DesktopBackgroundView::SetWallpaper(const SkBitmap& wallpaper) {
- wallpaper_ = wallpaper;
- wallpaper_.buildMipMap(false);
- SchedulePaint();
-}
-
////////////////////////////////////////////////////////////////////////////////
// DesktopBackgroundView, views::View overrides:
@@ -93,11 +88,11 @@ void DesktopBackgroundView::OnMouseReleased(const views::MouseEvent& event) {
Shell::GetInstance()->ShowBackgroundMenu(GetWidget(), event.location());
}
-views::Widget* CreateDesktopBackground(const SkBitmap& wallpaper) {
+views::Widget* CreateDesktopBackground() {
views::Widget* desktop_widget = new views::Widget;
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
- DesktopBackgroundView* view = new DesktopBackgroundView(wallpaper);
+ DesktopBackgroundView* view = new DesktopBackgroundView;
params.delegate = view;
params.parent =
Shell::GetInstance()->GetContainer(
diff --git a/ash/desktop_background/desktop_background_view.h b/ash/desktop_background/desktop_background_view.h
index f1f7652..6af6583 100644
--- a/ash/desktop_background/desktop_background_view.h
+++ b/ash/desktop_background/desktop_background_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -15,14 +15,9 @@ namespace internal {
class DesktopBackgroundView : public views::WidgetDelegateView {
public:
- DesktopBackgroundView(const SkBitmap& wallpaper);
+ DesktopBackgroundView();
virtual ~DesktopBackgroundView();
- // TODO(bshe): Remove this function once issue 117244 is fixed. It is
- // currently used in DesktopBackgroundController::
- // OnDesktopBackgroundChanged.
- void SetWallpaper(const SkBitmap& wallpaper);
-
private:
// Overridden from views::View:
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;