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

Side by Side Diff: chrome/browser/password_manager/native_backend_kwallet_x.h

Issue 2565173002: Remove ScopedVector from PasswordStoreX (Closed)
Patch Set: back_inserter, no =nullptr, drop autofill:: Created 4 years 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 CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_ 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_
6 #define CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_ 6 #define CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_
7 7
8 #include <memory>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_vector.h"
15 #include "base/nix/xdg_util.h" 15 #include "base/nix/xdg_util.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "chrome/browser/password_manager/password_store_factory.h" 17 #include "chrome/browser/password_manager/password_store_factory.h"
18 #include "chrome/browser/password_manager/password_store_x.h" 18 #include "chrome/browser/password_manager/password_store_x.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "components/os_crypt/kwallet_dbus.h" 20 #include "components/os_crypt/kwallet_dbus.h"
21 21
22 namespace autofill { 22 namespace autofill {
23 struct PasswordForm; 23 struct PasswordForm;
24 } 24 }
(...skipping 24 matching lines...) Expand all
49 base::Time delete_begin, 49 base::Time delete_begin,
50 base::Time delete_end, 50 base::Time delete_end,
51 password_manager::PasswordStoreChangeList* changes) override; 51 password_manager::PasswordStoreChangeList* changes) override;
52 bool RemoveLoginsSyncedBetween( 52 bool RemoveLoginsSyncedBetween(
53 base::Time delete_begin, 53 base::Time delete_begin,
54 base::Time delete_end, 54 base::Time delete_end,
55 password_manager::PasswordStoreChangeList* changes) override; 55 password_manager::PasswordStoreChangeList* changes) override;
56 bool DisableAutoSignInForOrigins( 56 bool DisableAutoSignInForOrigins(
57 const base::Callback<bool(const GURL&)>& origin_filter, 57 const base::Callback<bool(const GURL&)>& origin_filter,
58 password_manager::PasswordStoreChangeList* changes) override; 58 password_manager::PasswordStoreChangeList* changes) override;
59 bool GetLogins(const password_manager::PasswordStore::FormDigest& form, 59 bool GetLogins(
60 ScopedVector<autofill::PasswordForm>* forms) override; 60 const password_manager::PasswordStore::FormDigest& form,
61 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms) override;
61 bool GetAutofillableLogins( 62 bool GetAutofillableLogins(
62 ScopedVector<autofill::PasswordForm>* forms) override; 63 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms) override;
63 bool GetBlacklistLogins(ScopedVector<autofill::PasswordForm>* forms) override; 64 bool GetBlacklistLogins(
64 bool GetAllLogins(ScopedVector<autofill::PasswordForm>* forms) override; 65 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms) override;
66 bool GetAllLogins(
67 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms) override;
65 68
66 protected: 69 protected:
67 // Invalid handle returned by WalletHandle(). 70 // Invalid handle returned by WalletHandle().
68 static const int kInvalidKWalletHandle = -1; 71 static const int kInvalidKWalletHandle = -1;
69 72
70 // Internally used by Init(), but also for testing to provide a mock bus. 73 // Internally used by Init(), but also for testing to provide a mock bus.
71 bool InitWithBus(scoped_refptr<dbus::Bus> optional_bus); 74 bool InitWithBus(scoped_refptr<dbus::Bus> optional_bus);
72 75
73 // Deserializes a list of PasswordForms from the wallet. 76 // Deserializes a list of PasswordForms from the wallet.
74 static ScopedVector<autofill::PasswordForm> DeserializeValue( 77 static std::vector<std::unique_ptr<autofill::PasswordForm>> DeserializeValue(
75 const std::string& signon_realm, 78 const std::string& signon_realm,
76 const base::Pickle& pickle); 79 const base::Pickle& pickle);
77 80
78 private: 81 private:
79 enum InitResult { 82 enum InitResult {
80 INIT_SUCCESS, // Init succeeded. 83 INIT_SUCCESS, // Init succeeded.
81 TEMPORARY_FAIL, // Init failed, but might succeed after StartKWalletd(). 84 TEMPORARY_FAIL, // Init failed, but might succeed after StartKWalletd().
82 PERMANENT_FAIL // Init failed, and is not likely to work later either. 85 PERMANENT_FAIL // Init failed, and is not likely to work later either.
83 }; 86 };
84 87
85 enum TimestampToCompare { 88 enum TimestampToCompare {
86 CREATION_TIMESTAMP, 89 CREATION_TIMESTAMP,
87 SYNC_TIMESTAMP, 90 SYNC_TIMESTAMP,
88 }; 91 };
89 92
90 enum class BlacklistOptions { AUTOFILLABLE, BLACKLISTED }; 93 enum class BlacklistOptions { AUTOFILLABLE, BLACKLISTED };
91 94
92 // Initialization. 95 // Initialization.
93 InitResult InitWallet(); 96 InitResult InitWallet();
94 void InitOnDBThread(scoped_refptr<dbus::Bus> optional_bus, 97 void InitOnDBThread(scoped_refptr<dbus::Bus> optional_bus,
95 base::WaitableEvent* event, 98 base::WaitableEvent* event,
96 bool* success); 99 bool* success);
97 100
98 // Overwrites |forms| with all credentials matching |signon_realm|. Returns 101 // Overwrites |forms| with all credentials matching |signon_realm|. Returns
99 // true on success. 102 // true on success.
100 bool GetLoginsList(const std::string& signon_realm, 103 bool GetLoginsList(const std::string& signon_realm,
101 int wallet_handle, 104 int wallet_handle,
102 ScopedVector<autofill::PasswordForm>* forms) 105 std::vector<std::unique_ptr<autofill::PasswordForm>>*
103 WARN_UNUSED_RESULT; 106 forms) WARN_UNUSED_RESULT;
104 107
105 // Overwrites |forms| with all credentials matching |options|. Returns true on 108 // Overwrites |forms| with all credentials matching |options|. Returns true on
106 // success. 109 // success.
107 bool GetLoginsList(BlacklistOptions options, 110 bool GetLoginsList(BlacklistOptions options,
108 int wallet_handle, 111 int wallet_handle,
109 ScopedVector<autofill::PasswordForm>* forms) 112 std::vector<std::unique_ptr<autofill::PasswordForm>>*
110 WARN_UNUSED_RESULT; 113 forms) WARN_UNUSED_RESULT;
111 114
112 // Overwrites |forms| with all stored credentials. Returns true on success. 115 // Overwrites |forms| with all stored credentials. Returns true on success.
113 bool GetAllLoginsInternal(int wallet_handle, 116 bool GetAllLoginsInternal(
114 ScopedVector<autofill::PasswordForm>* forms) 117 int wallet_handle,
118 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms)
115 WARN_UNUSED_RESULT; 119 WARN_UNUSED_RESULT;
116 120
117 // Writes a list of PasswordForms to the wallet with the given signon_realm. 121 // Writes a list of PasswordForms to the wallet with the given signon_realm.
118 // Overwrites any existing list for this signon_realm. Removes the entry if 122 // Overwrites any existing list for this signon_realm. Removes the entry if
119 // |forms| is empty. Returns true on success. 123 // |forms| is empty. Returns true on success.
120 bool SetLoginsList(const std::vector<autofill::PasswordForm*>& forms, 124 bool SetLoginsList(
121 const std::string& signon_realm, 125 const std::vector<std::unique_ptr<autofill::PasswordForm>>& forms,
122 int wallet_handle); 126 const std::string& signon_realm,
127 int wallet_handle);
123 128
124 // Removes password created/synced in the time interval. Returns |true| if the 129 // Removes password created/synced in the time interval. Returns |true| if the
125 // operation succeeded. |changes| will contain the changes applied. 130 // operation succeeded. |changes| will contain the changes applied.
126 bool RemoveLoginsBetween(base::Time delete_begin, 131 bool RemoveLoginsBetween(base::Time delete_begin,
127 base::Time delete_end, 132 base::Time delete_end,
128 TimestampToCompare date_to_compare, 133 TimestampToCompare date_to_compare,
129 password_manager::PasswordStoreChangeList* changes); 134 password_manager::PasswordStoreChangeList* changes);
130 135
131 // Opens the wallet and ensures that the "Chrome Form Data" folder exists. 136 // Opens the wallet and ensures that the "Chrome Form Data" folder exists.
132 // Returns kInvalidWalletHandle on error. 137 // Returns kInvalidWalletHandle on error.
(...skipping 12 matching lines...) Expand all
145 150
146 // The name of the wallet we've opened. Set during Init(). 151 // The name of the wallet we've opened. Set during Init().
147 std::string wallet_name_; 152 std::string wallet_name_;
148 // The application name (e.g. "Chromium"), shown in KWallet auth dialogs. 153 // The application name (e.g. "Chromium"), shown in KWallet auth dialogs.
149 const std::string app_name_; 154 const std::string app_name_;
150 155
151 DISALLOW_COPY_AND_ASSIGN(NativeBackendKWallet); 156 DISALLOW_COPY_AND_ASSIGN(NativeBackendKWallet);
152 }; 157 };
153 158
154 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_ 159 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698