OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/login/session_manager_observer.h" |
| 6 |
| 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/chromeos/login/signed_settings.h" |
| 9 #include "chrome/browser/chromeos/login/signed_settings_temp_storage.h" |
| 10 #include "chrome/common/chrome_notification_types.h" |
| 11 #include "content/browser/browser_thread.h" |
| 12 #include "content/common/notification_service.h" |
| 13 |
| 14 namespace chromeos { |
| 15 |
| 16 namespace { |
| 17 |
| 18 class StubDelegate |
| 19 : public SignedSettings::Delegate< |
| 20 const enterprise_management::PolicyFetchResponse&> { |
| 21 public: |
| 22 StubDelegate() : policy_fetcher_(NULL) {} |
| 23 virtual ~StubDelegate() {} |
| 24 |
| 25 void set_fetcher(SignedSettings* fetcher) { policy_fetcher_ = fetcher; } |
| 26 SignedSettings* fetcher() { return policy_fetcher_.get(); } |
| 27 |
| 28 // Implementation of SignedSettings::Delegate |
| 29 virtual void OnSettingsOpCompleted( |
| 30 SignedSettings::ReturnCode code, |
| 31 const enterprise_management::PolicyFetchResponse& value) { |
| 32 VLOG(1) << "Done Fetching Policy"; |
| 33 delete this; |
| 34 } |
| 35 |
| 36 private: |
| 37 scoped_refptr<SignedSettings> policy_fetcher_; |
| 38 DISALLOW_COPY_AND_ASSIGN(StubDelegate); |
| 39 }; |
| 40 |
| 41 } // namespace |
| 42 |
| 43 SessionManagerObserver::SessionManagerObserver() { |
| 44 } |
| 45 |
| 46 SessionManagerObserver::~SessionManagerObserver() { |
| 47 } |
| 48 |
| 49 void SessionManagerObserver::OwnerKeySet(bool success) { |
| 50 VLOG(1) << "Owner key generation: " << (success ? "success" : "fail"); |
| 51 int result = |
| 52 chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED; |
| 53 if (!success) |
| 54 result = chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_FAILED; |
| 55 |
| 56 // Whether we exported the public key or not, send a notification |
| 57 // indicating that we're done with this attempt. |
| 58 NotificationService::current()->Notify(result, |
| 59 NotificationService::AllSources(), |
| 60 NotificationService::NoDetails()); |
| 61 |
| 62 // We stored some settings in transient storage before owner was assigned. |
| 63 // Now owner is assigned and key is generated and we should persist |
| 64 // those settings into signed storage. |
| 65 if (g_browser_process && g_browser_process->local_state()) { |
| 66 SignedSettingsTempStorage::Finalize(g_browser_process->local_state()); |
| 67 } |
| 68 } |
| 69 |
| 70 void SessionManagerObserver::PropertyChangeComplete(bool success) { |
| 71 if (success) { |
| 72 StubDelegate* stub = new StubDelegate(); // Manages its own lifetime. |
| 73 stub->set_fetcher(SignedSettings::CreateRetrievePolicyOp(stub)); |
| 74 stub->fetcher()->Execute(); |
| 75 } |
| 76 } |
| 77 |
| 78 } // namespace chromeos |
OLD | NEW |