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

Side by Side Diff: chromeos/cryptohome/system_salt_getter.h

Issue 1886653002: Remove WallpaperManager dependency on Cryptohome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests. Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROMEOS_CRYPTOHOME_SYSTEM_SALT_GETTER_H_ 5 #ifndef CHROMEOS_CRYPTOHOME_SYSTEM_SALT_GETTER_H_
6 #define CHROMEOS_CRYPTOHOME_SYSTEM_SALT_GETTER_H_ 6 #define CHROMEOS_CRYPTOHOME_SYSTEM_SALT_GETTER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback_forward.h" 13 #include "base/callback_forward.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "chromeos/chromeos_export.h" 16 #include "chromeos/chromeos_export.h"
17 #include "chromeos/dbus/dbus_method_call_status.h" 17 #include "chromeos/dbus/dbus_method_call_status.h"
18 18
19 namespace chromeos { 19 namespace chromeos {
20 20
21 // This class is used to get the system salt from cryptohome and cache it. 21 // This class is used to get the system salt from cryptohome and cache it.
22 class CHROMEOS_EXPORT SystemSaltGetter { 22 class CHROMEOS_EXPORT SystemSaltGetter {
23 public: 23 public:
24 typedef base::Callback<void(const std::string& system_salt)> 24 typedef base::Callback<void(const std::string& system_salt)>
25 GetSystemSaltCallback; 25 GetSystemSaltCallback;
26 26
27 using RawSalt = std::vector<uint8_t>;
28
27 // Manage an explicitly initialized global instance. 29 // Manage an explicitly initialized global instance.
28 static void Initialize(); 30 static void Initialize();
29 static bool IsInitialized(); 31 static bool IsInitialized();
30 static void Shutdown(); 32 static void Shutdown();
31 static SystemSaltGetter* Get(); 33 static SystemSaltGetter* Get();
32 34
33 // Converts |salt| to a hex encoded string. 35 // Converts |salt| to a hex encoded string.
34 static std::string ConvertRawSaltToHexString( 36 static std::string ConvertRawSaltToHexString(const RawSalt& salt);
35 const std::vector<uint8_t>& salt);
36 37
37 // Returns system hash in hex encoded ascii format. Note: this may return 38 // Returns system hash in hex encoded ascii format. Note: this may return
38 // an empty string (e.g. errors in D-Bus layer) 39 // an empty string (e.g. errors in D-Bus layer)
39 void GetSystemSalt(const GetSystemSaltCallback& callback); 40 void GetSystemSalt(const GetSystemSaltCallback& callback);
40 41
42 // Returns pointer to binary system salt if it is already known.
43 // Returns nullptr if system salt is not known.
44 const SystemSaltGetter::RawSalt* GetRawSalt() const;
Darren Krahn 2016/04/13 16:33:44 nit: SystemSaltGetter:: not necessary
Alexander Alekseev 2016/04/14 03:37:29 Done.
45
46 // This is for browser tests API.
47 void SetRawSaltForTesting(const SystemSaltGetter::RawSalt& raw_salt);
Darren Krahn 2016/04/13 16:33:43 nit: Here too
Alexander Alekseev 2016/04/14 03:37:29 Done.
48
41 protected: 49 protected:
42 SystemSaltGetter(); 50 SystemSaltGetter();
43 ~SystemSaltGetter(); 51 ~SystemSaltGetter();
44 52
45 private: 53 private:
46 // Used to implement GetSystemSalt(). 54 // Used to implement GetSystemSalt().
47 void DidWaitForServiceToBeAvailable(const GetSystemSaltCallback& callback, 55 void DidWaitForServiceToBeAvailable(const GetSystemSaltCallback& callback,
48 bool service_is_available); 56 bool service_is_available);
49 void DidGetSystemSalt(const GetSystemSaltCallback& callback, 57 void DidGetSystemSalt(const GetSystemSaltCallback& callback,
50 DBusMethodCallStatus call_status, 58 DBusMethodCallStatus call_status,
51 const std::vector<uint8_t>& system_salt); 59 const RawSalt& system_salt);
52 60
61 RawSalt raw_salt_;
53 std::string system_salt_; 62 std::string system_salt_;
54 63
55 base::WeakPtrFactory<SystemSaltGetter> weak_ptr_factory_; 64 base::WeakPtrFactory<SystemSaltGetter> weak_ptr_factory_;
56 65
57 DISALLOW_COPY_AND_ASSIGN(SystemSaltGetter); 66 DISALLOW_COPY_AND_ASSIGN(SystemSaltGetter);
58 }; 67 };
59 68
60 } // namespace chromeos 69 } // namespace chromeos
61 70
62 #endif // CHROMEOS_CRYPTOHOME_SYSTEM_SALT_GETTER_H_ 71 #endif // CHROMEOS_CRYPTOHOME_SYSTEM_SALT_GETTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698