summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/accelerators/accelerator_controller.cc11
-rw-r--r--ash/ash.gyp4
-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
-rw-r--r--ash/shell.cc30
-rw-r--r--ash/shell.h21
-rw-r--r--ash/shell_factory.h4
-rw-r--r--chrome/app/generated_resources.grd9
-rw-r--r--chrome/browser/chromeos/background/desktop_background_observer.cc50
-rw-r--r--chrome/browser/chromeos/background/desktop_background_observer.h36
-rw-r--r--chrome/browser/chromeos/chrome_browser_main_chromeos.cc10
-rw-r--r--chrome/browser/chromeos/chrome_browser_main_chromeos.h8
-rw-r--r--chrome/browser/chromeos/login/mock_user_manager.h2
-rw-r--r--chrome/browser/chromeos/login/user_manager.cc3
-rw-r--r--chrome/browser/chromeos/login/user_manager.h14
-rw-r--r--chrome/browser/chromeos/login/user_manager_impl.cc32
-rw-r--r--chrome/browser/chromeos/login/user_manager_impl.h3
-rw-r--r--chrome/browser/resources/options2/browser_options.html9
-rw-r--r--chrome/browser/resources/options2/browser_options.js6
-rw-r--r--chrome/browser/resources/options2/chromeos/change_picture_options.html2
-rw-r--r--chrome/browser/resources/options2/chromeos/image_picker.css (renamed from chrome/browser/resources/options2/chromeos/change_picture_options.css)10
-rw-r--r--chrome/browser/resources/options2/chromeos/set_wallpaper_options.css12
-rw-r--r--chrome/browser/resources/options2/chromeos/set_wallpaper_options.html12
-rw-r--r--chrome/browser/resources/options2/chromeos/set_wallpaper_options.js137
-rw-r--r--chrome/browser/resources/options2/options.html8
-rw-r--r--chrome/browser/resources/options2/options.js9
-rw-r--r--chrome/browser/resources/options2/options_bundle.js4
-rw-r--r--chrome/browser/ui/webui/options2/browser_options_handler2.cc3
-rw-r--r--chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc116
-rw-r--r--chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.h57
-rw-r--r--chrome/browser/ui/webui/options2/options_ui2.cc9
-rw-r--r--chrome/chrome_browser.gypi4
-rw-r--r--ui/resources/ui_resources.grd37
37 files changed, 848 insertions, 77 deletions
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc
index 0eb7ce8..b43b5f4 100644
--- a/ash/accelerators/accelerator_controller.cc
+++ b/ash/accelerators/accelerator_controller.cc
@@ -5,6 +5,7 @@
#include "ash/accelerators/accelerator_controller.h"
#include "ash/accelerators/accelerator_table.h"
+#include "ash/desktop_background/desktop_background_controller.h"
#include "ash/ash_switches.h"
#include "ash/caps_lock_delegate.h"
#include "ash/ime_control_delegate.h"
@@ -90,11 +91,13 @@ bool HandleRotateScreen() {
}
bool HandleToggleDesktopBackgroundMode() {
- ash::Shell* shell = ash::Shell::GetInstance();
- if (shell->desktop_background_mode() == ash::Shell::BACKGROUND_IMAGE)
- shell->SetDesktopBackgroundMode(ash::Shell::BACKGROUND_SOLID_COLOR);
+ ash::DesktopBackgroundController* desktop_background_controller =
+ ash::Shell::GetInstance()->desktop_background_controller();
+ if (desktop_background_controller->desktop_background_mode() ==
+ ash::DesktopBackgroundController::BACKGROUND_IMAGE)
+ desktop_background_controller->SetDesktopBackgroundSolidColorMode();
else
- shell->SetDesktopBackgroundMode(ash::Shell::BACKGROUND_IMAGE);
+ desktop_background_controller->SetPreviousDesktopBackgroundImage();
return true;
}
diff --git a/ash/ash.gyp b/ash/ash.gyp
index a5ee083..2626712 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -67,6 +67,10 @@
'ash_switches.cc',
'ash_switches.h',
'caps_lock_delegate.h',
+ 'desktop_background/desktop_background_controller.cc',
+ 'desktop_background/desktop_background_controller.h',
+ 'desktop_background/desktop_background_resources.cc',
+ 'desktop_background/desktop_background_resources.h',
'desktop_background/desktop_background_view.cc',
'desktop_background/desktop_background_view.h',
'drag_drop/drag_drop_controller.cc',
diff --git a/ash/desktop_background/desktop_background_controller.cc b/ash/desktop_background/desktop_background_controller.cc
new file mode 100644
index 0000000..cc4e017
--- /dev/null
+++ b/ash/desktop_background/desktop_background_controller.cc
@@ -0,0 +1,77 @@
+// 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
new file mode 100644
index 0000000..e6ef435
--- /dev/null
+++ b/ash/desktop_background/desktop_background_controller.h
@@ -0,0 +1,66 @@
+// 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
new file mode 100644
index 0000000..f7dc840
--- /dev/null
+++ b/ash/desktop_background/desktop_background_resources.cc
@@ -0,0 +1,67 @@
+// 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
new file mode 100644
index 0000000..1bcfdf8
--- /dev/null
+++ b/ash/desktop_background/desktop_background_resources.h
@@ -0,0 +1,19 @@
+// 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 dbf256f..96c4a6e 100644
--- a/ash/desktop_background/desktop_background_view.cc
+++ b/ash/desktop_background/desktop_background_view.cc
@@ -28,15 +28,20 @@ static int RoundPositive(double x) {
////////////////////////////////////////////////////////////////////////////////
// DesktopBackgroundView, public:
-DesktopBackgroundView::DesktopBackgroundView() {
- wallpaper_ = *ui::ResourceBundle::GetSharedInstance().GetImageNamed(
- IDR_AURA_WALLPAPER_1).ToSkBitmap();
+DesktopBackgroundView::DesktopBackgroundView(const SkBitmap& wallpaper) {
+ wallpaper_ = wallpaper;
wallpaper_.buildMipMap(false);
}
DesktopBackgroundView::~DesktopBackgroundView() {
}
+void DesktopBackgroundView::SetWallpaper(const SkBitmap& wallpaper) {
+ wallpaper_ = wallpaper;
+ wallpaper_.buildMipMap(false);
+ SchedulePaint();
+}
+
////////////////////////////////////////////////////////////////////////////////
// DesktopBackgroundView, views::View overrides:
@@ -88,11 +93,11 @@ void DesktopBackgroundView::OnMouseReleased(const views::MouseEvent& event) {
Shell::GetInstance()->ShowBackgroundMenu(GetWidget(), event.location());
}
-views::Widget* CreateDesktopBackground() {
+views::Widget* CreateDesktopBackground(const SkBitmap& wallpaper) {
views::Widget* desktop_widget = new views::Widget;
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
- DesktopBackgroundView* view = new DesktopBackgroundView;
+ DesktopBackgroundView* view = new DesktopBackgroundView(wallpaper);
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 6af6583..f1f7652 100644
--- a/ash/desktop_background/desktop_background_view.h
+++ b/ash/desktop_background/desktop_background_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -15,9 +15,14 @@ namespace internal {
class DesktopBackgroundView : public views::WidgetDelegateView {
public:
- DesktopBackgroundView();
+ DesktopBackgroundView(const SkBitmap& wallpaper);
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;
diff --git a/ash/shell.cc b/ash/shell.cc
index d3a794a..4b4c29f 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -8,6 +8,9 @@
#include "ash/app_list/app_list.h"
#include "ash/ash_switches.h"
+#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/drag_drop/drag_drop_controller.h"
#include "ash/focus_cycler.h"
#include "ash/ime/input_method_event_filter.h"
@@ -341,7 +344,6 @@ Shell::Shell(ShellDelegate* delegate)
root_filter_(NULL),
delegate_(delegate),
shelf_(NULL),
- desktop_background_mode_(BACKGROUND_IMAGE),
root_window_layout_(NULL),
status_widget_(NULL) {
aura::Env::GetInstance()->SetMonitorManager(
@@ -517,6 +519,9 @@ void Shell::Init() {
GetContainer(internal::kShellWindowId_DefaultContainer);
launcher_.reset(new Launcher(default_container));
+ // This controller needs to be set before SetupManagedWindowMode.
+ desktop_background_controller_.reset(new DesktopBackgroundController);
+
InitLayoutManagers();
if (!command_line->HasSwitch(switches::kAuraNoShadows))
@@ -580,27 +585,6 @@ void Shell::ToggleAppList() {
app_list_->SetVisible(!app_list_->IsVisible());
}
-void Shell::SetDesktopBackgroundMode(BackgroundMode mode) {
- if (mode == BACKGROUND_SOLID_COLOR) {
- // 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
- ui::Layer* background_layer = new ui::Layer(ui::Layer::LAYER_SOLID_COLOR);
- background_layer->SetColor(SK_ColorBLACK);
- GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)->
- layer()->Add(background_layer);
- root_window_layout_->SetBackgroundLayer(background_layer);
- root_window_layout_->SetBackgroundWidget(NULL);
- } else {
- // Create the desktop background image.
- root_window_layout_->SetBackgroundLayer(NULL);
- root_window_layout_->SetBackgroundWidget(
- internal::CreateDesktopBackground());
- }
- desktop_background_mode_ = mode;
-}
-
bool Shell::IsScreenLocked() const {
const aura::Window* lock_screen_container = GetContainer(
internal::kShellWindowId_LockScreenContainer);
@@ -683,7 +667,7 @@ void Shell::InitLayoutManagers() {
launcher_->widget()->Show();
// Create the desktop background image.
- SetDesktopBackgroundMode(BACKGROUND_IMAGE);
+ desktop_background_controller_->SetDefaultDesktopBackgroundImage();
}
void Shell::DisableWorkspaceGridLayout() {
diff --git a/ash/shell.h b/ash/shell.h
index 8a0f615..29e6e2b 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -19,6 +19,7 @@
#include "ui/gfx/insets.h"
class CommandLine;
+class SkBitmap;
namespace aura {
class EventFilter;
@@ -40,6 +41,7 @@ class Widget;
namespace ash {
class AcceleratorController;
+class DesktopBackgroundController;
class Launcher;
class NestedDispatcherController;
class PowerButtonController;
@@ -77,11 +79,6 @@ class WorkspaceController;
// takes ownership of the Shell.
class ASH_EXPORT Shell {
public:
- enum BackgroundMode {
- BACKGROUND_IMAGE,
- BACKGROUND_SOLID_COLOR
- };
-
enum Direction {
FORWARD,
BACKWARD
@@ -117,8 +114,8 @@ class ASH_EXPORT Shell {
// Get the singleton RootWindow used by the Shell.
static aura::RootWindow* GetRootWindow();
- BackgroundMode desktop_background_mode() const {
- return desktop_background_mode_;
+ internal::RootWindowLayoutManager* root_window_layout() const {
+ return root_window_layout_;
}
aura::Window* GetContainer(int container_id);
@@ -135,9 +132,6 @@ class ASH_EXPORT Shell {
// Toggles app list.
void ToggleAppList();
- // Sets the desktop background mode.
- void SetDesktopBackgroundMode(BackgroundMode mode);
-
// Returns true if the screen is locked.
bool IsScreenLocked() const;
@@ -176,6 +170,9 @@ class ASH_EXPORT Shell {
internal::PartialScreenshotEventFilter* partial_screenshot_filter() {
return partial_screenshot_filter_.get();
}
+ DesktopBackgroundController* desktop_background_controller() {
+ return desktop_background_controller_.get();
+ }
PowerButtonController* power_button_controller() {
return power_button_controller_.get();
}
@@ -263,6 +260,7 @@ class ASH_EXPORT Shell {
scoped_ptr<internal::ShadowController> shadow_controller_;
scoped_ptr<internal::TooltipController> tooltip_controller_;
scoped_ptr<internal::VisibilityController> visibility_controller_;
+ scoped_ptr<DesktopBackgroundController> desktop_background_controller_;
scoped_ptr<PowerButtonController> power_button_controller_;
scoped_ptr<VideoDetector> video_detector_;
scoped_ptr<WindowCycleController> window_cycle_controller_;
@@ -287,9 +285,6 @@ class ASH_EXPORT Shell {
ObserverList<ShellObserver> observers_;
- // Can change at runtime.
- BackgroundMode desktop_background_mode_;
-
// Owned by aura::RootWindow, cached here for type safety.
internal::RootWindowLayoutManager* root_window_layout_;
diff --git a/ash/shell_factory.h b/ash/shell_factory.h
index 0faec35..b90889b 100644
--- a/ash/shell_factory.h
+++ b/ash/shell_factory.h
@@ -8,6 +8,8 @@
#include "ash/ash_export.h"
+class SkBitmap;
+
namespace views {
class View;
class Widget;
@@ -18,7 +20,7 @@ class Widget;
namespace ash {
namespace internal {
-views::Widget* CreateDesktopBackground();
+views::Widget* CreateDesktopBackground(const SkBitmap& wallpaper);
ASH_EXPORT views::Widget* CreateStatusArea(views::View* contents);
} // namespace internal
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 1e8924f..cb38168 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -12656,6 +12656,15 @@ Some features may be unavailable. Please check that the profile exists and you
<message name="IDS_OPTIONS_ENABLE_SCREENLOCKER_CHECKBOX" desc="In the Personal Stuff settings tab, the text on the checkbox to enable screenlocker for current user.">
Require password to wake from sleep
</message>
+ <message name="IDS_SET_WALLPAPER_BUTTON" desc="The button to set wallpaper.">
+ Set Wallpaper...
+ </message>
+ <message name="IDS_OPTIONS_SET_WALLPAPER_DIALOG_TITLE" desc="Title of the dialog shown when user wants to change his/her wallpaper.">
+ Set Wallpaper
+ </message>
+ <message name="IDS_OPTIONS_SET_WALLPAPER_DIALOG_TEXT" desc="Text with description of what to do on Change Wallpaper dialog.">
+ Choose a picture to display on your background.
+ </message>
<message name="IDS_OPTIONS_CHANGE_PICTURE" desc="In the settings tab, the text on the button to change picture for the current user.">
Change picture...
</message>
diff --git a/chrome/browser/chromeos/background/desktop_background_observer.cc b/chrome/browser/chromeos/background/desktop_background_observer.cc
new file mode 100644
index 0000000..e803c60
--- /dev/null
+++ b/chrome/browser/chromeos/background/desktop_background_observer.cc
@@ -0,0 +1,50 @@
+// 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 "chrome/browser/chromeos/background/desktop_background_observer.h"
+
+#include "ash/shell.h"
+#include "ash/desktop_background/desktop_background_controller.h"
+#include "ash/desktop_background/desktop_background_resources.h"
+#include "base/logging.h"
+#include "chrome/browser/chromeos/login/user_manager.h"
+#include "chrome/common/chrome_notification_types.h"
+#include "content/public/browser/notification_service.h"
+
+namespace chromeos {
+
+DesktopBackgroundObserver::DesktopBackgroundObserver() {
+ registrar_.Add(
+ this,
+ chrome::NOTIFICATION_LOGIN_USER_CHANGED,
+ content::NotificationService::AllSources());
+}
+
+DesktopBackgroundObserver::~DesktopBackgroundObserver() {
+}
+
+int DesktopBackgroundObserver::GetUserWallpaperIndex() {
+ chromeos::UserManager* user_manager = chromeos::UserManager::Get();
+ const chromeos::User& user = user_manager->GetLoggedInUser();
+ DCHECK(!user.email().empty());
+ int index = user_manager->GetUserWallpaper(user.email());
+ DCHECK(index >=0 && index < ash::GetWallpaperCount());
+ return index;
+}
+
+void DesktopBackgroundObserver::Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ switch (type) {
+ case chrome::NOTIFICATION_LOGIN_USER_CHANGED: {
+ ash::Shell::GetInstance()->desktop_background_controller()->
+ OnDesktopBackgroundChanged(GetUserWallpaperIndex());
+ break;
+ }
+ default:
+ NOTREACHED();
+ }
+}
+
+} // namespace chromeos
diff --git a/chrome/browser/chromeos/background/desktop_background_observer.h b/chrome/browser/chromeos/background/desktop_background_observer.h
new file mode 100644
index 0000000..2fcca772
--- /dev/null
+++ b/chrome/browser/chromeos/background/desktop_background_observer.h
@@ -0,0 +1,36 @@
+// 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 CHROME_BROWSER_CHROMEOS_BACKGROUND_DESKTOP_BACKGROUND_OBSERVER_H_
+#define CHROME_BROWSER_CHROMEOS_BACKGROUND_DESKTOP_BACKGROUND_OBSERVER_H_
+#pragma once
+
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+
+namespace chromeos {
+
+// Listens for background change events and passes them to the Aura shell's
+// DesktopBackgroundController class.
+class DesktopBackgroundObserver : public content::NotificationObserver{
+ public:
+ DesktopBackgroundObserver();
+ virtual ~DesktopBackgroundObserver();
+
+ private:
+ // Returns the index of user selected wallpaper from a default wallpaper list.
+ int GetUserWallpaperIndex();
+
+ // content::NotificationObserver implementation.
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ content::NotificationRegistrar registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundObserver);
+};
+
+} // namespace chromeos
+#endif // CHROME_BROWSER_CHROMEOS_BACKGROUND_DESKTOP_BACKGROUND_OBSERVER_H_
diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
index 2bc1dc6..7ca0181 100644
--- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
+++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
@@ -68,6 +68,10 @@
#include <gtk/gtk.h>
#endif
+#if defined(OS_CHROMEOS) && defined(USE_ASH)
+#include "chrome/browser/chromeos/background/desktop_background_observer.h"
+#endif
+
#if defined(USE_AURA)
#include "chrome/browser/chromeos/legacy_window_manager/initial_browser_window_observer.h"
#include "chrome/browser/chromeos/power/power_button_controller_delegate_chromeos.h"
@@ -408,6 +412,12 @@ void ChromeBrowserMainPartsChromeos::PreProfileInit() {
// In Aura builds this will initialize ash::Shell.
ChromeBrowserMainPartsLinux::PreProfileInit();
+
+#if defined(OS_CHROMEOS) && defined(USE_ASH)
+ // Initialize desktop background observer so that it can receive
+ // LOGIN_USER_CHANGED notification from UserManager.
+ desktop_background_observer_.reset(new chromeos::DesktopBackgroundObserver);
+#endif
}
void ChromeBrowserMainPartsChromeos::PostProfileInit() {
diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.h b/chrome/browser/chromeos/chrome_browser_main_chromeos.h
index 156dc58..765990b 100644
--- a/chrome/browser/chromeos/chrome_browser_main_chromeos.h
+++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.h
@@ -14,6 +14,10 @@ class ResumeObserver;
class ScreenLockObserver;
class SessionManagerObserver;
+#if defined(OS_CHROMEOS) && defined(USE_ASH)
+class DesktopBackgroundObserver;
+#endif
+
#if defined(USE_AURA)
class InitialBrowserWindowObserver;
class PowerButtonObserver;
@@ -47,6 +51,10 @@ class ChromeBrowserMainPartsChromeos : public ChromeBrowserMainPartsLinux {
scoped_ptr<chromeos::ScreenLockObserver> screen_lock_observer_;
scoped_ptr<chromeos::SessionManagerObserver> session_manager_observer_;
+#if defined(OS_CHROMEOS) && defined(USE_ASH)
+ scoped_ptr<chromeos::DesktopBackgroundObserver> desktop_background_observer_;
+#endif
+
#if defined(USE_AURA)
scoped_ptr<chromeos::InitialBrowserWindowObserver>
initial_browser_window_observer_;
diff --git a/chrome/browser/chromeos/login/mock_user_manager.h b/chrome/browser/chromeos/login/mock_user_manager.h
index ca9462e..943a4ec 100644
--- a/chrome/browser/chromeos/login/mock_user_manager.h
+++ b/chrome/browser/chromeos/login/mock_user_manager.h
@@ -35,6 +35,8 @@ class MockUserManager : public UserManager {
User::OAuthTokenStatus));
MOCK_METHOD2(SaveUserDisplayEmail, void(const std::string&,
const std::string&));
+ MOCK_METHOD1(GetUserWallpaper, int(const std::string&));
+ MOCK_METHOD2(SaveWallpaperDefaultIndex, void(const std::string&, int));
MOCK_CONST_METHOD1(GetUserDisplayEmail, std::string(const std::string&));
MOCK_METHOD2(SaveUserDefaultImageIndex, void(const std::string&, int));
MOCK_METHOD2(SaveUserImage, void(const std::string&, const SkBitmap&));
diff --git a/chrome/browser/chromeos/login/user_manager.cc b/chrome/browser/chromeos/login/user_manager.cc
index 4762bd0..d460086 100644
--- a/chrome/browser/chromeos/login/user_manager.cc
+++ b/chrome/browser/chromeos/login/user_manager.cc
@@ -13,6 +13,7 @@ namespace chromeos {
// static
const char UserManager::kLoggedInUsers[] = "LoggedInUsers";
+const char UserManager::kUserWallpapers[] = "UserWallpapers";
const char UserManager::kUserImages[] = "UserImages";
const char UserManager::kUserDisplayEmail[] = "UserDisplayEmail";
const char UserManager::kUserOAuthTokenStatus[] = "OAuthTokenStatus";
@@ -69,6 +70,8 @@ void UserManager::Set(UserManager* mock) {
// static
void UserManager::RegisterPrefs(PrefService* local_state) {
local_state->RegisterListPref(kLoggedInUsers, PrefService::UNSYNCABLE_PREF);
+ local_state->RegisterDictionaryPref(kUserWallpapers,
+ PrefService::UNSYNCABLE_PREF);
local_state->RegisterDictionaryPref(kUserImages,
PrefService::UNSYNCABLE_PREF);
local_state->RegisterDictionaryPref(kUserOAuthTokenStatus,
diff --git a/chrome/browser/chromeos/login/user_manager.h b/chrome/browser/chromeos/login/user_manager.h
index 837d8c0..392b4b7 100644
--- a/chrome/browser/chromeos/login/user_manager.h
+++ b/chrome/browser/chromeos/login/user_manager.h
@@ -37,6 +37,9 @@ class UserManager {
// A vector pref of the users who have logged into the device.
static const char kLoggedInUsers[];
+ // A dictionary that maps usernames to file paths to their wallpapers.
+ static const char kUserWallpapers[];
+
// A dictionary that maps usernames to file paths to their images.
static const char kUserImages[];
@@ -116,6 +119,17 @@ class UserManager {
virtual std::string GetUserDisplayEmail(
const std::string& username) const = 0;
+ // Returns the index of the default wallpapers saved in local state for user
+ // |username| if it is known (was previousely set by
+ // |SaveWallpaperToLocalState| call).
+ // Otherwise, returns default wallpaper index.
+ virtual int GetUserWallpaper(const std::string& username) = 0;
+
+ // Sets user wallpaper to the default wallpaper with index |wallpaper_index|,
+ // updates Local State.
+ virtual void SaveWallpaperDefaultIndex(const std::string& username,
+ int wallpaper_index) = 0;
+
// Sets user image to the default image with index |image_index|, sends
// LOGIN_USER_IMAGE_CHANGED notification and updates Local State.
virtual void SaveUserDefaultImageIndex(const std::string& username,
diff --git a/chrome/browser/chromeos/login/user_manager_impl.cc b/chrome/browser/chromeos/login/user_manager_impl.cc
index 1f52a25..895ee7b 100644
--- a/chrome/browser/chromeos/login/user_manager_impl.cc
+++ b/chrome/browser/chromeos/login/user_manager_impl.cc
@@ -6,6 +6,9 @@
#include <vector>
+#include "ash/shell.h"
+#include "ash/desktop_background/desktop_background_controller.h"
+#include "ash/desktop_background/desktop_background_resources.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
@@ -897,6 +900,31 @@ void UserManagerImpl::SetInitialUserImage(const std::string& username) {
SaveUserDefaultImageIndex(username, image_id);
}
+int UserManagerImpl::GetUserWallpaper(const std::string& username) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ PrefService* local_state = g_browser_process->local_state();
+ const DictionaryValue* user_wallpapers =
+ local_state->GetDictionary(UserManager::kUserWallpapers);
+ int index = ash::GetDefaultWallpaperIndex();
+ user_wallpapers->GetIntegerWithoutPathExpansion(username,
+ &index);
+ return index;
+}
+
+void UserManagerImpl::SaveWallpaperDefaultIndex(const std::string& username,
+ int wallpaper_index) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ PrefService* local_state = g_browser_process->local_state();
+ DictionaryPrefUpdate wallpapers_update(local_state,
+ UserManager::kUserWallpapers);
+ wallpapers_update->SetWithoutPathExpansion(username,
+ new base::FundamentalValue(wallpaper_index));
+ ash::Shell::GetInstance()->desktop_background_controller()->
+ OnDesktopBackgroundChanged(wallpaper_index);
+}
+
void UserManagerImpl::SetUserImage(const std::string& username,
int image_index,
const SkBitmap& image) {
@@ -1153,6 +1181,10 @@ void UserManagerImpl::RemoveUserFromListInternal(const std::string& email) {
user_to_remove = it;
}
+ DictionaryPrefUpdate prefs_wallpapers_update(prefs,
+ kUserWallpapers);
+ prefs_wallpapers_update->RemoveWithoutPathExpansion(email, NULL);
+
DictionaryPrefUpdate prefs_images_update(prefs, kUserImages);
std::string image_path_string;
prefs_images_update->GetStringWithoutPathExpansion(email, &image_path_string);
diff --git a/chrome/browser/chromeos/login/user_manager_impl.h b/chrome/browser/chromeos/login/user_manager_impl.h
index 6e8e3c5..8176df7 100644
--- a/chrome/browser/chromeos/login/user_manager_impl.h
+++ b/chrome/browser/chromeos/login/user_manager_impl.h
@@ -61,6 +61,9 @@ class UserManagerImpl : public UserManager,
const std::string& display_email) OVERRIDE;
virtual std::string GetUserDisplayEmail(
const std::string& username) const OVERRIDE;
+ virtual int GetUserWallpaper(const std::string& username) OVERRIDE;
+ virtual void SaveWallpaperDefaultIndex(const std::string& username,
+ int wallpaper_index) OVERRIDE;
virtual void SaveUserDefaultImageIndex(const std::string& username,
int image_index) OVERRIDE;
virtual void SaveUserImage(const std::string& username,
diff --git a/chrome/browser/resources/options2/browser_options.html b/chrome/browser/resources/options2/browser_options.html
index 0f358f5..23557aa 100644
--- a/chrome/browser/resources/options2/browser_options.html
+++ b/chrome/browser/resources/options2/browser_options.html
@@ -89,21 +89,22 @@
</if>
<section>
<h3 i18n-content="sectionTitleAppearance"></h3>
-<if expr="not pp_ifdef('toolkit_views') and is_posix and not is_macosx">
<div>
+<if expr="pp_ifdef('chromeos') and pp_ifdef('use_ash')">
+ <button id="set-wallpaper" i18n-content="setWallpaper"></button>
+</if>
+<if expr="not pp_ifdef('toolkit_views') and is_posix and not is_macosx">
<button id="themes-gallery" i18n-content="themesGallery"></button>
<button id="themes-GTK-button"
i18n-content="themesGTKButton"></button>
<button id="themes-reset"
i18n-content="themesSetClassic"></button>
- </div>
</if>
<if expr="pp_ifdef('toolkit_views') or is_win or is_macosx">
- <div>
<button id="themes-gallery" i18n-content="themesGallery"></button>
<button id="themes-reset" i18n-content="themesReset"></button>
- </div>
</if>
+ </div>
<div class="settings-row">
<span i18n-content="homePage"></span>
<select id="home-page-select">
diff --git a/chrome/browser/resources/options2/browser_options.js b/chrome/browser/resources/options2/browser_options.js
index b5dec20..485f820 100644
--- a/chrome/browser/resources/options2/browser_options.js
+++ b/chrome/browser/resources/options2/browser_options.js
@@ -126,6 +126,12 @@ cr.define('options', function() {
self.onHomePagePrefChanged_.bind(self));
});
+ if ($('set-wallpaper')) {
+ $('set-wallpaper').onclick = function(event) {
+ OptionsPage.navigateToPage('setWallpaper');
+ };
+ }
+
$('themes-gallery').onclick = function(event) {
window.open(localStrings.getString('themesGalleryURL'));
};
diff --git a/chrome/browser/resources/options2/chromeos/change_picture_options.html b/chrome/browser/resources/options2/chromeos/change_picture_options.html
index 7b1657a..784f0ba 100644
--- a/chrome/browser/resources/options2/chromeos/change_picture_options.html
+++ b/chrome/browser/resources/options2/chromeos/change_picture_options.html
@@ -3,7 +3,7 @@
<h1 i18n-content="changePicturePage"></h1>
<div class="content-area">
<span i18n-content="changePicturePageDescription"></span>
- <grid id="images-grid"></grid>
+ <grid id="images-grid" class="image-picker"></grid>
</div>
<div class="action-area">
<div class="button-strip">
diff --git a/chrome/browser/resources/options2/chromeos/change_picture_options.css b/chrome/browser/resources/options2/chromeos/image_picker.css
index c3e1cf8..4cb5af1 100644
--- a/chrome/browser/resources/options2/chromeos/change_picture_options.css
+++ b/chrome/browser/resources/options2/chromeos/image_picker.css
@@ -2,7 +2,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file. */
-#images-grid {
+.image-picker {
-webkit-user-drag: none;
-webkit-user-select: none;
margin: 10px;
@@ -11,19 +11,19 @@
width: 600px;
}
-#images-grid * {
+.image-picker * {
margin: 0;
padding: 0;
}
-#images-grid img {
+.image-picker img {
background-color: white;
height: 64px;
vertical-align: middle;
width: 64px;
}
-#images-grid [role=listitem] {
+.image-picker [role=listitem] {
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 4px;
display: inline-block;
@@ -31,7 +31,7 @@
padding: 3px;
}
-#images-grid [selected] {
+.image-picker [selected] {
border: 2px solid rgb(0, 102, 204);
padding: 2px;
}
diff --git a/chrome/browser/resources/options2/chromeos/set_wallpaper_options.css b/chrome/browser/resources/options2/chromeos/set_wallpaper_options.css
new file mode 100644
index 0000000..2b8585f
--- /dev/null
+++ b/chrome/browser/resources/options2/chromeos/set_wallpaper_options.css
@@ -0,0 +1,12 @@
+/* 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. */
+
+#wallpaper-grid {
+ width: 470px;
+}
+
+#wallpaper-grid img {
+ height: 80px;
+ width: 128px;
+}
diff --git a/chrome/browser/resources/options2/chromeos/set_wallpaper_options.html b/chrome/browser/resources/options2/chromeos/set_wallpaper_options.html
new file mode 100644
index 0000000..2aec5d8
--- /dev/null
+++ b/chrome/browser/resources/options2/chromeos/set_wallpaper_options.html
@@ -0,0 +1,12 @@
+<div id="set-wallpaper-page" class="page" hidden>
+ <h1 i18n-content="setWallpaperPage"></h1>
+ <div class="content-area">
+ <span i18n-content="setWallpaperPageDescription"></span>
+ <grid id="wallpaper-grid" class="image-picker"></grid>
+ </div>
+ <div class="action-area">
+ <div class="button-strip">
+ <button id="set-wallpaper-overlay-confirm" i18n-content="ok"></button>
+ </div>
+ </div>
+</div>
diff --git a/chrome/browser/resources/options2/chromeos/set_wallpaper_options.js b/chrome/browser/resources/options2/chromeos/set_wallpaper_options.js
new file mode 100644
index 0000000..9ef61ea
--- /dev/null
+++ b/chrome/browser/resources/options2/chromeos/set_wallpaper_options.js
@@ -0,0 +1,137 @@
+// 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.
+
+cr.define('options', function() {
+
+ var OptionsPage = options.OptionsPage;
+ var UserImagesGrid = options.UserImagesGrid;
+
+ /////////////////////////////////////////////////////////////////////////////
+ // SetWallpaperOptions class:
+
+ /**
+ * Encapsulated handling of ChromeOS set wallpaper options page.
+ * @constructor
+ */
+ function SetWallpaperOptions() {
+ OptionsPage.call(
+ this,
+ 'setWallpaper',
+ localStrings.getString('setWallpaper'),
+ 'set-wallpaper-page');
+ }
+
+ cr.addSingletonGetter(SetWallpaperOptions);
+
+ SetWallpaperOptions.prototype = {
+ // Inherit SetWallpaperOptions from OptionsPage.
+ __proto__: options.OptionsPage.prototype,
+
+ /**
+ * Initializes SetWallpaperOptions page.
+ */
+ initializePage: function() {
+ // Call base class implementation to start preferences initialization.
+ OptionsPage.prototype.initializePage.call(this);
+
+ var wallpaperGrid = $('wallpaper-grid');
+ UserImagesGrid.decorate(wallpaperGrid);
+
+ wallpaperGrid.addEventListener('change',
+ this.handleImageSelected_.bind(this));
+ wallpaperGrid.addEventListener('dblclick',
+ this.handleImageDblClick_.bind(this));
+ wallpaperGrid.addEventListener('activate',
+ function() { OptionsPage.closeOverlay() });
+
+ $('set-wallpaper-overlay-confirm').onclick = function() {
+ OptionsPage.closeOverlay();
+ };
+
+ chrome.send('onSetWallpaperPageInitialized');
+ },
+
+ /**
+ * Called right after the page has been shown to user.
+ */
+ didShowPage: function() {
+ $('wallpaper-grid').updateAndFocus();
+ chrome.send('onSetWallpaperPageShown');
+ },
+
+ /**
+ * Called right before the page is hidden.
+ */
+ willHidePage: function() {
+ var wallpaperGrid = $('wallpaper-grid');
+ wallpaperGrid.blur();
+ },
+
+ /**
+ * Handles image selection change.
+ * @private
+ */
+ handleImageSelected_: function() {
+ var wallpaperGrid = $('wallpaper-grid');
+ var index = wallpaperGrid.selectionModel.selectedIndex;
+ // Ignore deselection, selection change caused by program itself and
+ // selection of one of the action buttons.
+ if (index != -1 &&
+ !wallpaperGrid.inProgramSelection) {
+ chrome.send('selectWallpaper', [index.toString()]);
+ }
+ },
+
+ /**
+ * Handles double click on the image grid.
+ * @param {Event} e Double click Event.
+ */
+ handleImageDblClick_: function(e) {
+ // Close page unless the click target is the grid itself.
+ if (e.target instanceof HTMLImageElement)
+ OptionsPage.closeOverlay();
+ },
+
+ /**
+ * Selects user image with the given index.
+ * @param {int} index index of the image to select.
+ * @private
+ */
+ setSelectedImage_: function(index) {
+ var wallpaperGrid = $('wallpaper-grid');
+ wallpaperGrid.selectionModel.selectedIndex = index;
+ wallpaperGrid.selectionModel.leadIndex = index;
+ },
+
+ /**
+ * Appends default images to the image grid. Should only be called once.
+ * @param {Array.<string>} images An array of URLs to default images.
+ * @private
+ */
+ setDefaultImages_: function(images) {
+ var wallpaperGrid = $('wallpaper-grid');
+ for (var i = 0, url; url = images[i]; i++)
+ wallpaperGrid.addItem(url);
+ },
+
+ };
+
+ // Forward public APIs to private implementations.
+ [
+ 'setDefaultImages',
+ 'setSelectedImage'
+ ].forEach(function(name) {
+ SetWallpaperOptions[name] = function() {
+ var instance = SetWallpaperOptions.getInstance();
+ return instance[name + '_'].apply(instance, arguments);
+ };
+ });
+
+ // Export
+ return {
+ SetWallpaperOptions: SetWallpaperOptions
+ };
+
+});
+
diff --git a/chrome/browser/resources/options2/options.html b/chrome/browser/resources/options2/options.html
index 8e879e5..e448114 100644
--- a/chrome/browser/resources/options2/options.html
+++ b/chrome/browser/resources/options2/options.html
@@ -38,11 +38,14 @@
<if expr="pp_ifdef('chromeos')">
<link rel="stylesheet" href="chromeos/accounts_options_page.css">
<link rel="stylesheet" href="chromeos/bluetooth.css">
- <link rel="stylesheet" href="chromeos/change_picture_options.css">
+ <link rel="stylesheet" href="chromeos/image_picker.css">
<link rel="stylesheet" href="chromeos/internet_detail.css">
<link rel="stylesheet" href="chromeos/internet_options_page.css">
<link rel="stylesheet" href="chromeos/pointer_overlay.css">
</if>
+<if expr="pp_ifdef('chromeos') and pp_ifdef('use_ash')">
+ <link rel="stylesheet" href="chromeos/set_wallpaper_options.css">
+</if>
<if expr="pp_ifdef('chromeos') and pp_ifdef('use_virtual_keyboard')">
<link rel="stylesheet" href="chromeos/virtual_keyboard.css">
</if>
@@ -100,6 +103,9 @@
<include src="chromeos/keyboard_overlay.html">
<include src="chromeos/pointer_overlay.html">
</if>
+ <if expr="pp_ifdef('chromeos') and pp_ifdef('use_ash')">
+ <include src="chromeos/set_wallpaper_options.html">
+ </if>
<if expr="not is_win and not is_macosx">
<include src="certificate_manager.html">
</if>
diff --git a/chrome/browser/resources/options2/options.js b/chrome/browser/resources/options2/options.js
index 5dc7ff4..2447d32 100644
--- a/chrome/browser/resources/options2/options.js
+++ b/chrome/browser/resources/options2/options.js
@@ -164,6 +164,15 @@ function load() {
LanguageOptions.getInstance());
}
}
+
+<if expr="pp_ifdef('chromeos') and pp_ifdef('use_ash')">
+ if (SetWallpaperOptions) {
+ OptionsPage.registerOverlay(SetWallpaperOptions.getInstance(),
+ BrowserOptions.getInstance(),
+ [$('set-wallpaper')]);
+ }
+</if>
+
if (!cr.isWindows && !cr.isMac) {
OptionsPage.registerOverlay(CertificateBackupOverlay.getInstance(),
CertificateManager.getInstance());
diff --git a/chrome/browser/resources/options2/options_bundle.js b/chrome/browser/resources/options2/options_bundle.js
index 01f975b..16d75cd 100644
--- a/chrome/browser/resources/options2/options_bundle.js
+++ b/chrome/browser/resources/options2/options_bundle.js
@@ -42,6 +42,10 @@
var KeyboardOverlay = options.KeyboardOverlay;
var PointerOverlay = options.PointerOverlay;
</if>
+<if expr="pp_ifdef('chromeos') and pp_ifdef('use_ash')">
+ <include src="chromeos/set_wallpaper_options.js"></include>
+ var SetWallpaperOptions = options.SetWallpaperOptions;
+</if>
<if expr="not is_win and not is_macosx">
<include src="certificate_tree.js"></include>
<include src="certificate_manager.js"></include>
diff --git a/chrome/browser/ui/webui/options2/browser_options_handler2.cc b/chrome/browser/ui/webui/options2/browser_options_handler2.cc
index 2992af1..52583ba 100644
--- a/chrome/browser/ui/webui/options2/browser_options_handler2.cc
+++ b/chrome/browser/ui/webui/options2/browser_options_handler2.cc
@@ -299,6 +299,9 @@ void BrowserOptionsHandler::GetLocalizedValues(
IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_ENABLING_BUTTON },
{ "proxiesConfigureButton", IDS_OPTIONS_PROXIES_CONFIGURE_BUTTON },
#endif
+#if defined(OS_CHROMEOS) && defined(USE_ASH)
+ { "setWallpaper", IDS_SET_WALLPAPER_BUTTON },
+#endif
#if !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
{ "advancedSectionTitleBackground",
IDS_OPTIONS_ADVANCED_SECTION_TITLE_BACKGROUND },
diff --git a/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc b/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc
new file mode 100644
index 0000000..6a2a14d
--- /dev/null
+++ b/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc
@@ -0,0 +1,116 @@
+// 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 "chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.h"
+
+#include "ash/desktop_background/desktop_background_resources.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/metrics/histogram.h"
+#include "base/path_service.h"
+#include "base/string_number_conversions.h"
+#include "base/string_util.h"
+#include "base/values.h"
+#include "chrome/browser/chromeos/login/user_manager.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/views/window.h"
+#include "chrome/browser/ui/webui/web_ui_util.h"
+#include "chrome/common/chrome_notification_types.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/browser/web_ui.h"
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/views/widget/widget.h"
+
+namespace chromeos {
+namespace options2 {
+
+SetWallpaperOptionsHandler::SetWallpaperOptionsHandler()
+ : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
+}
+
+SetWallpaperOptionsHandler::~SetWallpaperOptionsHandler() {
+}
+
+void SetWallpaperOptionsHandler::GetLocalizedValues(
+ DictionaryValue* localized_strings) {
+ DCHECK(localized_strings);
+ localized_strings->SetString("setWallpaperPage",
+ l10n_util::GetStringUTF16(IDS_OPTIONS_SET_WALLPAPER_DIALOG_TITLE));
+ localized_strings->SetString("setWallpaperPageDescription",
+ l10n_util::GetStringUTF16(IDS_OPTIONS_SET_WALLPAPER_DIALOG_TEXT));
+}
+
+void SetWallpaperOptionsHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback("onSetWallpaperPageInitialized",
+ base::Bind(&SetWallpaperOptionsHandler::HandlePageInitialized,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback("onSetWallpaperPageShown",
+ base::Bind(&SetWallpaperOptionsHandler::HandlePageShown,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback("selectWallpaper",
+ base::Bind(&SetWallpaperOptionsHandler::HandleSelectImage,
+ base::Unretained(this)));
+}
+
+void SetWallpaperOptionsHandler::SendDefaultImages() {
+ ListValue image_urls;
+
+ for (int i = 0; i < ash::GetWallpaperCount(); ++i) {
+ image_urls.Append(Value::CreateStringValue(
+ web_ui_util::GetImageDataUrl(ash::GetWallpaperThumbnail(i))));
+ }
+
+ web_ui()->CallJavascriptFunction("SetWallpaperOptions.setDefaultImages",
+ image_urls);
+}
+
+void SetWallpaperOptionsHandler::HandlePageInitialized(
+ const base::ListValue* args) {
+ DCHECK(args && args->empty());
+
+ SendDefaultImages();
+}
+
+void SetWallpaperOptionsHandler::HandlePageShown(const base::ListValue* args) {
+ DCHECK(args && args->empty());
+ chromeos::UserManager* user_manager = chromeos::UserManager::Get();
+ const chromeos::User& user = user_manager->GetLoggedInUser();
+ DCHECK(!user.email().empty());
+ int index = user_manager->GetUserWallpaper(user.email());
+ DCHECK(index >=0 && index < ash::GetWallpaperCount());
+ base::FundamentalValue index_value(index);
+ web_ui()->CallJavascriptFunction("SetWallpaperOptions.setSelectedImage",
+ index_value);
+}
+
+void SetWallpaperOptionsHandler::HandleSelectImage(const ListValue* args) {
+ std::string image_index_string;
+ int image_index;
+ if (!args ||
+ args->GetSize() != 1 ||
+ !args->GetString(0, &image_index_string) ||
+ !base::StringToInt(image_index_string, &image_index) ||
+ image_index < 0 || image_index >= ash::GetWallpaperCount())
+ NOTREACHED();
+
+ UserManager* user_manager = UserManager::Get();
+ const User& user = user_manager->GetLoggedInUser();
+ DCHECK(!user.email().empty());
+ user_manager->SaveWallpaperDefaultIndex(user.email(), image_index);
+}
+
+gfx::NativeWindow SetWallpaperOptionsHandler::GetBrowserWindow() const {
+ Browser* browser =
+ BrowserList::FindBrowserWithProfile(Profile::FromWebUI(web_ui()));
+ if (!browser)
+ return NULL;
+ return browser->window()->GetNativeHandle();
+}
+
+} // namespace options2
+} // namespace chromeos
diff --git a/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.h b/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.h
new file mode 100644
index 0000000..61ed6611
--- /dev/null
+++ b/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.h
@@ -0,0 +1,57 @@
+// 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 CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_SET_WALLPAPER_OPTIONS_HANDLER2_H_
+#define CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_SET_WALLPAPER_OPTIONS_HANDLER2_H_
+
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/ui/webui/options2/options_ui2.h"
+#include "ui/gfx/native_widget_types.h"
+
+namespace base {
+class DictionaryValue;
+class ListValue;
+}
+
+namespace chromeos {
+namespace options2 {
+
+// ChromeOS user image options page UI handler.
+class SetWallpaperOptionsHandler : public OptionsPageUIHandler{
+ public:
+ SetWallpaperOptionsHandler();
+ virtual ~SetWallpaperOptionsHandler();
+
+ // OptionsPageUIHandler implementation.
+ virtual void GetLocalizedValues(
+ base::DictionaryValue* localized_strings) OVERRIDE;
+
+ // WebUIMessageHandler implementation.
+ virtual void RegisterMessages() OVERRIDE;
+
+ private:
+ // Sends list of available default images to the page.
+ void SendDefaultImages();
+
+ // Handles page initialized event.
+ void HandlePageInitialized(const base::ListValue* args);
+
+ // Handles page shown event.
+ void HandlePageShown(const base::ListValue* args);
+
+ // Selects one of the available images.
+ void HandleSelectImage(const base::ListValue* args);
+
+ // Returns handle to browser window or NULL if it can't be found.
+ gfx::NativeWindow GetBrowserWindow() const;
+
+ base::WeakPtrFactory<SetWallpaperOptionsHandler> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(SetWallpaperOptionsHandler);
+};
+
+} // namespace options2
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_SET_WALLPAPER_OPTIONS_HANDLER2_H_
diff --git a/chrome/browser/ui/webui/options2/options_ui2.cc b/chrome/browser/ui/webui/options2/options_ui2.cc
index e17a800..1d32812 100644
--- a/chrome/browser/ui/webui/options2/options_ui2.cc
+++ b/chrome/browser/ui/webui/options2/options_ui2.cc
@@ -77,6 +77,10 @@
#include "chrome/browser/ui/webui/options2/chromeos/virtual_keyboard_manager_handler2.h"
#endif
+#if defined(OS_CHROMEOS) && defined(USE_ASH)
+#include "chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.h"
+#endif
+
#if defined(USE_NSS)
#include "chrome/browser/ui/webui/options2/certificate_manager_handler2.h"
#endif
@@ -226,6 +230,11 @@ OptionsUI::OptionsUI(content::WebUI* web_ui)
AddOptionsPageUIHandler(localized_strings,
new chromeos::options2::StatsOptionsHandler());
#endif
+#if defined(OS_CHROMEOS) && defined(USE_ASH)
+ AddOptionsPageUIHandler(
+ localized_strings,
+ new chromeos::options2::SetWallpaperOptionsHandler());
+#endif
#if defined(USE_NSS)
AddOptionsPageUIHandler(localized_strings, new CertificateManagerHandler());
#endif
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 1c0de07..e3fca76 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -407,6 +407,8 @@
'browser/chromeos/audio/audio_mixer.h',
'browser/chromeos/audio/audio_mixer_alsa.cc',
'browser/chromeos/audio/audio_mixer_alsa.h',
+ 'browser/chromeos/background/desktop_background_observer.cc',
+ 'browser/chromeos/background/desktop_background_observer.h',
'browser/chromeos/bluetooth/bluetooth_adapter.cc',
'browser/chromeos/bluetooth/bluetooth_adapter.h',
'browser/chromeos/bluetooth/bluetooth_device.cc',
@@ -3872,6 +3874,8 @@
'browser/ui/webui/options2/chromeos/pointer_handler2.h',
'browser/ui/webui/options2/chromeos/proxy_handler2.cc',
'browser/ui/webui/options2/chromeos/proxy_handler2.h',
+ 'browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc',
+ 'browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.h',
'browser/ui/webui/options2/chromeos/stats_options_handler2.cc',
'browser/ui/webui/options2/chromeos/stats_options_handler2.h',
'browser/ui/webui/options2/chromeos/system_settings_provider2.cc',
diff --git a/ui/resources/ui_resources.grd b/ui/resources/ui_resources.grd
index e3f3ea0..8751f6c 100644
--- a/ui/resources/ui_resources.grd
+++ b/ui/resources/ui_resources.grd
@@ -175,24 +175,25 @@
<include name="IDR_AURA_SHADOW_SMALL_BOTTOM" file="aura/small_shadow_bottom.png" type="BINDATA" />
<include name="IDR_AURA_SHADOW_SMALL_BOTTOM_RIGHT" file="aura/small_shadow_bottom_right.png" type="BINDATA" />
<include name="IDR_AURA_STATUS_MOCK" file="aura/statusbar.png" type="BINDATA" />
- <include name="IDR_AURA_WALLPAPER_1" file="aura/wallpaper_1.jpg" type="BINDATA" />
- <include name="IDR_AURA_WALLPAPER_1_THUMB" file="aura/wallpaper_1_thumb.jpg" type="BINDATA" />
- <include name="IDR_AURA_WALLPAPER_2" file="aura/wallpaper_2.jpg" type="BINDATA" />
- <include name="IDR_AURA_WALLPAPER_2_THUMB" file="aura/wallpaper_2_thumb.jpg" type="BINDATA" />
- <include name="IDR_AURA_WALLPAPER_3" file="aura/wallpaper_3.jpg" type="BINDATA" />
- <include name="IDR_AURA_WALLPAPER_3_THUMB" file="aura/wallpaper_3_thumb.jpg" type="BINDATA" />
- <include name="IDR_AURA_WALLPAPER_4" file="aura/wallpaper_4.jpg" type="BINDATA" />
- <include name="IDR_AURA_WALLPAPER_4_THUMB" file="aura/wallpaper_4_thumb.jpg" type="BINDATA" />
- <include name="IDR_AURA_WALLPAPER_5" file="aura/wallpaper_5.jpg" type="BINDATA" />
- <include name="IDR_AURA_WALLPAPER_5_THUMB" file="aura/wallpaper_5_thumb.jpg" type="BINDATA" />
- <include name="IDR_AURA_WALLPAPER_6" file="aura/wallpaper_6.jpg" type="BINDATA" />
- <include name="IDR_AURA_WALLPAPER_6_THUMB" file="aura/wallpaper_6_thumb.jpg" type="BINDATA" />
- <include name="IDR_AURA_WALLPAPER_7" file="aura/wallpaper_7.jpg" type="BINDATA" />
- <include name="IDR_AURA_WALLPAPER_7_THUMB" file="aura/wallpaper_7_thumb.jpg" type="BINDATA" />
- <include name="IDR_AURA_WALLPAPER_8" file="aura/wallpaper_8.jpg" type="BINDATA" />
- <include name="IDR_AURA_WALLPAPER_8_THUMB" file="aura/wallpaper_8_thumb.jpg" type="BINDATA" />
- <include name="IDR_AURA_WALLPAPER_9" file="aura/wallpaper_9.jpg" type="BINDATA" />
- <include name="IDR_AURA_WALLPAPER_9_THUMB" file="aura/wallpaper_9_thumb.jpg" type="BINDATA" />
+ <!-- TODO(bshe): Change the file names to follow the IDR naming rules. -->
+ <include name="IDR_AURA_WALLPAPER" file="aura/wallpaper_1.jpg" type="BINDATA" />
+ <include name="IDR_AURA_WALLPAPER_THUMB" file="aura/wallpaper_1_thumb.jpg" type="BINDATA" />
+ <include name="IDR_AURA_WALLPAPER_1" file="aura/wallpaper_2.jpg" type="BINDATA" />
+ <include name="IDR_AURA_WALLPAPER_1_THUMB" file="aura/wallpaper_2_thumb.jpg" type="BINDATA" />
+ <include name="IDR_AURA_WALLPAPER_2" file="aura/wallpaper_3.jpg" type="BINDATA" />
+ <include name="IDR_AURA_WALLPAPER_2_THUMB" file="aura/wallpaper_3_thumb.jpg" type="BINDATA" />
+ <include name="IDR_AURA_WALLPAPER_3" file="aura/wallpaper_4.jpg" type="BINDATA" />
+ <include name="IDR_AURA_WALLPAPER_3_THUMB" file="aura/wallpaper_4_thumb.jpg" type="BINDATA" />
+ <include name="IDR_AURA_WALLPAPER_4" file="aura/wallpaper_5.jpg" type="BINDATA" />
+ <include name="IDR_AURA_WALLPAPER_4_THUMB" file="aura/wallpaper_5_thumb.jpg" type="BINDATA" />
+ <include name="IDR_AURA_WALLPAPER_5" file="aura/wallpaper_6.jpg" type="BINDATA" />
+ <include name="IDR_AURA_WALLPAPER_5_THUMB" file="aura/wallpaper_6_thumb.jpg" type="BINDATA" />
+ <include name="IDR_AURA_WALLPAPER_6" file="aura/wallpaper_7.jpg" type="BINDATA" />
+ <include name="IDR_AURA_WALLPAPER_6_THUMB" file="aura/wallpaper_7_thumb.jpg" type="BINDATA" />
+ <include name="IDR_AURA_WALLPAPER_7" file="aura/wallpaper_8.jpg" type="BINDATA" />
+ <include name="IDR_AURA_WALLPAPER_7_THUMB" file="aura/wallpaper_8_thumb.jpg" type="BINDATA" />
+ <include name="IDR_AURA_WALLPAPER_8" file="aura/wallpaper_9.jpg" type="BINDATA" />
+ <include name="IDR_AURA_WALLPAPER_8_THUMB" file="aura/wallpaper_9_thumb.jpg" type="BINDATA" />
<include name="IDR_AURA_WINDOW_BUTTON_SEPARATOR" file="aura/window_button_separator.png" type="BINDATA" />
<include name="IDR_AURA_WINDOW_CLOSE_ICON" file="aura/slab_close.png" type="BINDATA" />
<include name="IDR_AURA_WINDOW_CLOSE" file="aura/window_close_normal.png" type="BINDATA" />