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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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/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 11 matching lines...) Expand all
22 #include "chrome/browser/chromeos/cros/cryptohome_library.h" 22 #include "chrome/browser/chromeos/cros/cryptohome_library.h"
23 #include "chrome/browser/chromeos/input_method/input_method_manager.h" 23 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
24 #include "chrome/browser/chromeos/login/default_user_images.h" 24 #include "chrome/browser/chromeos/login/default_user_images.h"
25 #include "chrome/browser/chromeos/login/login_display.h" 25 #include "chrome/browser/chromeos/login/login_display.h"
26 #include "chrome/browser/chromeos/login/ownership_service.h" 26 #include "chrome/browser/chromeos/login/ownership_service.h"
27 #include "chrome/browser/chromeos/user_cros_settings_provider.h" 27 #include "chrome/browser/chromeos/user_cros_settings_provider.h"
28 #include "chrome/browser/chromeos/wm_ipc.h" 28 #include "chrome/browser/chromeos/wm_ipc.h"
29 #include "chrome/browser/defaults.h" 29 #include "chrome/browser/defaults.h"
30 #include "chrome/browser/prefs/pref_service.h" 30 #include "chrome/browser/prefs/pref_service.h"
31 #include "chrome/browser/prefs/scoped_user_pref_update.h" 31 #include "chrome/browser/prefs/scoped_user_pref_update.h"
32 #include "chrome/common/chrome_notification_types.h"
32 #include "chrome/common/chrome_paths.h" 33 #include "chrome/common/chrome_paths.h"
33 #include "chrome/common/chrome_switches.h" 34 #include "chrome/common/chrome_switches.h"
34 #include "content/browser/browser_thread.h" 35 #include "content/browser/browser_thread.h"
35 #include "content/common/notification_service.h" 36 #include "content/common/notification_service.h"
36 #include "content/common/notification_type.h"
37 #include "ui/base/resource/resource_bundle.h" 37 #include "ui/base/resource/resource_bundle.h"
38 #include "ui/gfx/codec/png_codec.h" 38 #include "ui/gfx/codec/png_codec.h"
39 39
40 namespace chromeos { 40 namespace chromeos {
41 41
42 namespace { 42 namespace {
43 43
44 // A vector pref of the users who have logged into the device. 44 // A vector pref of the users who have logged into the device.
45 const char kLoggedInUsers[] = "LoggedInUsers"; 45 const char kLoggedInUsers[] = "LoggedInUsers";
46 // A dictionary that maps usernames to file paths to their images. 46 // A dictionary that maps usernames to file paths to their images.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 LOG(ERROR) << "Failed to remove user image."; 96 LOG(ERROR) << "Failed to remove user image.";
97 return; 97 return;
98 } 98 }
99 } 99 }
100 100
101 // Updates current user ownership on UI thread. 101 // Updates current user ownership on UI thread.
102 void UpdateOwnership(bool is_owner) { 102 void UpdateOwnership(bool is_owner) {
103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
104 104
105 g_user_manager.Get().set_current_user_is_owner(is_owner); 105 g_user_manager.Get().set_current_user_is_owner(is_owner);
106 NotificationService::current()->Notify(NotificationType::OWNERSHIP_CHECKED, 106 NotificationService::current()->Notify(
107 NotificationService::AllSources(), 107 chrome::NOTIFICATION_OWNERSHIP_CHECKED,
108 NotificationService::NoDetails()); 108 NotificationService::AllSources(),
109 NotificationService::NoDetails());
109 if (is_owner) { 110 if (is_owner) {
110 // Also update cached value. 111 // Also update cached value.
111 UserCrosSettingsProvider::UpdateCachedOwner( 112 UserCrosSettingsProvider::UpdateCachedOwner(
112 g_user_manager.Get().logged_in_user().email()); 113 g_user_manager.Get().logged_in_user().email());
113 } 114 }
114 } 115 }
115 116
116 // Checks current user's ownership on file thread. 117 // Checks current user's ownership on file thread.
117 void CheckOwnership() { 118 void CheckOwnership() {
118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 DVLOG(1) << "Loaded image for " << username; 531 DVLOG(1) << "Loaded image for " << username;
531 user_images_[username] = image; 532 user_images_[username] = image;
532 User user; 533 User user;
533 user.set_email(username); 534 user.set_email(username);
534 user.set_image(image); 535 user.set_image(image);
535 if (logged_in_user_.email() == username) 536 if (logged_in_user_.email() == username)
536 logged_in_user_.set_image(image); 537 logged_in_user_.set_image(image);
537 if (should_save_image) 538 if (should_save_image)
538 SaveUserImage(username, image); 539 SaveUserImage(username, image);
539 NotificationService::current()->Notify( 540 NotificationService::current()->Notify(
540 NotificationType::LOGIN_USER_IMAGE_CHANGED, 541 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
541 Source<UserManager>(this), 542 Source<UserManager>(this),
542 Details<const User>(&user)); 543 Details<const User>(&user));
543 } 544 }
544 545
545 bool UserManager::IsLoggedInAsGuest() const { 546 bool UserManager::IsLoggedInAsGuest() const {
546 return logged_in_user().email() == kGuestUser; 547 return logged_in_user().email() == kGuestUser;
547 } 548 }
548 549
549 // Private constructor and destructor. Do nothing. 550 // Private constructor and destructor. Do nothing.
550 UserManager::UserManager() 551 UserManager::UserManager()
551 : ALLOW_THIS_IN_INITIALIZER_LIST(image_loader_(new UserImageLoader(this))), 552 : ALLOW_THIS_IN_INITIALIZER_LIST(image_loader_(new UserImageLoader(this))),
552 current_user_is_owner_(false), 553 current_user_is_owner_(false),
553 current_user_is_new_(false), 554 current_user_is_new_(false),
554 user_is_logged_in_(false) { 555 user_is_logged_in_(false) {
555 registrar_.Add(this, NotificationType::OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED, 556 registrar_.Add(this, chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED,
556 NotificationService::AllSources()); 557 NotificationService::AllSources());
557 } 558 }
558 559
559 UserManager::~UserManager() { 560 UserManager::~UserManager() {
560 image_loader_->set_delegate(NULL); 561 image_loader_->set_delegate(NULL);
561 } 562 }
562 563
563 FilePath UserManager::GetImagePathForUser(const std::string& username) { 564 FilePath UserManager::GetImagePathForUser(const std::string& username) {
564 std::string filename = username + ".png"; 565 std::string filename = username + ".png";
565 FilePath user_data_dir; 566 FilePath user_data_dir;
(...skipping 29 matching lines...) Expand all
595 CrosLibrary::Get()->GetCryptohomeLibrary()->Pkcs11GetTpmTokenInfo( 596 CrosLibrary::Get()->GetCryptohomeLibrary()->Pkcs11GetTpmTokenInfo(
596 &local_token_name, &local_user_pin); 597 &local_token_name, &local_user_pin);
597 if (token_name) 598 if (token_name)
598 *token_name = local_token_name; 599 *token_name = local_token_name;
599 if (user_pin) 600 if (user_pin)
600 *user_pin = local_user_pin; 601 *user_pin = local_user_pin;
601 } 602 }
602 603
603 void UserManager::NotifyOnLogin() { 604 void UserManager::NotifyOnLogin() {
604 NotificationService::current()->Notify( 605 NotificationService::current()->Notify(
605 NotificationType::LOGIN_USER_CHANGED, 606 chrome::NOTIFICATION_LOGIN_USER_CHANGED,
606 Source<UserManager>(this), 607 Source<UserManager>(this),
607 Details<const User>(&logged_in_user_)); 608 Details<const User>(&logged_in_user_));
608 609
609 chromeos::input_method::InputMethodManager::GetInstance()-> 610 chromeos::input_method::InputMethodManager::GetInstance()->
610 SetDeferImeStartup(false); 611 SetDeferImeStartup(false);
611 // Shut down the IME so that it will reload the user's settings. 612 // Shut down the IME so that it will reload the user's settings.
612 chromeos::input_method::InputMethodManager::GetInstance()-> 613 chromeos::input_method::InputMethodManager::GetInstance()->
613 StopInputMethodDaemon(); 614 StopInputMethodDaemon();
614 // Let the window manager know that we're logged in now. 615 // Let the window manager know that we're logged in now.
615 WmIpc::instance()->SetLoggedInProperty(true); 616 WmIpc::instance()->SetLoggedInProperty(true);
616 // Ensure we've opened the real user's key/certificate database. 617 // Ensure we've opened the real user's key/certificate database.
617 crypto::OpenPersistentNSSDB(); 618 crypto::OpenPersistentNSSDB();
618 619
619 // Only load the Opencryptoki library into NSS if we have this switch. 620 // Only load the Opencryptoki library into NSS if we have this switch.
620 // TODO(gspencer): Remove this switch once cryptohomed work is finished: 621 // TODO(gspencer): Remove this switch once cryptohomed work is finished:
621 // http://crosbug.com/12295 and http://crosbug.com/12304 622 // http://crosbug.com/12295 and http://crosbug.com/12304
622 if (CommandLine::ForCurrentProcess()->HasSwitch( 623 if (CommandLine::ForCurrentProcess()->HasSwitch(
623 switches::kLoadOpencryptoki)) { 624 switches::kLoadOpencryptoki)) {
624 crypto::EnableTPMTokenForNSS(new RealTPMTokenInfoDelegate()); 625 crypto::EnableTPMTokenForNSS(new RealTPMTokenInfoDelegate());
625 } 626 }
626 627
627 // Schedules current user ownership check on file thread. 628 // Schedules current user ownership check on file thread.
628 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 629 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
629 NewRunnableFunction(&CheckOwnership)); 630 NewRunnableFunction(&CheckOwnership));
630 } 631 }
631 632
632 void UserManager::Observe(NotificationType type, 633 void UserManager::Observe(int type,
633 const NotificationSource& source, 634 const NotificationSource& source,
634 const NotificationDetails& details) { 635 const NotificationDetails& details) {
635 if (type == NotificationType::OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED) { 636 if (type == chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED) {
636 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 637 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
637 NewRunnableFunction(&CheckOwnership)); 638 NewRunnableFunction(&CheckOwnership));
638 } 639 }
639 } 640 }
640 641
641 bool UserManager::current_user_is_owner() const { 642 bool UserManager::current_user_is_owner() const {
642 base::AutoLock lk(current_user_is_owner_lock_); 643 base::AutoLock lk(current_user_is_owner_lock_);
643 return current_user_is_owner_; 644 return current_user_is_owner_;
644 } 645 }
645 646
646 void UserManager::set_current_user_is_owner(bool current_user_is_owner) { 647 void UserManager::set_current_user_is_owner(bool current_user_is_owner) {
647 base::AutoLock lk(current_user_is_owner_lock_); 648 base::AutoLock lk(current_user_is_owner_lock_);
648 current_user_is_owner_ = current_user_is_owner; 649 current_user_is_owner_ = current_user_is_owner;
649 } 650 }
650 651
651 } // namespace chromeos 652 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/user_manager.h ('k') | chrome/browser/chromeos/login/views_oobe_display.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698