summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorantrim@chromium.org <antrim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-25 18:22:17 +0000
committerantrim@chromium.org <antrim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-25 18:22:17 +0000
commit1df8df8f6b7c8b28fd564644362b8a45fd625cb0 (patch)
treef9c860ff322ab3388fe207aa58d2c9671d717668 /chrome
parenta0fe29fd4cc9ffe12fc04e05bb0c8ab4b2d39004 (diff)
downloadchromium_src-1df8df8f6b7c8b28fd564644362b8a45fd625cb0.zip
chromium_src-1df8df8f6b7c8b28fd564644362b8a45fd625cb0.tar.gz
chromium_src-1df8df8f6b7c8b28fd564644362b8a45fd625cb0.tar.bz2
Wallpaper on lock screen
BUG=124339 TEST=Lock the screen with user that have some background, check that lock page has background. Note that --enable-new-oobe flag is required. Review URL: https://chromiumcodereview.appspot.com/10534059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143958 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/resources/chromeos/login/display_manager.js9
-rw-r--r--chrome/browser/resources/chromeos/login/oobe.css4
-rw-r--r--chrome/browser/resources/chromeos/login/screen_account_picker.js9
-rw-r--r--chrome/browser/resources/options2/chromeos/set_wallpaper_options.js3
-rw-r--r--chrome/browser/ui/webui/DEPS3
-rw-r--r--chrome/browser/ui/webui/chromeos/login/oobe_ui.cc8
-rw-r--r--chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc2
-rw-r--r--chrome/browser/ui/webui/options2/chromeos/wallpaper_source2.cc169
-rw-r--r--chrome/browser/ui/webui/options2/chromeos/wallpaper_source2.h62
-rw-r--r--chrome/browser/ui/webui/options2/options_ui2.cc2
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/common/url_constants.cc6
-rw-r--r--chrome/common/url_constants.h2
13 files changed, 275 insertions, 6 deletions
diff --git a/chrome/browser/resources/chromeos/login/display_manager.js b/chrome/browser/resources/chromeos/login/display_manager.js
index aeeb2a2..8c0800d 100644
--- a/chrome/browser/resources/chromeos/login/display_manager.js
+++ b/chrome/browser/resources/chromeos/login/display_manager.js
@@ -315,7 +315,14 @@ cr.define('cr.ui.login', function() {
*/
isNewOobe: function() {
return document.documentElement.getAttribute('oobe') == 'new';
- }
+ },
+
+ /**
+ * Returns true if the current screen is the lock screen.
+ */
+ isLockScreen: function() {
+ return document.documentElement.getAttribute('screen') == 'lock';
+ },
};
/**
diff --git a/chrome/browser/resources/chromeos/login/oobe.css b/chrome/browser/resources/chromeos/login/oobe.css
index a053ba0..8066285 100644
--- a/chrome/browser/resources/chromeos/login/oobe.css
+++ b/chrome/browser/resources/chromeos/login/oobe.css
@@ -27,6 +27,10 @@ html[oobe=new]:not([screen=lock]) body {
background-color: transparent;
}
+html[oobe=new][screen=lock] body {
+ -webkit-background-size: 100% 100%;
+}
+
progress {
border: solid 1px #bbb;
padding: 1px;
diff --git a/chrome/browser/resources/chromeos/login/screen_account_picker.js b/chrome/browser/resources/chromeos/login/screen_account_picker.js
index f6113dd..bd86fa5 100644
--- a/chrome/browser/resources/chromeos/login/screen_account_picker.js
+++ b/chrome/browser/resources/chromeos/login/screen_account_picker.js
@@ -185,6 +185,15 @@ cr.define('login', function() {
$('pod-row').classList[enabled ? 'add' : 'remove']('capslock-on');
};
+ /**
+ * Sets wallpaper for lock screen.
+ */
+ AccountPickerScreen.setWallpaper = function() {
+ var oobe = Oobe.getInstance();
+ if (oobe.isNewOobe() && oobe.isLockScreen())
+ document.body.background = 'chrome://wallpaper/';
+ }
+
return {
AccountPickerScreen: AccountPickerScreen
};
diff --git a/chrome/browser/resources/options2/chromeos/set_wallpaper_options.js b/chrome/browser/resources/options2/chromeos/set_wallpaper_options.js
index 84a68bf..8e9791b 100644
--- a/chrome/browser/resources/options2/chromeos/set_wallpaper_options.js
+++ b/chrome/browser/resources/options2/chromeos/set_wallpaper_options.js
@@ -7,7 +7,8 @@ cr.define('options', function() {
var OptionsPage = options.OptionsPage;
var UserImagesGrid = options.UserImagesGrid;
- /** @const */ var CUSTOM_WALLPAPER_PREFIX = 'chrome://wallpaper/custom_';
+ /** @const */ var CUSTOM_WALLPAPER_PREFIX =
+ 'chrome://wallpaper-thumb/custom_';
/////////////////////////////////////////////////////////////////////////////
// SetWallpaperOptions class:
diff --git a/chrome/browser/ui/webui/DEPS b/chrome/browser/ui/webui/DEPS
index 7471d83..189f541 100644
--- a/chrome/browser/ui/webui/DEPS
+++ b/chrome/browser/ui/webui/DEPS
@@ -6,5 +6,6 @@ include_rules = [
"+sync/internal_api/public/util/weak_handle.h",
# Other libraries.
- "+third_party/angle", # For ANGLE version.
+ "+third_party/angle", # For ANGLE version.
+ "+third_party/zlib/zlib.h", # For compression level constants.
]
diff --git a/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc b/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc
index a6a1fa7..6798297 100644
--- a/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc
+++ b/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc
@@ -30,6 +30,7 @@
#include "chrome/browser/ui/webui/chromeos/login/update_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h"
#include "chrome/browser/ui/webui/options2/chromeos/user_image_source2.h"
+#include "chrome/browser/ui/webui/options2/chromeos/wallpaper_source2.h"
#include "chrome/browser/ui/webui/theme_source.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/jstemplate_builder.h"
@@ -178,6 +179,13 @@ OobeUI::OobeUI(content::WebUI* web_ui)
options2::UserImageSource* user_image_source =
new options2::UserImageSource();
ChromeURLDataManager::AddDataSource(profile, user_image_source);
+
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableNewOobe)) {
+ // Set up the chrome://wallpaper/ source.
+ chromeos::options2::WallpaperImageSource* wallpaper_image_source =
+ new chromeos::options2::WallpaperImageSource();
+ ChromeURLDataManager::AddDataSource(profile, wallpaper_image_source);
+ }
}
OobeUI::~OobeUI() {
diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
index 59b6205..6964657 100644
--- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
@@ -1032,6 +1032,8 @@ void SigninScreenHandler::HandleLoginVisible(const base::ListValue* args) {
chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE,
content::NotificationService::AllSources(),
content::NotificationService::NoDetails());
+ if (ScreenLocker::default_screen_locker())
+ web_ui()->CallJavascriptFunction("login.AccountPickerScreen.setWallpaper");
}
void SigninScreenHandler::StartClearingDnsCache() {
diff --git a/chrome/browser/ui/webui/options2/chromeos/wallpaper_source2.cc b/chrome/browser/ui/webui/options2/chromeos/wallpaper_source2.cc
new file mode 100644
index 0000000..7bf14d9
--- /dev/null
+++ b/chrome/browser/ui/webui/options2/chromeos/wallpaper_source2.cc
@@ -0,0 +1,169 @@
+// 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/wallpaper_source2.h"
+
+#include "ash/desktop_background/desktop_background_controller.h"
+#include "ash/shell.h"
+#include "base/synchronization/cancellation_flag.h"
+#include "base/threading/worker_pool.h"
+#include "chrome/browser/chromeos/login/user_manager.h"
+#include "chrome/common/url_constants.h"
+#include "content/public/browser/browser_thread.h"
+#include "grit/ui_resources.h"
+#include "net/base/mime_util.h"
+#include "ui/gfx/codec/png_codec.h"
+#include "ui/gfx/size.h"
+#include "ui/gfx/skia_util.h"
+
+extern "C" {
+#if defined(USE_SYSTEM_ZLIB)
+#include <zlib.h>
+#else
+#include "third_party/zlib/zlib.h"
+#endif
+}
+
+namespace chromeos {
+namespace options2 {
+
+// Operation class that encodes existing in-memory image as PNG.
+// It uses NO-COMPRESSION to save time.
+class WallpaperImageSource::WallpaperEncodingOperation
+ : public base::RefCountedThreadSafe<
+ WallpaperImageSource::WallpaperEncodingOperation> {
+ public:
+ WallpaperEncodingOperation(
+ int request_id,
+ scoped_refptr<base::RefCountedBytes> data,
+ SkBitmap image)
+ : request_id_(request_id),
+ data_(data),
+ image_(image) {
+ }
+
+ static void Run(scoped_refptr<WallpaperEncodingOperation> weo) {
+ weo->EncodeWallpaper();
+ }
+
+ int request_id() {
+ return request_id_;
+ }
+
+ void EncodeWallpaper() {
+ if (cancel_flag_.IsSet())
+ return;
+ SkAutoLockPixels lock_input(image_);
+ // Avoid compression to make things faster.
+ gfx::PNGCodec::EncodeWithCompressionLevel(
+ reinterpret_cast<unsigned char*>(image_.getAddr32(0, 0)),
+ gfx::PNGCodec::FORMAT_SkBitmap,
+ gfx::Size(image_.width(), image_.height()),
+ image_.width() * image_.bytesPerPixel(),
+ false,
+ std::vector<gfx::PNGCodec::Comment>(),
+ Z_NO_COMPRESSION,
+ &data_->data());
+ if (cancel_flag_.IsSet())
+ return;
+ }
+
+ void Cancel() {
+ cancel_flag_.Set();
+ }
+
+ private:
+ friend class base::RefCountedThreadSafe<
+ WallpaperImageSource::WallpaperEncodingOperation>;
+
+ base::CancellationFlag cancel_flag_;
+
+ // ID of original request.
+ int request_id_;
+ // Buffer to store encoded image.
+ scoped_refptr<base::RefCountedBytes> data_;
+ // Original image to encode.
+ SkBitmap image_;
+
+ DISALLOW_COPY_AND_ASSIGN(WallpaperEncodingOperation);
+};
+
+WallpaperImageSource::WallpaperImageSource()
+ : DataSource(chrome::kChromeUIWallpaperImageHost, NULL),
+ weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+}
+
+WallpaperImageSource::~WallpaperImageSource() {
+}
+
+void WallpaperImageSource::StartDataRequest(const std::string& email,
+ bool is_incognito,
+ int request_id) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+ CancelPendingEncodingOperation();
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&WallpaperImageSource::GetCurrentUserWallpaper, this,
+ request_id));
+}
+
+std::string WallpaperImageSource::GetMimeType(const std::string&) const {
+ return "images/png";
+}
+
+// Get current background image and store it to |data|.
+void WallpaperImageSource::GetCurrentUserWallpaper(int request_id) {
+ SkBitmap image;
+ if (chromeos::UserManager::Get()->IsUserLoggedIn()) {
+ SkBitmap wallpaper = ash::Shell::GetInstance()->
+ desktop_background_controller()->
+ GetCurrentWallpaperImage();
+ SkBitmap copy;
+ if (wallpaper.deepCopyTo(&copy, wallpaper.config()))
+ image = copy;
+ }
+ content::BrowserThread::PostTask(
+ content::BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&WallpaperImageSource::ImageAcquired, this, image, request_id));
+}
+
+
+void WallpaperImageSource::ImageAcquired(SkBitmap image,
+ int request_id) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+ CancelPendingEncodingOperation();
+ scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes();
+ wallpaper_encoding_op_ = new WallpaperEncodingOperation(request_id,
+ data,
+ image);
+ base::WorkerPool::PostTaskAndReply(
+ FROM_HERE,
+ base::Bind(&WallpaperEncodingOperation::Run, wallpaper_encoding_op_),
+ base::Bind(&WallpaperImageSource::SendCurrentUserWallpaper,
+ weak_ptr_factory_.GetWeakPtr(), request_id, data),
+ true /* task_is_slow */);
+};
+
+void WallpaperImageSource::CancelPendingEncodingOperation() {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+ // Set canceled flag of previous request to skip unneeded encoding.
+ if (wallpaper_encoding_op_.get()) {
+ wallpaper_encoding_op_->Cancel();
+ SendResponse(wallpaper_encoding_op_->request_id(), NULL);
+ }
+
+ // Cancel reply callback for previous request.
+ weak_ptr_factory_.InvalidateWeakPtrs();
+}
+
+void WallpaperImageSource::SendCurrentUserWallpaper(int request_id,
+ scoped_refptr<base::RefCountedBytes> data) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+ SendResponse(request_id, data);
+}
+
+} // namespace options2
+} // namespace chromeos
diff --git a/chrome/browser/ui/webui/options2/chromeos/wallpaper_source2.h b/chrome/browser/ui/webui/options2/chromeos/wallpaper_source2.h
new file mode 100644
index 0000000..f819bcf
--- /dev/null
+++ b/chrome/browser/ui/webui/options2/chromeos/wallpaper_source2.h
@@ -0,0 +1,62 @@
+// 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_WALLPAPER_SOURCE2_H_
+#define CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_WALLPAPER_SOURCE2_H_
+#pragma once
+
+#include <string>
+
+#include "base/compiler_specific.h"
+#include "base/memory/ref_counted_memory.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+
+namespace chromeos {
+namespace options2 {
+
+// A DataSource for chrome://wallpaper/ URL, provides current user's wallpaper.
+class WallpaperImageSource : public ChromeURLDataManager::DataSource {
+ public:
+ WallpaperImageSource();
+
+ // ChromeURLDataManager::DataSource implementation.
+ virtual void StartDataRequest(const std::string& path,
+ bool is_incognito,
+ int request_id) OVERRIDE;
+ virtual std::string GetMimeType(const std::string&) const OVERRIDE;
+
+ private:
+ class WallpaperEncodingOperation;
+
+ virtual ~WallpaperImageSource();
+
+ // Get wallpaper for request identified by |request_id| in UI thread
+ // and pass it to encoding phase.
+ void GetCurrentUserWallpaper(int request_id);
+
+ // Callback is called when image is obtained from UI thread to
+ // encode and send reply to request identified by |request_id|.
+ void ImageAcquired(SkBitmap image, int request_id);
+
+ // Cancel current image encoding operation.
+ void CancelPendingEncodingOperation();
+
+ // Send image stored in |data| as a reply to request
+ // identifed by |request_id|.
+ void SendCurrentUserWallpaper(int request_id,
+ scoped_refptr<base::RefCountedBytes> data);
+
+ scoped_refptr<WallpaperEncodingOperation> wallpaper_encoding_op_;
+
+ base::WeakPtrFactory<WallpaperImageSource> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(WallpaperImageSource);
+};
+
+} // namespace options2
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_WALLPAPER_SOURCE2_H_
diff --git a/chrome/browser/ui/webui/options2/options_ui2.cc b/chrome/browser/ui/webui/options2/options_ui2.cc
index cee715b..1e1ad06 100644
--- a/chrome/browser/ui/webui/options2/options_ui2.cc
+++ b/chrome/browser/ui/webui/options2/options_ui2.cc
@@ -308,7 +308,7 @@ OptionsUI::OptionsUI(content::WebUI* web_ui)
new chromeos::options2::UserImageSource();
ChromeURLDataManager::AddDataSource(profile, user_image_source);
- // Set up the chrome://wallpaper/ source.
+ // Set up the chrome://wallpaper-thumb/ source.
chromeos::options2::WallpaperThumbnailSource* wallpaper_thumbnail_source =
new chromeos::options2::WallpaperThumbnailSource();
ChromeURLDataManager::AddDataSource(profile, wallpaper_thumbnail_source);
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index eb30bc2..e42461b 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -3986,6 +3986,8 @@
'browser/ui/webui/options2/chromeos/system_settings_provider2.h',
'browser/ui/webui/options2/chromeos/user_image_source2.cc',
'browser/ui/webui/options2/chromeos/user_image_source2.h',
+ 'browser/ui/webui/options2/chromeos/wallpaper_source2.cc',
+ 'browser/ui/webui/options2/chromeos/wallpaper_source2.h',
'browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source2.cc',
'browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source2.h',
'browser/ui/webui/options2/clear_browser_data_handler2.cc',
diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc
index 9419314..878c298 100644
--- a/chrome/common/url_constants.cc
+++ b/chrome/common/url_constants.cc
@@ -97,7 +97,8 @@ const char kChromeUISystemInfoURL[] = "chrome://system/";
const char kChromeUITermsOemURL[] = "chrome://terms/oem";
const char kChromeUIUserImageURL[] = "chrome://userimage/";
const char kChromeUIWallpaperURL[] = "chrome://wallpapers/";
-const char kChromeUIWallpaperThumbnailURL[] = "chrome://wallpaper/";
+const char kChromeUIWallpaperImageURL[] = "chrome://wallpaper/";
+const char kChromeUIWallpaperThumbnailURL[] = "chrome://wallpaper-thumb/";
#endif
#if defined(USE_ASH)
@@ -232,7 +233,8 @@ const char kChromeUISlideshowHost[] = "slideshow";
const char kChromeUISystemInfoHost[] = "system";
const char kChromeUIUserImageHost[] = "userimage";
const char kChromeUIWallpaperHost[] = "wallpapers";
-const char kChromeUIWallpaperThumbnailHost[] = "wallpaper";
+const char kChromeUIWallpaperImageHost[] = "wallpaper";
+const char kChromeUIWallpaperThumbnailHost[] = "wallpaper-thumb";
const char kChromeUIMenu[] = "menu";
const char kChromeUINetworkMenu[] = "network-menu";
diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h
index d5a959c..c67f995 100644
--- a/chrome/common/url_constants.h
+++ b/chrome/common/url_constants.h
@@ -91,6 +91,7 @@ extern const char kChromeUISystemInfoURL[];
extern const char kChromeUITermsOemURL[];
extern const char kChromeUIUserImageURL[];
extern const char kChromeUIWallpaperURL[];
+extern const char kChromeUIWallpaperImageURL[];
extern const char kChromeUIWallpaperThumbnailURL[];
#endif
@@ -224,6 +225,7 @@ extern const char kChromeUISlideshowHost[];
extern const char kChromeUISystemInfoHost[];
extern const char kChromeUIUserImageHost[];
extern const char kChromeUIWallpaperHost[];
+extern const char kChromeUIWallpaperImageHost[];
extern const char kChromeUIWallpaperThumbnailHost[];
extern const char kChromeUIMenu[];