Upstream version 9.37.195.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / ownership / owner_settings_service.cc
index cf08b95..0fc5bf9 100644 (file)
@@ -13,6 +13,7 @@
 #include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h"
 #include "chrome/browser/chromeos/profiles/profile_helper.h"
 #include "chrome/browser/profiles/profile.h"
+#include "chromeos/dbus/dbus_thread_manager.h"
 #include "content/public/browser/browser_thread.h"
 #include "content/public/browser/notification_details.h"
 #include "content/public/browser/notification_source.h"
@@ -126,6 +127,11 @@ OwnerSettingsService::OwnerSettingsService(Profile* profile)
     TPMTokenLoader::Get()->AddObserver(this);
   }
 
+  if (DBusThreadManager::IsInitialized() &&
+      DBusThreadManager::Get()->GetSessionManagerClient()) {
+    DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this);
+  }
+
   registrar_.Add(this,
                  chrome::NOTIFICATION_PROFILE_CREATED,
                  content::Source<Profile>(profile_));
@@ -135,6 +141,11 @@ OwnerSettingsService::~OwnerSettingsService() {
   DCHECK(thread_checker_.CalledOnValidThread());
   if (TPMTokenLoader::IsInitialized())
     TPMTokenLoader::Get()->RemoveObserver(this);
+
+  if (DBusThreadManager::IsInitialized() &&
+      DBusThreadManager::Get()->GetSessionManagerClient()) {
+    DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this);
+  }
 }
 
 bool OwnerSettingsService::IsOwner() {
@@ -196,6 +207,12 @@ void OwnerSettingsService::OnTPMTokenReady() {
   ReloadPrivateKey();
 }
 
+void OwnerSettingsService::OwnerKeySet(bool success) {
+  DCHECK(thread_checker_.CalledOnValidThread());
+  if (success)
+    ReloadPrivateKey();
+}
+
 // static
 void OwnerSettingsService::IsPrivateKeyExistAsync(
     const IsOwnerCallback& callback) {
@@ -264,7 +281,7 @@ void OwnerSettingsService::OnPrivateKeyLoaded(
 
   std::vector<IsOwnerCallback> is_owner_callbacks;
   is_owner_callbacks.swap(pending_is_owner_callbacks_);
-  const bool is_owner = private_key_.get() && private_key_->key();
+  const bool is_owner = IsOwner();
   for (std::vector<IsOwnerCallback>::iterator it(is_owner_callbacks.begin());
        it != is_owner_callbacks.end();
        ++it) {