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

Unified Diff: chrome/browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source2.cc

Issue 10375010: Implement user selected wallpaper feature. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source2.cc
diff --git a/chrome/browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source2.cc b/chrome/browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source2.cc
index 8186da8b2289512dca0210c72cb4a04f6da38249..bc38e2da184353c2c6ab66441335f8aafef6709c 100644
--- a/chrome/browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source2.cc
+++ b/chrome/browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source2.cc
@@ -12,6 +12,7 @@
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "base/threading/thread_restrictions.h"
+#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
#include "chrome/common/url_constants.h"
@@ -27,8 +28,9 @@ namespace options2 {
namespace {
const char kDefaultWallpaperPrefix[] = "default_";
+const char kCustomWallpaperPrefix[] = "custom_";
-// Parse an integer from |path| and save it to |index|. For example, deafult_20
+// Parse an integer from |path| and save it to |index|. For example, default_20
// will set |index| to 20.
// |path| and |index| must not be NULL.
bool ParseIndexFromPath(const std::string& path, int* index) {
@@ -51,6 +53,18 @@ int PathToIDR(const std::string& path) {
return idr;
}
+// True if |path| is a custom wallpaper thumbnail URL and set |email| parsed
+// from |path|.
+// custom url = "custom_|email|?date" where date is current time.
+bool IsCustomWallpaperPath(const std::string& path, std::string* email) {
+ if (!StartsWithASCII(path, kCustomWallpaperPrefix, false))
+ return false;
+
+ std::string sub_path = path.substr(strlen(kCustomWallpaperPrefix));
+ *email = sub_path.substr(0, sub_path.find_first_of("?"));
+ return true;
+}
+
} // namespace
std::string GetDefaultWallpaperThumbnailURL(int index) {
@@ -78,6 +92,17 @@ WallpaperThumbnailSource::~WallpaperThumbnailSource() {
void WallpaperThumbnailSource::StartDataRequest(const std::string& path,
bool is_incognito,
int request_id) {
+ std::string email;
+ if (IsCustomWallpaperPath(path, &email)) {
+ const chromeos::User* user = chromeos::UserManager::Get()->FindUser(email);
+ if (user) {
+ std::vector<unsigned char> data;
+ gfx::PNGCodec::EncodeBGRASkBitmap(user->wallpaper_thumbnail(),
+ false, &data);
+ SendResponse(request_id, new base::RefCountedBytes(data));
+ return;
+ }
+ }
int idr = PathToIDR(path);
if (idr != -1) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
« no previous file with comments | « chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698