Index: chrome/browser/chromeos/extensions/wallpaper_private_api.cc |
diff --git a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc |
index cd03addaecfaf09953764e743b3c2c9366990cae..b1401e74f586c4d2d5e13efb243540b3cb2d61d8 100644 |
--- a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc |
+++ b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc |
@@ -4,6 +4,9 @@ |
#include "chrome/browser/chromeos/extensions/wallpaper_private_api.h" |
+#include <map> |
+#include <set> |
+#include <string> |
#include <vector> |
#include "ash/desktop_background/desktop_background_controller.h" |
@@ -17,6 +20,7 @@ |
#include "base/memory/scoped_ptr.h" |
#include "base/path_service.h" |
#include "base/prefs/pref_service.h" |
+#include "base/stl_util.h" |
#include "base/strings/string_number_conversions.h" |
#include "base/strings/stringprintf.h" |
#include "base/threading/worker_pool.h" |
@@ -68,7 +72,9 @@ bool IsOEMDefaultWallpaper() { |
// Saves |data| as |file_name| to directory with |key|. Return false if the |
// directory can not be found/created or failed to write file. |
-bool SaveData(int key, const std::string& file_name, const std::string& data) { |
+bool SaveData(int key, |
+ const std::string& file_name, |
+ const std::vector<char>& data) { |
base::FilePath data_dir; |
CHECK(PathService::Get(key, &data_dir)); |
if (!base::DirectoryExists(data_dir) && |
@@ -78,7 +84,7 @@ bool SaveData(int key, const std::string& file_name, const std::string& data) { |
base::FilePath file_path = data_dir.Append(file_name); |
return base::PathExists(file_path) || |
- (base::WriteFile(file_path, data.c_str(), data.size()) != -1); |
+ base::WriteFile(file_path, vector_as_array(&data), data.size()) != -1; |
} |
// Gets |file_name| from directory with |key|. Return false if the directory can |
@@ -355,17 +361,18 @@ void WallpaperPrivateSetWallpaperIfExistsFunction:: |
const base::FilePath& fallback_path) { |
DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( |
sequence_token_)); |
- std::string data; |
base::FilePath path = file_path; |
if (!base::PathExists(file_path)) |
path = fallback_path; |
+ std::string data; |
if (base::PathExists(path) && |
base::ReadFileToString(path, &data)) { |
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
+ BrowserThread::PostTask( |
+ BrowserThread::UI, FROM_HERE, |
base::Bind(&WallpaperPrivateSetWallpaperIfExistsFunction::StartDecode, |
- this, data)); |
+ this, std::vector<char>(data.begin(), data.end()))); |
return; |
} |
std::string error = base::StringPrintf( |
@@ -831,8 +838,8 @@ void WallpaperPrivateSaveThumbnailFunction::Success() { |
SendResponse(true); |
} |
-void WallpaperPrivateSaveThumbnailFunction::Save(const std::string& data, |
- const std::string& file_name) { |
+void WallpaperPrivateSaveThumbnailFunction::Save(const std::vector<char>& data, |
+ const std::string& file_name) { |
DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( |
sequence_token_)); |
if (SaveData(chrome::DIR_CHROMEOS_WALLPAPER_THUMBNAILS, file_name, data)) { |