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

Side by Side Diff: chrome/browser/chromeos/login/user_manager.cc

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 22 matching lines...) Expand all
33 #include "chrome/browser/chromeos/login/ownership_service.h" 33 #include "chrome/browser/chromeos/login/ownership_service.h"
34 #include "chrome/browser/chromeos/user_cros_settings_provider.h" 34 #include "chrome/browser/chromeos/user_cros_settings_provider.h"
35 #include "chrome/browser/defaults.h" 35 #include "chrome/browser/defaults.h"
36 #include "chrome/browser/prefs/pref_service.h" 36 #include "chrome/browser/prefs/pref_service.h"
37 #include "chrome/browser/prefs/scoped_user_pref_update.h" 37 #include "chrome/browser/prefs/scoped_user_pref_update.h"
38 #include "chrome/browser/ui/webui/web_ui_util.h" 38 #include "chrome/browser/ui/webui/web_ui_util.h"
39 #include "chrome/common/chrome_notification_types.h" 39 #include "chrome/common/chrome_notification_types.h"
40 #include "chrome/common/chrome_paths.h" 40 #include "chrome/common/chrome_paths.h"
41 #include "chrome/common/chrome_switches.h" 41 #include "chrome/common/chrome_switches.h"
42 #include "content/browser/browser_thread.h" 42 #include "content/browser/browser_thread.h"
43 #include "content/common/notification_service.h" 43 #include "content/public/browser/notification_service.h"
44 #include "ui/base/resource/resource_bundle.h" 44 #include "ui/base/resource/resource_bundle.h"
45 #include "ui/gfx/codec/png_codec.h" 45 #include "ui/gfx/codec/png_codec.h"
46 46
47 #if defined(TOOLKIT_USES_GTK) 47 #if defined(TOOLKIT_USES_GTK)
48 #include "chrome/browser/chromeos/wm_ipc.h" 48 #include "chrome/browser/chromeos/wm_ipc.h"
49 #endif 49 #endif
50 50
51 namespace chromeos { 51 namespace chromeos {
52 52
53 namespace { 53 namespace {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 DictionaryPrefUpdate images_update(local_state, kUserImages); 223 DictionaryPrefUpdate images_update(local_state, kUserImages);
224 base::DictionaryValue* image_properties = new base::DictionaryValue(); 224 base::DictionaryValue* image_properties = new base::DictionaryValue();
225 image_properties->Set(kImagePathNodeName, new StringValue(image_path)); 225 image_properties->Set(kImagePathNodeName, new StringValue(image_path));
226 image_properties->Set(kImageIndexNodeName, 226 image_properties->Set(kImageIndexNodeName,
227 new base::FundamentalValue(image_index)); 227 new base::FundamentalValue(image_index));
228 images_update->SetWithoutPathExpansion(username, image_properties); 228 images_update->SetWithoutPathExpansion(username, image_properties);
229 DVLOG(1) << "Saving path to user image in Local State."; 229 DVLOG(1) << "Saving path to user image in Local State.";
230 local_state->SavePersistentPrefs(); 230 local_state->SavePersistentPrefs();
231 231
232 NotifyLocalStateChanged(); 232 NotifyLocalStateChanged();
233 NotificationService::current()->Notify( 233 content::NotificationService::current()->Notify(
234 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, 234 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
235 content::Source<UserManager>(this), 235 content::Source<UserManager>(this),
236 content::Details<const User>(&logged_in_user_)); 236 content::Details<const User>(&logged_in_user_));
237 } 237 }
238 238
239 void UserManager::SaveImageToFile(const SkBitmap& image, 239 void UserManager::SaveImageToFile(const SkBitmap& image,
240 const FilePath& image_path, 240 const FilePath& image_path,
241 const std::string& username, 241 const std::string& username,
242 int image_index) { 242 int image_index) {
243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
(...skipping 23 matching lines...) Expand all
267 if (!file_util::Delete(image_path, false)) { 267 if (!file_util::Delete(image_path, false)) {
268 LOG(ERROR) << "Failed to remove user image."; 268 LOG(ERROR) << "Failed to remove user image.";
269 return; 269 return;
270 } 270 }
271 } 271 }
272 272
273 void UserManager::UpdateOwnership(bool is_owner) { 273 void UserManager::UpdateOwnership(bool is_owner) {
274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
275 275
276 set_current_user_is_owner(is_owner); 276 set_current_user_is_owner(is_owner);
277 NotificationService::current()->Notify( 277 content::NotificationService::current()->Notify(
278 chrome::NOTIFICATION_OWNERSHIP_CHECKED, 278 chrome::NOTIFICATION_OWNERSHIP_CHECKED,
279 NotificationService::AllSources(), 279 content::NotificationService::AllSources(),
280 NotificationService::NoDetails()); 280 content::NotificationService::NoDetails());
281 if (is_owner) { 281 if (is_owner) {
282 // Also update cached value. 282 // Also update cached value.
283 UserCrosSettingsProvider::UpdateCachedOwner(logged_in_user_.email()); 283 UserCrosSettingsProvider::UpdateCachedOwner(logged_in_user_.email());
284 } 284 }
285 } 285 }
286 286
287 void UserManager::CheckOwnership() { 287 void UserManager::CheckOwnership() {
288 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 288 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
289 bool is_owner = OwnershipService::GetSharedInstance()->CurrentUserIsOwner(); 289 bool is_owner = OwnershipService::GetSharedInstance()->CurrentUserIsOwner();
290 VLOG(1) << "Current user " << (is_owner ? "is owner" : "is not owner"); 290 VLOG(1) << "Current user " << (is_owner ? "is owner" : "is not owner");
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 VLOG(1) << "Downloaded profile image for logged-in user."; 683 VLOG(1) << "Downloaded profile image for logged-in user.";
684 684
685 std::string current_image_data_url = 685 std::string current_image_data_url =
686 web_ui_util::GetImageDataUrl(logged_in_user_.image()); 686 web_ui_util::GetImageDataUrl(logged_in_user_.image());
687 std::string new_image_data_url = 687 std::string new_image_data_url =
688 web_ui_util::GetImageDataUrl(image); 688 web_ui_util::GetImageDataUrl(image);
689 if (current_image_data_url != new_image_data_url) { 689 if (current_image_data_url != new_image_data_url) {
690 VLOG(1) << "Updating profile image for logged-in user"; 690 VLOG(1) << "Updating profile image for logged-in user";
691 SetLoggedInUserImage(image, User::kProfileImageIndex); 691 SetLoggedInUserImage(image, User::kProfileImageIndex);
692 SaveUserImage(logged_in_user_.email(), image, User::kProfileImageIndex); 692 SaveUserImage(logged_in_user_.email(), image, User::kProfileImageIndex);
693 NotificationService::current()->Notify( 693 content::NotificationService::current()->Notify(
694 chrome::NOTIFICATION_PROFILE_IMAGE_UPDATED, 694 chrome::NOTIFICATION_PROFILE_IMAGE_UPDATED,
695 content::Source<UserManager>(this), 695 content::Source<UserManager>(this),
696 content::Details<const UserManager::User>(&logged_in_user())); 696 content::Details<const UserManager::User>(&logged_in_user()));
697 } 697 }
698 } 698 }
699 699
700 bool UserManager::IsLoggedInAsGuest() const { 700 bool UserManager::IsLoggedInAsGuest() const {
701 return logged_in_user().email() == kGuestUser; 701 return logged_in_user().email() == kGuestUser;
702 } 702 }
703 703
704 // Private constructor and destructor. Do nothing. 704 // Private constructor and destructor. Do nothing.
705 UserManager::UserManager() 705 UserManager::UserManager()
706 : ALLOW_THIS_IN_INITIALIZER_LIST(image_loader_(new UserImageLoader(this))), 706 : ALLOW_THIS_IN_INITIALIZER_LIST(image_loader_(new UserImageLoader(this))),
707 offline_login_(false), 707 offline_login_(false),
708 current_user_is_owner_(false), 708 current_user_is_owner_(false),
709 current_user_is_new_(false), 709 current_user_is_new_(false),
710 user_is_logged_in_(false), 710 user_is_logged_in_(false),
711 last_image_set_async_(false) { 711 last_image_set_async_(false) {
712 registrar_.Add(this, chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED, 712 registrar_.Add(this, chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED,
713 NotificationService::AllSources()); 713 content::NotificationService::AllSources());
714 } 714 }
715 715
716 UserManager::~UserManager() { 716 UserManager::~UserManager() {
717 image_loader_->set_delegate(NULL); 717 image_loader_->set_delegate(NULL);
718 } 718 }
719 719
720 FilePath UserManager::GetImagePathForUser(const std::string& username) { 720 FilePath UserManager::GetImagePathForUser(const std::string& username) {
721 std::string filename = username + ".png"; 721 std::string filename = username + ".png";
722 FilePath user_data_dir; 722 FilePath user_data_dir;
723 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); 723 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
(...skipping 27 matching lines...) Expand all
751 std::string local_user_pin; 751 std::string local_user_pin;
752 CrosLibrary::Get()->GetCryptohomeLibrary()->Pkcs11GetTpmTokenInfo( 752 CrosLibrary::Get()->GetCryptohomeLibrary()->Pkcs11GetTpmTokenInfo(
753 &local_token_name, &local_user_pin); 753 &local_token_name, &local_user_pin);
754 if (token_name) 754 if (token_name)
755 *token_name = local_token_name; 755 *token_name = local_token_name;
756 if (user_pin) 756 if (user_pin)
757 *user_pin = local_user_pin; 757 *user_pin = local_user_pin;
758 } 758 }
759 759
760 void UserManager::NotifyOnLogin() { 760 void UserManager::NotifyOnLogin() {
761 NotificationService::current()->Notify( 761 content::NotificationService::current()->Notify(
762 chrome::NOTIFICATION_LOGIN_USER_CHANGED, 762 chrome::NOTIFICATION_LOGIN_USER_CHANGED,
763 content::Source<UserManager>(this), 763 content::Source<UserManager>(this),
764 content::Details<const User>(&logged_in_user_)); 764 content::Details<const User>(&logged_in_user_));
765 765
766 chromeos::input_method::InputMethodManager::GetInstance()-> 766 chromeos::input_method::InputMethodManager::GetInstance()->
767 SetDeferImeStartup(false); 767 SetDeferImeStartup(false);
768 // Shut down the IME so that it will reload the user's settings. 768 // Shut down the IME so that it will reload the user's settings.
769 chromeos::input_method::InputMethodManager::GetInstance()-> 769 chromeos::input_method::InputMethodManager::GetInstance()->
770 StopInputMethodDaemon(); 770 StopInputMethodDaemon();
771 771
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 observer_list_, 828 observer_list_,
829 LocalStateChanged(this)); 829 LocalStateChanged(this));
830 } 830 }
831 831
832 void UserManager::DownloadProfileImage() { 832 void UserManager::DownloadProfileImage() {
833 profile_image_downloader_.reset(new ProfileImageDownloader(this)); 833 profile_image_downloader_.reset(new ProfileImageDownloader(this));
834 profile_image_downloader_->Start(); 834 profile_image_downloader_->Start();
835 } 835 }
836 836
837 } // namespace chromeos 837 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/user_image_screen.cc ('k') | chrome/browser/chromeos/login/views_oobe_display.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698