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

Unified Diff: chrome/browser/sync/credential_cache_win.h

Issue 10656033: [sync] Automatic bootstrapping of Sync on Win 8 from cached credentials (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: "" Created 8 years, 6 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/sync/credential_cache_win.h
diff --git a/chrome/browser/sync/credential_cache_win.h b/chrome/browser/sync/credential_cache_win.h
new file mode 100644
index 0000000000000000000000000000000000000000..f9c984e538646b7810c8f887315629f3ced5bf94
--- /dev/null
+++ b/chrome/browser/sync/credential_cache_win.h
@@ -0,0 +1,121 @@
+// Copyright (c) 2012 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.
+
+#ifndef CHROME_BROWSER_SYNC_CREDENTIAL_CACHE_WIN_H_
+#define CHROME_BROWSER_SYNC_CREDENTIAL_CACHE_WIN_H_
+#pragma once
+
+
+#include "base/basictypes.h"
+#include "base/file_path.h"
+#include "base/memory/ref_counted.h"
+
+#include <string>
Andrew T Wilson (Slow) 2012/06/26 23:26:13 std includes go above project-specific includes.
Raghu Simha 2012/07/19 06:57:07 Done.
+
+namespace base {
+class StringValue;
+class Value;
+}
+
+namespace csync {
+
+// Encapsulates the fields that are required in order to automatically start up
+// sync. Used on Windows 8 after the user has manually signed in to Desktop
+// or Metro, to auto-start sync on the alternate Metro or Desktop profile.
+// RefCounted so that when SyncBackendHost or SigninManager want to persist sync
+// credentials to file, they can pass in a CredentialCache object to one of the
+// Persist* helper functions defined below, and not have to worry about
+// cleaning up the object.
Roger Tawa OOO till Jul 10th 2012/06/27 21:23:28 I'm not sure why you need this class. why can't y
Raghu Simha 2012/07/19 06:57:07 The design has changed pretty significantly. Pleas
+class CredentialCache : public base::RefCounted<CredentialCache>{
Roger Tawa OOO till Jul 10th 2012/06/27 21:23:28 space before {
+ public:
+ // Instantiates a CredentialCache object with credentials that will be
+ // persisted in |profile_dir| by one of the Persist* methods.
+ CredentialCache(const std::string& authenticated_username,
+ const std::string& sid,
+ const std::string& lsid,
+ const std::string& encryption_bootstrap_token,
+ const FilePath& profile_dir);
+
+ // Instantiates an empty CredentialCache object that will be populated by
+ // LoadCredentialsFromAlternateProfile with credentials from the alternate
+ // profile directory of |profile_dir|.
+ explicit CredentialCache(const FilePath& profile_dir);
+
+ // Returns true if |profile_dir| is the "Default" folder in Chrome's default
+ // user data directory, and false otherwise.
+ static bool IsDefaultProfileDir(const FilePath& profile_dir);
+
+ // Encrypts and base 64 encodes |plaintext|, converts the result to a
Roger Tawa OOO till Jul 10th 2012/06/27 21:23:28 |plaintext| not right. Document that the caller n
Raghu Simha 2012/07/19 06:57:07 Done.
+ // StringValue, and returns the result.
+ static base::StringValue* PackCredential(const std::string& clear_text);
+
+ // Extracts a string from the Value |packed|, base 64 decodes and decrypts it,
+ // and writes the result to |unpacked|.
+ static void UnpackCredential(const base::Value* packed,
Roger Tawa OOO till Jul 10th 2012/06/27 21:23:28 use a const ref?
Raghu Simha 2012/07/19 06:57:07 Done.
+ std::string* unpacked);
+
+ // Persists auth tokens to the sync credential cache in |profile_dir_|. Called
+ // by SigninManager after a successful signin. Must be run on the FILE
+ // BrowserThread, and only for the "Default" profile. Takes over ownership of
Andrew T Wilson (Slow) 2012/06/26 23:26:13 Nobody owns a refcounted ptr, so it's not true tha
Raghu Simha 2012/07/19 06:57:07 This method has been removed.
+ // |credentials|.
+ static void PersistAuthTokens(scoped_refptr<CredentialCache> credentials);
+
+ // Persists the encryption bootstrap token to the sync credential cache in
+ // |profile_dir_|. Called by SyncBackendHost after successfully starting sync
+ // for encrypted datatypes. Must be run on the FILE BrowserThread, and only
+ // for the "Default" profile. Takes over ownership of |credentials|.
Andrew T Wilson (Slow) 2012/06/26 23:26:13 Nobody owns a refcounted object, so this doesn't t
Raghu Simha 2012/07/19 06:57:07 This method has been removed.
+ static void PersistEncryptionBootstrapToken(
+ scoped_refptr<CredentialCache> credentials);
+
+ // Reads sign in auth tokens and the encryption bootstrap token from the sync
+ // credential cache in the alternate profile directory on Windows 8.
+ // Called by ProfileSyncService while trying to automatically and silently
+ // start sync from cached credentials. Must be run on the FILE BrowserThread,
+ // and only for the "Default" profile.
+ static void LoadCredentialsFromAlternateProfile(
+ scoped_refptr<CredentialCache> credentials);
+
+ // Member accessors.
+ std::string authenticated_username() const { return authenticated_username_; }
+ std::string sid() const { return sid_; }
+ std::string lsid() const { return lsid_; }
+ std::string encryption_bootstrap_token() const {
+ return encryption_bootstrap_token_;
+ }
Roger Tawa OOO till Jul 10th 2012/06/27 21:23:28 i would return const ref return values for all the
Raghu Simha 2012/07/19 06:57:07 These methods have been removed.
+
+ protected:
+ // Ensures that file operations are running on the FILE BrowserThread. Virtual
+ // so that it can be mocked by unit tests.
+ virtual bool RunningOnCorrectThread() const;
Roger Tawa OOO till Jul 10th 2012/06/27 21:23:28 I think the name of this function should say "file
Raghu Simha 2012/07/19 06:57:07 This method has been removed.
+
+ // Ensures that |profile_dir_| is the default profile directory, since we do
+ // not cache credentials in non-default directories. Virtual so that it can
+ // be mocked by unit tests.
+ virtual bool RunningInCorrectProfileDir() const;
Roger Tawa OOO till Jul 10th 2012/06/27 21:23:28 I think the name of this function should say "defa
Raghu Simha 2012/07/19 06:57:07 This method has been removed.
+
+ // Returns the path to the sync credentials file in the default Desktop
+ // profile directory if we are running in Metro mode, and vice versa. Virtual
+ // so that it can be mocked by unit tests.
+ virtual FilePath GetCredentialPathInAlternateProfile() const;
+
+ private:
+ // RefCounted implementation.
+ friend class base::RefCounted<CredentialCache>;
+ virtual ~CredentialCache();
+
+ // Credential fields.
+ std::string authenticated_username_;
+ std::string sid_;
+ std::string lsid_;
+ std::string encryption_bootstrap_token_;
+
+ // The profile directory in which the credential cache exists.
+ FilePath profile_dir_;
+
+ DISALLOW_COPY_AND_ASSIGN(CredentialCache);
+};
+
+} // namespace csync
+
+#endif // CHROME_BROWSER_SYNC_CREDENTIAL_CACHE_WIN_H_

Powered by Google App Engine
This is Rietveld 408576698