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

Unified Diff: chrome/browser/chromeos/cros/login_library.cc

Issue 3141031: [Chrome OS] Wire up ownership API from libcros (Closed)
Patch Set: address davemoore comments Created 10 years, 4 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
« no previous file with comments | « chrome/browser/chromeos/cros/login_library.h ('k') | chrome/browser/chromeos/cros/mock_login_library.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/cros/login_library.cc
diff --git a/chrome/browser/chromeos/cros/login_library.cc b/chrome/browser/chromeos/cros/login_library.cc
index ab29a4728807646273d2adb8323ba201860ee4d0..2b9b8e55e031f74df53b7d99826cf6466a66a5b7 100644
--- a/chrome/browser/chromeos/cros/login_library.cc
+++ b/chrome/browser/chromeos/cros/login_library.cc
@@ -12,13 +12,26 @@ namespace chromeos {
class LoginLibraryImpl : public LoginLibrary {
public:
- LoginLibraryImpl() {}
- virtual ~LoginLibraryImpl() {}
+ LoginLibraryImpl()
+ : set_owner_key_callback_(NULL) {
+ }
+ virtual ~LoginLibraryImpl() {
+ if (session_connection_) {
+ chromeos::DisconnectSession(session_connection_);
+ }
+ }
bool EmitLoginPromptReady() {
return chromeos::EmitLoginPromptReady();
}
+ bool SetOwnerKey(const std::vector<uint8>& public_key_der,
+ Delegate<bool>* callback) {
+ DCHECK(callback) << "must provide a callback to SetOwnerKey()";
+ set_owner_key_callback_ = callback;
+ return chromeos::SetOwnerKey(public_key_der);
+ }
+
bool StartSession(const std::string& user_email,
const std::string& unique_id /* unused */) {
// only pass unique_id through once we use it for something.
@@ -35,6 +48,41 @@ class LoginLibraryImpl : public LoginLibrary {
}
private:
+ static void Handler(void* object, const OwnershipEvent& event) {
+ LoginLibraryImpl* self = static_cast<LoginLibraryImpl*>(object);
+ switch (event) {
+ case SetKeySuccess:
+ self->CompleteSetOwnerKey(true);
+ break;
+ case SetKeyFailure:
+ self->CompleteSetOwnerKey(false);
+ break;
+ case WhitelistOpSuccess:
+ case WhitelistOpFailure:
+ case SettingsOpSuccess:
+ case SettingsOpFailure:
+ NOTIMPLEMENTED();
+ break;
+ default:
+ NOTREACHED();
+ }
+ }
+
+ void Init() {
+ session_connection_ = chromeos::MonitorSession(&Handler, this);
+ }
+
+ void CompleteSetOwnerKey(bool result) {
+ CHECK(set_owner_key_callback_) << "CompleteSetOwnerKey() called without "
+ "a registered callback!";
+ set_owner_key_callback_->Run(result);
+ set_owner_key_callback_ = NULL;
+ }
+
+ chromeos::SessionConnection session_connection_;
+
+ Delegate<bool>* set_owner_key_callback_;
+
DISALLOW_COPY_AND_ASSIGN(LoginLibraryImpl);
};
@@ -44,12 +92,23 @@ class LoginLibraryStubImpl : public LoginLibrary {
virtual ~LoginLibraryStubImpl() {}
bool EmitLoginPromptReady() { return true; }
+ bool SetOwnerKey(const std::vector<uint8>& public_key_der,
+ Delegate<bool>* callback) {
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableFunction(&SetOwnerKeyStubCallback, callback));
+ return true;
+ }
bool StartSession(const std::string& user_email,
const std::string& unique_id /* unused */) { return true; }
bool StopSession(const std::string& unique_id /* unused */) { return true; }
bool RestartJob(int pid, const std::string& command_line) { return true; }
private:
+ static void SetOwnerKeyStubCallback(Delegate<bool>* callback) {
+ callback->Run(true);
+ }
+
DISALLOW_COPY_AND_ASSIGN(LoginLibraryStubImpl);
};
« no previous file with comments | « chrome/browser/chromeos/cros/login_library.h ('k') | chrome/browser/chromeos/cros/mock_login_library.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698