| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/login/user_manager.h" | 5 #include "chrome/browser/chromeos/login/user_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 // Stores path to the image in local state. Runs on UI thread. | 69 // Stores path to the image in local state. Runs on UI thread. |
| 70 void SavePathToLocalState(const std::string& username, | 70 void SavePathToLocalState(const std::string& username, |
| 71 const std::string& image_path) { | 71 const std::string& image_path) { |
| 72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 73 PrefService* local_state = g_browser_process->local_state(); | 73 PrefService* local_state = g_browser_process->local_state(); |
| 74 DictionaryPrefUpdate images_update(local_state, kUserImages); | 74 DictionaryPrefUpdate images_update(local_state, kUserImages); |
| 75 images_update->SetWithoutPathExpansion(username, new StringValue(image_path)); | 75 images_update->SetWithoutPathExpansion(username, new StringValue(image_path)); |
| 76 DVLOG(1) << "Saving path to user image in Local State."; | 76 DVLOG(1) << "Saving path to user image in Local State."; |
| 77 local_state->SavePersistentPrefs(); | 77 local_state->SavePersistentPrefs(); |
| 78 UserManager::Get()->NotifyLocalStateChanged(); |
| 78 } | 79 } |
| 79 | 80 |
| 80 // Saves image to file with specified path. Runs on FILE thread. | 81 // Saves image to file with specified path. Runs on FILE thread. |
| 81 // Posts task for saving image path to local state on UI thread. | 82 // Posts task for saving image path to local state on UI thread. |
| 82 void SaveImageToFile(const SkBitmap& image, | 83 void SaveImageToFile(const SkBitmap& image, |
| 83 const FilePath& image_path, | 84 const FilePath& image_path, |
| 84 const std::string& username) { | 85 const std::string& username) { |
| 85 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 86 std::vector<unsigned char> encoded_image; | 87 std::vector<unsigned char> encoded_image; |
| 87 if (!gfx::PNGCodec::EncodeBGRASkBitmap(image, true, &encoded_image)) { | 88 if (!gfx::PNGCodec::EncodeBGRASkBitmap(image, true, &encoded_image)) { |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 bool UserManager::current_user_is_owner() const { | 684 bool UserManager::current_user_is_owner() const { |
| 684 base::AutoLock lk(current_user_is_owner_lock_); | 685 base::AutoLock lk(current_user_is_owner_lock_); |
| 685 return current_user_is_owner_; | 686 return current_user_is_owner_; |
| 686 } | 687 } |
| 687 | 688 |
| 688 void UserManager::set_current_user_is_owner(bool current_user_is_owner) { | 689 void UserManager::set_current_user_is_owner(bool current_user_is_owner) { |
| 689 base::AutoLock lk(current_user_is_owner_lock_); | 690 base::AutoLock lk(current_user_is_owner_lock_); |
| 690 current_user_is_owner_ = current_user_is_owner; | 691 current_user_is_owner_ = current_user_is_owner; |
| 691 } | 692 } |
| 692 | 693 |
| 694 void UserManager::AddObserver(Observer* obs) { |
| 695 observer_list_.AddObserver(obs); |
| 696 } |
| 697 |
| 698 void UserManager::RemoveObserver(Observer* obs) { |
| 699 observer_list_.RemoveObserver(obs); |
| 700 } |
| 701 |
| 702 void UserManager::NotifyLocalStateChanged() { |
| 703 FOR_EACH_OBSERVER( |
| 704 Observer, |
| 705 observer_list_, |
| 706 LocalStateChanged(this)); |
| 707 } |
| 708 |
| 693 } // namespace chromeos | 709 } // namespace chromeos |
| OLD | NEW |