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

Side by Side 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, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_SYNC_CREDENTIAL_CACHE_WIN_H_
6 #define CHROME_BROWSER_SYNC_CREDENTIAL_CACHE_WIN_H_
7 #pragma once
8
9
10 #include "base/basictypes.h"
11 #include "base/file_path.h"
12 #include "base/memory/ref_counted.h"
13
14 #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.
15
16 namespace base {
17 class StringValue;
18 class Value;
19 }
20
21 namespace csync {
22
23 // Encapsulates the fields that are required in order to automatically start up
24 // sync. Used on Windows 8 after the user has manually signed in to Desktop
25 // or Metro, to auto-start sync on the alternate Metro or Desktop profile.
26 // RefCounted so that when SyncBackendHost or SigninManager want to persist sync
27 // credentials to file, they can pass in a CredentialCache object to one of the
28 // Persist* helper functions defined below, and not have to worry about
29 // 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
30 class CredentialCache : public base::RefCounted<CredentialCache>{
Roger Tawa OOO till Jul 10th 2012/06/27 21:23:28 space before {
31 public:
32 // Instantiates a CredentialCache object with credentials that will be
33 // persisted in |profile_dir| by one of the Persist* methods.
34 CredentialCache(const std::string& authenticated_username,
35 const std::string& sid,
36 const std::string& lsid,
37 const std::string& encryption_bootstrap_token,
38 const FilePath& profile_dir);
39
40 // Instantiates an empty CredentialCache object that will be populated by
41 // LoadCredentialsFromAlternateProfile with credentials from the alternate
42 // profile directory of |profile_dir|.
43 explicit CredentialCache(const FilePath& profile_dir);
44
45 // Returns true if |profile_dir| is the "Default" folder in Chrome's default
46 // user data directory, and false otherwise.
47 static bool IsDefaultProfileDir(const FilePath& profile_dir);
48
49 // 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.
50 // StringValue, and returns the result.
51 static base::StringValue* PackCredential(const std::string& clear_text);
52
53 // Extracts a string from the Value |packed|, base 64 decodes and decrypts it,
54 // and writes the result to |unpacked|.
55 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.
56 std::string* unpacked);
57
58 // Persists auth tokens to the sync credential cache in |profile_dir_|. Called
59 // by SigninManager after a successful signin. Must be run on the FILE
60 // 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.
61 // |credentials|.
62 static void PersistAuthTokens(scoped_refptr<CredentialCache> credentials);
63
64 // Persists the encryption bootstrap token to the sync credential cache in
65 // |profile_dir_|. Called by SyncBackendHost after successfully starting sync
66 // for encrypted datatypes. Must be run on the FILE BrowserThread, and only
67 // 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.
68 static void PersistEncryptionBootstrapToken(
69 scoped_refptr<CredentialCache> credentials);
70
71 // Reads sign in auth tokens and the encryption bootstrap token from the sync
72 // credential cache in the alternate profile directory on Windows 8.
73 // Called by ProfileSyncService while trying to automatically and silently
74 // start sync from cached credentials. Must be run on the FILE BrowserThread,
75 // and only for the "Default" profile.
76 static void LoadCredentialsFromAlternateProfile(
77 scoped_refptr<CredentialCache> credentials);
78
79 // Member accessors.
80 std::string authenticated_username() const { return authenticated_username_; }
81 std::string sid() const { return sid_; }
82 std::string lsid() const { return lsid_; }
83 std::string encryption_bootstrap_token() const {
84 return encryption_bootstrap_token_;
85 }
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.
86
87 protected:
88 // Ensures that file operations are running on the FILE BrowserThread. Virtual
89 // so that it can be mocked by unit tests.
90 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.
91
92 // Ensures that |profile_dir_| is the default profile directory, since we do
93 // not cache credentials in non-default directories. Virtual so that it can
94 // be mocked by unit tests.
95 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.
96
97 // Returns the path to the sync credentials file in the default Desktop
98 // profile directory if we are running in Metro mode, and vice versa. Virtual
99 // so that it can be mocked by unit tests.
100 virtual FilePath GetCredentialPathInAlternateProfile() const;
101
102 private:
103 // RefCounted implementation.
104 friend class base::RefCounted<CredentialCache>;
105 virtual ~CredentialCache();
106
107 // Credential fields.
108 std::string authenticated_username_;
109 std::string sid_;
110 std::string lsid_;
111 std::string encryption_bootstrap_token_;
112
113 // The profile directory in which the credential cache exists.
114 FilePath profile_dir_;
115
116 DISALLOW_COPY_AND_ASSIGN(CredentialCache);
117 };
118
119 } // namespace csync
120
121 #endif // CHROME_BROWSER_SYNC_CREDENTIAL_CACHE_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698