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

Side by Side Diff: components/autofill/content/renderer/password_generation_agent.h

Issue 151503006: Re-land r248110 with ASAN error fixed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Punctuation Created 6 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_AUTOFILL_CONTENT_RENDERER_PASSWORD_GENERATION_AGENT_H_ 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_GENERATION_AGENT_H_
6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_GENERATION_AGENT_H_ 6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_GENERATION_AGENT_H_
7 7
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 16 matching lines...) Expand all
27 27
28 // This class is responsible for controlling communication for password 28 // This class is responsible for controlling communication for password
29 // generation between the browser (which shows the popup and generates 29 // generation between the browser (which shows the popup and generates
30 // passwords) and WebKit (shows the generation icon in the password field). 30 // passwords) and WebKit (shows the generation icon in the password field).
31 class PasswordGenerationAgent : public content::RenderViewObserver, 31 class PasswordGenerationAgent : public content::RenderViewObserver,
32 public blink::WebPasswordGeneratorClient { 32 public blink::WebPasswordGeneratorClient {
33 public: 33 public:
34 explicit PasswordGenerationAgent(content::RenderView* render_view); 34 explicit PasswordGenerationAgent(content::RenderView* render_view);
35 virtual ~PasswordGenerationAgent(); 35 virtual ~PasswordGenerationAgent();
36 36
37 // Returns true if the field being changed is one where a generated password
38 // is being offered. Updates the state of the popup if necessary.
39 bool TextDidChangeInTextField(const blink::WebInputElement& element);
40
37 protected: 41 protected:
38 // Returns true if this document is one that we should consider analyzing. 42 // Returns true if this document is one that we should consider analyzing.
39 // Virtual so that it can be overriden during testing. 43 // Virtual so that it can be overriden during testing.
40 virtual bool ShouldAnalyzeDocument(const blink::WebDocument& document) const; 44 virtual bool ShouldAnalyzeDocument(const blink::WebDocument& document) const;
41 45
42 // RenderViewObserver: 46 // RenderViewObserver:
43 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 47 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
44 48
49 // Use to force enable during testing.
50 void set_enabled(bool enabled) { enabled_ = enabled; }
51
45 private: 52 private:
46 // RenderViewObserver: 53 // RenderViewObserver:
47 virtual void DidFinishDocumentLoad(blink::WebFrame* frame) OVERRIDE; 54 virtual void DidFinishDocumentLoad(blink::WebFrame* frame) OVERRIDE;
48 virtual void DidFinishLoad(blink::WebFrame* frame) OVERRIDE; 55 virtual void DidFinishLoad(blink::WebFrame* frame) OVERRIDE;
56 virtual void FocusedNodeChanged(const blink::WebNode& node) OVERRIDE;
49 57
50 // WebPasswordGeneratorClient: 58 // WebPasswordGeneratorClient:
51 virtual void openPasswordGenerator(blink::WebInputElement& element) OVERRIDE; 59 virtual void openPasswordGenerator(blink::WebInputElement& element) OVERRIDE;
52 60
53 // Message handlers. 61 // Message handlers.
54 void OnFormNotBlacklisted(const PasswordForm& form); 62 void OnFormNotBlacklisted(const PasswordForm& form);
55 void OnPasswordAccepted(const base::string16& password); 63 void OnPasswordAccepted(const base::string16& password);
56 void OnAccountCreationFormsDetected( 64 void OnAccountCreationFormsDetected(
57 const std::vector<autofill::FormData>& forms); 65 const std::vector<autofill::FormData>& forms);
58 66
59 // Helper function to decide whether we should show password generation icon. 67 // Helper function to decide if |passwords_| contains password fields for
60 void MaybeShowIcon(); 68 // an account creation form. Sets |generation_element_| to the field that
69 // we want to trigger the generation UI on.
70 void DetermineGenerationElement();
71
72 // Show password generation UI anchored at |generation_element_|.
73 void ShowGenerationPopup();
74
75 // Show UI for editing a generated password at |generation_element_|.
76 void ShowEditingPopup();
77
78 // Hides a password generation popup if one exists.
79 void HidePopup();
61 80
62 content::RenderView* render_view_; 81 content::RenderView* render_view_;
63 82
64 // Stores the origin of the account creation form we detected. 83 // Stores the origin of the account creation form we detected.
65 scoped_ptr<PasswordForm> possible_account_creation_form_; 84 scoped_ptr<PasswordForm> possible_account_creation_form_;
66 85
67 // Stores the origins of the password forms confirmed not to be blacklisted 86 // Stores the origins of the password forms confirmed not to be blacklisted
68 // by the browser. A form can be blacklisted if a user chooses "never save 87 // by the browser. A form can be blacklisted if a user chooses "never save
69 // passwords for this site". 88 // passwords for this site".
70 std::vector<GURL> not_blacklisted_password_form_origins_; 89 std::vector<GURL> not_blacklisted_password_form_origins_;
71 90
72 // Stores each password form for which the Autofill server classifies one of 91 // Stores each password form for which the Autofill server classifies one of
73 // the form's fields as an ACCOUNT_CREATION_PASSWORD. These forms will 92 // the form's fields as an ACCOUNT_CREATION_PASSWORD. These forms will
74 // not be sent if the feature is disabled. 93 // not be sent if the feature is disabled.
75 std::vector<autofill::FormData> generation_enabled_forms_; 94 std::vector<autofill::FormData> generation_enabled_forms_;
76 95
77 std::vector<blink::WebInputElement> passwords_; 96 // Password elements that may be part of an account creation form.
97 std::vector<blink::WebInputElement> password_elements_;
98
99 // Element where we want to trigger password generation UI.
100 blink::WebInputElement generation_element_;
101
102 // If the password field at |generation_element_| contains a generated
103 // password.
104 bool password_is_generated_;
105
106 // True if a password was generated and the user edited it. Used for UMA
107 // stats.
108 bool password_edited_;
109
110 // If this feature is enabled. Controlled by Finch.
111 bool enabled_;
78 112
79 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationAgent); 113 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationAgent);
80 }; 114 };
81 115
82 } // namespace autofill 116 } // namespace autofill
83 117
84 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_GENERATION_AGENT_H_ 118 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_GENERATION_AGENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698