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

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

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

Powered by Google App Engine
This is Rietveld 408576698