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

Unified Diff: chrome/browser/chromeos/login/session_manager_observer.cc

Issue 8295019: chromeos: Implement the new D-Bus client for SessionManagerClient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/session_manager_observer.cc
diff --git a/chrome/browser/chromeos/login/session_manager_observer.cc b/chrome/browser/chromeos/login/session_manager_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5ec65b0394662fe107c7c1919303e1d3b688e2bf
--- /dev/null
+++ b/chrome/browser/chromeos/login/session_manager_observer.cc
@@ -0,0 +1,78 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/login/session_manager_observer.h"
+
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chromeos/login/signed_settings.h"
+#include "chrome/browser/chromeos/login/signed_settings_temp_storage.h"
+#include "chrome/common/chrome_notification_types.h"
+#include "content/browser/browser_thread.h"
+#include "content/common/notification_service.h"
+
+namespace chromeos {
+
+namespace {
+
+class StubDelegate
+ : public SignedSettings::Delegate<
+ const enterprise_management::PolicyFetchResponse&> {
+ public:
+ StubDelegate() : policy_fetcher_(NULL) {}
+ virtual ~StubDelegate() {}
+
+ void set_fetcher(SignedSettings* fetcher) { policy_fetcher_ = fetcher; }
+ SignedSettings* fetcher() { return policy_fetcher_.get(); }
+
+ // Implementation of SignedSettings::Delegate
+ virtual void OnSettingsOpCompleted(
+ SignedSettings::ReturnCode code,
+ const enterprise_management::PolicyFetchResponse& value) {
+ VLOG(1) << "Done Fetching Policy";
+ delete this;
+ }
+
+ private:
+ scoped_refptr<SignedSettings> policy_fetcher_;
+ DISALLOW_COPY_AND_ASSIGN(StubDelegate);
+};
+
+} // namespace
+
+SessionManagerObserver::SessionManagerObserver() {
+}
+
+SessionManagerObserver::~SessionManagerObserver() {
+}
+
+void SessionManagerObserver::OwnerKeySet(bool success) {
+ VLOG(1) << "Owner key generation: " << (success ? "success" : "fail");
+ int result =
+ chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED;
+ if (!success)
+ result = chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_FAILED;
+
+ // Whether we exported the public key or not, send a notification
+ // indicating that we're done with this attempt.
+ NotificationService::current()->Notify(result,
+ NotificationService::AllSources(),
+ NotificationService::NoDetails());
+
+ // We stored some settings in transient storage before owner was assigned.
+ // Now owner is assigned and key is generated and we should persist
+ // those settings into signed storage.
+ if (g_browser_process && g_browser_process->local_state()) {
+ SignedSettingsTempStorage::Finalize(g_browser_process->local_state());
+ }
+}
+
+void SessionManagerObserver::PropertyChangeComplete(bool success) {
+ if (success) {
+ StubDelegate* stub = new StubDelegate(); // Manages its own lifetime.
+ stub->set_fetcher(SignedSettings::CreateRetrievePolicyOp(stub));
+ stub->fetcher()->Execute();
+ }
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698