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

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 <base/memory/ref_counted.h>
vasilii 2017/05/29 13:15:48 Should go down
kolos1 2017/05/29 15:47:06 Done.
8 #include <stdint.h> 9 #include <stdint.h>
9 10
10 #include <map> 11 #include <map>
11 #include <memory> 12 #include <memory>
12 #include <string> 13 #include <string>
13 #include <vector> 14 #include <vector>
14 15
15 #include "base/macros.h" 16 #include "base/macros.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;
30 using base::RefCounted;
vasilii 2017/05/29 13:15:48 Seems mostly not used.
kolos1 2017/05/29 15:47:06 Removed.
29 31
30 namespace password_manager { 32 namespace password_manager {
31 33
32 class FormSaver; 34 class FormSaver;
33 class PasswordManager; 35 class PasswordManager;
34 class PasswordManagerClient; 36 class PasswordManagerClient;
35 37
36 // A map from field names to field types. 38 // A map from field names to field types.
37 using FieldTypeMap = std::map<base::string16, autofill::ServerFieldType>; 39 using FieldTypeMap = std::map<base::string16, autofill::ServerFieldType>;
38 40
39 // This class helps with filling the observed form (both HTML and from HTTP 41 // This class helps with filling the observed form (both HTML and from HTTP
40 // auth) and with saving/updating the stored information about it. 42 // auth) and with saving/updating the stored information about it.
41 class PasswordFormManager : public FormFetcher::Consumer { 43 class PasswordFormManager : public FormFetcher::Consumer,
44 public RefCounted<PasswordFormManager> {
42 public: 45 public:
43 // |password_manager| owns |this|, |client| and |driver| serve to 46 // |password_manager| owns |this|, |client| and |driver| serve to
44 // communicate with embedder, |observed_form| is the associated form |this| 47 // communicate with embedder, |observed_form| is the associated form |this|
45 // is managing, |form_saver| is used to save/update the form and 48 // 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 49 // |form_fetcher| to get saved data about the form. |form_fetcher| must not be
47 // destroyed before |this|. 50 // destroyed before |this|.
48 // 51 //
49 // TODO(crbug.com/621355): So far, |form_fetcher| can be null. In that case 52 // 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 53 // |this| creates an instance of it itself (meant for production code). Once
51 // the fetcher is shared between PasswordFormManager instances, it will be 54 // the fetcher is shared between PasswordFormManager instances, it will be
52 // required that |form_fetcher| is not null. 55 // required that |form_fetcher| is not null.
53 PasswordFormManager(PasswordManager* password_manager, 56 PasswordFormManager(PasswordManager* password_manager,
54 PasswordManagerClient* client, 57 PasswordManagerClient* client,
55 const base::WeakPtr<PasswordManagerDriver>& driver, 58 const base::WeakPtr<PasswordManagerDriver>& driver,
56 const autofill::PasswordForm& observed_form, 59 const autofill::PasswordForm& observed_form,
57 std::unique_ptr<FormSaver> form_saver, 60 std::unique_ptr<FormSaver> form_saver,
58 FormFetcher* form_fetcher); 61 FormFetcher* form_fetcher);
59 ~PasswordFormManager() override;
60 62
61 // Flags describing the result of comparing two forms as performed by 63 // Flags describing the result of comparing two forms as performed by
62 // DoesMatch. Individual flags are only relevant for HTML forms, but 64 // DoesMatch. Individual flags are only relevant for HTML forms, but
63 // RESULT_COMPLETE_MATCH will also be returned to indicate non-HTML forms 65 // RESULT_COMPLETE_MATCH will also be returned to indicate non-HTML forms
64 // completely matching. 66 // completely matching.
65 // The ordering of these flags is important. Larger matches are more 67 // The ordering of these flags is important. Larger matches are more
66 // preferred than lower matches. That is, since RESULT_HTML_ATTRIBUTES_MATCH 68 // 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 69 // 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. 70 // actions will be preferred to one of actions and not attributes.
69 enum MatchResultFlags { 71 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 250 // owned by the associated FormFetcher. This does not cause removing |this| as
249 // a consumer of |form_fetcher_|. 251 // a consumer of |form_fetcher_|.
250 void ResetStoredMatches(); 252 void ResetStoredMatches();
251 253
252 // Takes ownership of |fetcher|. If |fetcher| is different from the current 254 // Takes ownership of |fetcher|. If |fetcher| is different from the current
253 // |form_fetcher_| then also resets matches stored from the old fetcher and 255 // |form_fetcher_| then also resets matches stored from the old fetcher and
254 // adds itself as a consumer of the new one. 256 // adds itself as a consumer of the new one.
255 void GrabFetcher(std::unique_ptr<FormFetcher> fetcher); 257 void GrabFetcher(std::unique_ptr<FormFetcher> fetcher);
256 258
257 protected: 259 protected:
260 ~PasswordFormManager() override;
261
258 // FormFetcher::Consumer: 262 // FormFetcher::Consumer:
259 void ProcessMatches( 263 void ProcessMatches(
260 const std::vector<const autofill::PasswordForm*>& non_federated, 264 const std::vector<const autofill::PasswordForm*>& non_federated,
261 size_t filtered_count) override; 265 size_t filtered_count) override;
262 266
263 private: 267 private:
268 friend class base::RefCounted<PasswordFormManager>;
vasilii 2017/05/29 13:15:48 What is the point in making a base class friend?
kolos1 2017/05/29 15:47:06 It is required for using RefCounted (https://cs.ch
269
264 // ManagerAction - What does the manager do with this form? Either it 270 // 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 271 // 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 272 // 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 273 // attribute. Note that if we don't have an exact match, we still provide
268 // candidates that the user may end up choosing. 274 // candidates that the user may end up choosing.
269 enum ManagerAction { 275 enum ManagerAction {
270 kManagerActionNone = 0, 276 kManagerActionNone = 0,
271 kManagerActionAutofilled, 277 kManagerActionAutofilled,
272 kManagerActionBlacklisted_Obsolete, 278 kManagerActionBlacklisted_Obsolete,
273 kManagerActionMax 279 kManagerActionMax
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 // True if the main frame's visible URL, at the time this PasswordFormManager 649 // True if the main frame's visible URL, at the time this PasswordFormManager
644 // was created, is secure. 650 // was created, is secure.
645 bool is_main_frame_secure_ = false; 651 bool is_main_frame_secure_ = false;
646 652
647 DISALLOW_COPY_AND_ASSIGN(PasswordFormManager); 653 DISALLOW_COPY_AND_ASSIGN(PasswordFormManager);
648 }; 654 };
649 655
650 } // namespace password_manager 656 } // namespace password_manager
651 657
652 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_FORM_MANAGER_H_ 658 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_FORM_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698