| 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/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 8 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 10 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/nss_util.h" | 13 #include "base/nss_util.h" |
| 13 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 15 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
| 16 #include "base/time.h" | 17 #include "base/time.h" |
| 17 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
| 18 #include "base/values.h" | 19 #include "base/values.h" |
| 19 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/chromeos/cros/cros_library.h" | 21 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 21 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | 22 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
| 22 #include "chrome/browser/chromeos/cros/input_method_library.h" | 23 #include "chrome/browser/chromeos/cros/input_method_library.h" |
| 23 #include "chrome/browser/chromeos/login/login_display.h" | 24 #include "chrome/browser/chromeos/login/login_display.h" |
| 24 #include "chrome/browser/chromeos/login/ownership_service.h" | 25 #include "chrome/browser/chromeos/login/ownership_service.h" |
| 25 #include "chrome/browser/chromeos/user_cros_settings_provider.h" | 26 #include "chrome/browser/chromeos/user_cros_settings_provider.h" |
| 26 #include "chrome/browser/chromeos/wm_ipc.h" | 27 #include "chrome/browser/chromeos/wm_ipc.h" |
| 27 #include "chrome/browser/defaults.h" | 28 #include "chrome/browser/defaults.h" |
| 28 #include "chrome/browser/prefs/pref_service.h" | 29 #include "chrome/browser/prefs/pref_service.h" |
| 29 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
| 31 #include "chrome/common/chrome_switches.h" |
| 30 #include "content/browser/browser_thread.h" | 32 #include "content/browser/browser_thread.h" |
| 31 #include "content/common/notification_service.h" | 33 #include "content/common/notification_service.h" |
| 32 #include "content/common/notification_type.h" | 34 #include "content/common/notification_type.h" |
| 33 #include "grit/theme_resources.h" | 35 #include "grit/theme_resources.h" |
| 34 #include "ui/base/resource/resource_bundle.h" | 36 #include "ui/base/resource/resource_bundle.h" |
| 35 #include "ui/gfx/codec/png_codec.h" | 37 #include "ui/gfx/codec/png_codec.h" |
| 36 | 38 |
| 37 namespace chromeos { | 39 namespace chromeos { |
| 38 | 40 |
| 39 namespace { | 41 namespace { |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 Details<const User>(&logged_in_user_)); | 563 Details<const User>(&logged_in_user_)); |
| 562 | 564 |
| 563 chromeos::CrosLibrary::Get()->GetInputMethodLibrary()-> | 565 chromeos::CrosLibrary::Get()->GetInputMethodLibrary()-> |
| 564 SetDeferImeStartup(false); | 566 SetDeferImeStartup(false); |
| 565 // Shut down the IME so that it will reload the user's settings. | 567 // Shut down the IME so that it will reload the user's settings. |
| 566 chromeos::CrosLibrary::Get()->GetInputMethodLibrary()-> | 568 chromeos::CrosLibrary::Get()->GetInputMethodLibrary()-> |
| 567 StopInputMethodDaemon(); | 569 StopInputMethodDaemon(); |
| 568 // Let the window manager know that we're logged in now. | 570 // Let the window manager know that we're logged in now. |
| 569 WmIpc::instance()->SetLoggedInProperty(true); | 571 WmIpc::instance()->SetLoggedInProperty(true); |
| 570 // Ensure we've opened the real user's key/certificate database. | 572 // Ensure we've opened the real user's key/certificate database. |
| 571 base::OpenPersistentNSSDB(); | 573 bool init_tpm = |
| 574 CommandLine::ForCurrentProcess()->HasSwitch(switches::kLoadOpencryptoki); |
| 575 base::OpenPersistentNSSDB(init_tpm); |
| 572 | 576 |
| 573 // Schedules current user ownership check on file thread. | 577 // Schedules current user ownership check on file thread. |
| 574 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 578 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 575 NewRunnableFunction(&CheckOwnership)); | 579 NewRunnableFunction(&CheckOwnership)); |
| 576 } | 580 } |
| 577 | 581 |
| 578 void UserManager::Observe(NotificationType type, | 582 void UserManager::Observe(NotificationType type, |
| 579 const NotificationSource& source, | 583 const NotificationSource& source, |
| 580 const NotificationDetails& details) { | 584 const NotificationDetails& details) { |
| 581 if (type == NotificationType::OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED) { | 585 if (type == NotificationType::OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED) { |
| 582 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 586 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 583 NewRunnableFunction(&CheckOwnership)); | 587 NewRunnableFunction(&CheckOwnership)); |
| 584 } | 588 } |
| 585 } | 589 } |
| 586 | 590 |
| 587 bool UserManager::current_user_is_owner() const { | 591 bool UserManager::current_user_is_owner() const { |
| 588 base::AutoLock lk(current_user_is_owner_lock_); | 592 base::AutoLock lk(current_user_is_owner_lock_); |
| 589 return current_user_is_owner_; | 593 return current_user_is_owner_; |
| 590 } | 594 } |
| 591 | 595 |
| 592 void UserManager::set_current_user_is_owner(bool current_user_is_owner) { | 596 void UserManager::set_current_user_is_owner(bool current_user_is_owner) { |
| 593 base::AutoLock lk(current_user_is_owner_lock_); | 597 base::AutoLock lk(current_user_is_owner_lock_); |
| 594 current_user_is_owner_ = current_user_is_owner; | 598 current_user_is_owner_ = current_user_is_owner; |
| 595 } | 599 } |
| 596 | 600 |
| 597 } // namespace chromeos | 601 } // namespace chromeos |
| OLD | NEW |