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

Side by Side Diff: components/password_manager/core/browser/password_form_manager.h

Issue 2926833002: Revert of [Password Manager] Convert |pending_login_managers_| to an array of scoped_refptr (Closed)
Patch Set: Created 3 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 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 COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_FORM_MANAGER_H_ 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_FORM_MANAGER_H_
6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_FORM_MANAGER_H_ 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_FORM_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h"
17 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
18 #include "base/optional.h" 17 #include "base/optional.h"
19 #include "base/strings/string16.h" 18 #include "base/strings/string16.h"
20 #include "build/build_config.h" 19 #include "build/build_config.h"
21 #include "components/autofill/core/browser/field_types.h" 20 #include "components/autofill/core/browser/field_types.h"
22 #include "components/autofill/core/browser/form_structure.h" 21 #include "components/autofill/core/browser/form_structure.h"
23 #include "components/autofill/core/common/password_form.h" 22 #include "components/autofill/core/common/password_form.h"
24 #include "components/password_manager/core/browser/form_fetcher.h" 23 #include "components/password_manager/core/browser/form_fetcher.h"
25 #include "components/password_manager/core/browser/password_manager_driver.h" 24 #include "components/password_manager/core/browser/password_manager_driver.h"
26 #include "components/password_manager/core/browser/password_store.h" 25 #include "components/password_manager/core/browser/password_store.h"
27 26
28 using autofill::FormData; 27 using autofill::FormData;
29 using autofill::FormStructure; 28 using autofill::FormStructure;
30 29
31 namespace password_manager { 30 namespace password_manager {
32 31
33 class FormSaver; 32 class FormSaver;
34 class PasswordManager; 33 class PasswordManager;
35 class PasswordManagerClient; 34 class PasswordManagerClient;
36 35
37 // A map from field names to field types. 36 // A map from field names to field types.
38 using FieldTypeMap = std::map<base::string16, autofill::ServerFieldType>; 37 using FieldTypeMap = std::map<base::string16, autofill::ServerFieldType>;
39 38
40 // This class helps with filling the observed form (both HTML and from HTTP 39 // This class helps with filling the observed form (both HTML and from HTTP
41 // auth) and with saving/updating the stored information about it. 40 // auth) and with saving/updating the stored information about it.
42 class PasswordFormManager : public FormFetcher::Consumer, 41 class PasswordFormManager : public FormFetcher::Consumer {
43 public base::RefCounted<PasswordFormManager> {
44 public: 42 public:
45 // |password_manager| owns |this|, |client| and |driver| serve to 43 // |password_manager| owns |this|, |client| and |driver| serve to
46 // communicate with embedder, |observed_form| is the associated form |this| 44 // communicate with embedder, |observed_form| is the associated form |this|
47 // is managing, |form_saver| is used to save/update the form and 45 // is managing, |form_saver| is used to save/update the form and
48 // |form_fetcher| to get saved data about the form. |form_fetcher| must not be 46 // |form_fetcher| to get saved data about the form. |form_fetcher| must not be
49 // destroyed before |this|. 47 // destroyed before |this|.
50 // 48 //
51 // TODO(crbug.com/621355): So far, |form_fetcher| can be null. In that case 49 // TODO(crbug.com/621355): So far, |form_fetcher| can be null. In that case
52 // |this| creates an instance of it itself (meant for production code). Once 50 // |this| creates an instance of it itself (meant for production code). Once
53 // the fetcher is shared between PasswordFormManager instances, it will be 51 // the fetcher is shared between PasswordFormManager instances, it will be
54 // required that |form_fetcher| is not null. 52 // required that |form_fetcher| is not null.
55 PasswordFormManager(PasswordManager* password_manager, 53 PasswordFormManager(PasswordManager* password_manager,
56 PasswordManagerClient* client, 54 PasswordManagerClient* client,
57 const base::WeakPtr<PasswordManagerDriver>& driver, 55 const base::WeakPtr<PasswordManagerDriver>& driver,
58 const autofill::PasswordForm& observed_form, 56 const autofill::PasswordForm& observed_form,
59 std::unique_ptr<FormSaver> form_saver, 57 std::unique_ptr<FormSaver> form_saver,
60 FormFetcher* form_fetcher); 58 FormFetcher* form_fetcher);
59 ~PasswordFormManager() override;
61 60
62 // Flags describing the result of comparing two forms as performed by 61 // Flags describing the result of comparing two forms as performed by
63 // DoesMatch. Individual flags are only relevant for HTML forms, but 62 // DoesMatch. Individual flags are only relevant for HTML forms, but
64 // RESULT_COMPLETE_MATCH will also be returned to indicate non-HTML forms 63 // RESULT_COMPLETE_MATCH will also be returned to indicate non-HTML forms
65 // completely matching. 64 // completely matching.
66 // The ordering of these flags is important. Larger matches are more 65 // The ordering of these flags is important. Larger matches are more
67 // preferred than lower matches. That is, since RESULT_HTML_ATTRIBUTES_MATCH 66 // preferred than lower matches. That is, since RESULT_HTML_ATTRIBUTES_MATCH
68 // is greater than RESULT_ACTION_MATCH, a match of only attributes and not 67 // is greater than RESULT_ACTION_MATCH, a match of only attributes and not
69 // actions will be preferred to one of actions and not attributes. 68 // actions will be preferred to one of actions and not attributes.
70 enum MatchResultFlags { 69 enum MatchResultFlags {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // owned by the associated FormFetcher. This does not cause removing |this| as 248 // owned by the associated FormFetcher. This does not cause removing |this| as
250 // a consumer of |form_fetcher_|. 249 // a consumer of |form_fetcher_|.
251 void ResetStoredMatches(); 250 void ResetStoredMatches();
252 251
253 // Takes ownership of |fetcher|. If |fetcher| is different from the current 252 // Takes ownership of |fetcher|. If |fetcher| is different from the current
254 // |form_fetcher_| then also resets matches stored from the old fetcher and 253 // |form_fetcher_| then also resets matches stored from the old fetcher and
255 // adds itself as a consumer of the new one. 254 // adds itself as a consumer of the new one.
256 void GrabFetcher(std::unique_ptr<FormFetcher> fetcher); 255 void GrabFetcher(std::unique_ptr<FormFetcher> fetcher);
257 256
258 protected: 257 protected:
259 ~PasswordFormManager() override;
260
261 // FormFetcher::Consumer: 258 // FormFetcher::Consumer:
262 void ProcessMatches( 259 void ProcessMatches(
263 const std::vector<const autofill::PasswordForm*>& non_federated, 260 const std::vector<const autofill::PasswordForm*>& non_federated,
264 size_t filtered_count) override; 261 size_t filtered_count) override;
265 262
266 private: 263 private:
267 friend class base::RefCounted<PasswordFormManager>;
268
269 // ManagerAction - What does the manager do with this form? Either it 264 // ManagerAction - What does the manager do with this form? Either it
270 // fills it, or it doesn't. If it doesn't fill it, that's either 265 // fills it, or it doesn't. If it doesn't fill it, that's either
271 // because it has no match or it is disabled via the AUTOCOMPLETE=off 266 // because it has no match or it is disabled via the AUTOCOMPLETE=off
272 // attribute. Note that if we don't have an exact match, we still provide 267 // attribute. Note that if we don't have an exact match, we still provide
273 // candidates that the user may end up choosing. 268 // candidates that the user may end up choosing.
274 enum ManagerAction { 269 enum ManagerAction {
275 kManagerActionNone = 0, 270 kManagerActionNone = 0,
276 kManagerActionAutofilled, 271 kManagerActionAutofilled,
277 kManagerActionBlacklisted_Obsolete, 272 kManagerActionBlacklisted_Obsolete,
278 kManagerActionMax 273 kManagerActionMax
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 // True if the main frame's visible URL, at the time this PasswordFormManager 651 // True if the main frame's visible URL, at the time this PasswordFormManager
657 // was created, is secure. 652 // was created, is secure.
658 bool is_main_frame_secure_ = false; 653 bool is_main_frame_secure_ = false;
659 654
660 DISALLOW_COPY_AND_ASSIGN(PasswordFormManager); 655 DISALLOW_COPY_AND_ASSIGN(PasswordFormManager);
661 }; 656 };
662 657
663 } // namespace password_manager 658 } // namespace password_manager
664 659
665 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_FORM_MANAGER_H_ 660 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_FORM_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698