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

Unified Diff: chrome/browser/chromeos/login/user_manager.cc

Issue 2498003: Revert r48735 "Added user image screen for new user login (or old user logging in through" (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: removed grd files from cl Created 10 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/chromeos/login/user_image_view.cc ('k') | chrome/browser/chromeos/login/wizard_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/user_manager.cc
diff --git a/chrome/browser/chromeos/login/user_manager.cc b/chrome/browser/chromeos/login/user_manager.cc
index 565b4dd2e6cf4c2bf7654feeb763d61306f03f84..37a15c05429ff78490069e09b8238e2ca72d6818 100644
--- a/chrome/browser/chromeos/login/user_manager.cc
+++ b/chrome/browser/chromeos/login/user_manager.cc
@@ -12,7 +12,6 @@
#include "base/path_service.h"
#include "base/string_util.h"
#include "base/time.h"
-#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_thread.h"
@@ -35,45 +34,6 @@ const wchar_t kUserImages[] = L"UserImages";
// The one true UserManager.
static UserManager* user_manager_ = NULL;
-// Stores path to the image in local state. Runs on UI thread.
-void save_path_to_local_state(const std::string& username,
- const std::string& image_path) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
- PrefService* local_state = g_browser_process->local_state();
- DictionaryValue* images =
- local_state->GetMutableDictionary(kUserImages);
- images->SetWithoutPathExpansion(UTF8ToWide(username),
- new StringValue(image_path));
- LOG(INFO) << "Saving path to user image in Local State.";
- local_state->ScheduleSavePersistentPrefs();
-}
-
-// Saves image to file with specified path. Runs on FILE thread.
-// Posts task for saving image path to local state on UI thread.
-void save_image_to_file(const SkBitmap& image,
- const FilePath& image_path,
- const std::string& username) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
- std::vector<unsigned char> encoded_image;
- if (!gfx::PNGCodec::EncodeBGRASkBitmap(image, true, &encoded_image)) {
- LOG(ERROR) << "Failed to PNG encode the image.";
- return;
- }
-
- if (file_util::WriteFile(image_path,
- reinterpret_cast<char*>(&encoded_image[0]),
- encoded_image.size()) == -1) {
- LOG(ERROR) << "Failed to save image to file.";
- return;
- }
-
- ChromeThread::PostTask(
- ChromeThread::UI,
- FROM_HERE,
- NewRunnableFunction(&save_path_to_local_state,
- username, image_path.value()));
-}
-
} // namespace
UserManager::User::User() {
@@ -175,18 +135,28 @@ void UserManager::UserLoggedIn(const std::string& email) {
void UserManager::SaveUserImage(const std::string& username,
const SkBitmap& image) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
std::string filename = username + ".png";
FilePath user_data_dir;
PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
FilePath image_path = user_data_dir.AppendASCII(filename);
- LOG(INFO) << "Saving user image to " << image_path.value();
+ std::vector<unsigned char> encoded_image;
+ if (!gfx::PNGCodec::EncodeBGRASkBitmap(image, true, &encoded_image))
+ return;
ChromeThread::PostTask(
ChromeThread::FILE,
FROM_HERE,
- NewRunnableFunction(&save_image_to_file,
- image, image_path, username));
+ NewRunnableFunction<int(*)(const FilePath&, const char*, int)>(
+ &file_util::WriteFile,
+ image_path,
+ reinterpret_cast<char*>(&encoded_image[0]),
+ encoded_image.size()));
+ PrefService* local_state = g_browser_process->local_state();
+ DictionaryValue* images =
+ local_state->GetMutableDictionary(kUserImages);
+ images->SetWithoutPathExpansion(ASCIIToWide(username),
+ new StringValue(image_path.value()));
+ local_state->ScheduleSavePersistentPrefs();
}
void UserManager::OnImageLoaded(const std::string& username,
« no previous file with comments | « chrome/browser/chromeos/login/user_image_view.cc ('k') | chrome/browser/chromeos/login/wizard_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698