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

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

Issue 23432002: Generate passwords only for forms that autofill server marks as account creation forms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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 CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_GENERATION_MANAGER_H_ 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_GENERATION_MANAGER_H_
6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_GENERATION_MANAGER_H_ 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_GENERATION_MANAGER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/prefs/pref_change_registrar.h" 11 #include "base/prefs/pref_change_registrar.h"
12 #include "chrome/browser/sync/profile_sync_service_observer.h" 12 #include "chrome/browser/sync/profile_sync_service_observer.h"
13 #include "content/public/browser/web_contents_observer.h" 13 #include "content/public/browser/web_contents_observer.h"
14 #include "content/public/browser/web_contents_user_data.h" 14 #include "content/public/browser/web_contents_user_data.h"
15 #include "url/gurl.h"
15 16
16 namespace autofill { 17 namespace autofill {
18 class FormStructure;
17 class PasswordGenerator; 19 class PasswordGenerator;
18 } 20 }
19 21
20 namespace content { 22 namespace content {
21 struct PasswordForm; 23 struct PasswordForm;
22 } 24 }
23 25
24 namespace user_prefs { 26 namespace user_prefs {
25 class PrefRegistrySyncable; 27 class PrefRegistrySyncable;
26 } 28 }
(...skipping 15 matching lines...) Expand all
42 // if the user chooses to generate a password. 44 // if the user chooses to generate a password.
43 class PasswordGenerationManager 45 class PasswordGenerationManager
44 : public ProfileSyncServiceObserver, 46 : public ProfileSyncServiceObserver,
45 public content::WebContentsObserver, 47 public content::WebContentsObserver,
46 public content::WebContentsUserData<PasswordGenerationManager> { 48 public content::WebContentsUserData<PasswordGenerationManager> {
47 public: 49 public:
48 static void CreateForWebContents(content::WebContents* contents); 50 static void CreateForWebContents(content::WebContents* contents);
49 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 51 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
50 virtual ~PasswordGenerationManager(); 52 virtual ~PasswordGenerationManager();
51 53
54 // Detect account creation forms from forms with autofill type annotated.
55 void DetectAccountCreationForms(
56 const std::vector<autofill::FormStructure*>& forms);
57
52 protected: 58 protected:
53 explicit PasswordGenerationManager(content::WebContents* contents); 59 explicit PasswordGenerationManager(content::WebContents* contents);
54 60
55 private: 61 private:
56 friend class content::WebContentsUserData<PasswordGenerationManager>; 62 friend class content::WebContentsUserData<PasswordGenerationManager>;
57 friend class PasswordGenerationManagerTest; 63 friend class PasswordGenerationManagerTest;
58 64
59 // WebContentsObserver: 65 // WebContentsObserver:
60 virtual void RenderViewCreated(content::RenderViewHost* host) OVERRIDE; 66 virtual void RenderViewCreated(content::RenderViewHost* host) OVERRIDE;
61 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 67 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
(...skipping 12 matching lines...) Expand all
74 80
75 // Determines current state of password generation and sends this information 81 // Determines current state of password generation and sends this information
76 // to the renderer if it is different from |enabled_| or if |new_renderer| 82 // to the renderer if it is different from |enabled_| or if |new_renderer|
77 // is true. 83 // is true.
78 void UpdateState(content::RenderViewHost* host, bool new_renderer); 84 void UpdateState(content::RenderViewHost* host, bool new_renderer);
79 85
80 // Sends a message to the renderer enabling or disabling this feature. This 86 // Sends a message to the renderer enabling or disabling this feature. This
81 // is a separate function to aid in testing. 87 // is a separate function to aid in testing.
82 virtual void SendStateToRenderer(content::RenderViewHost* host, bool enabled); 88 virtual void SendStateToRenderer(content::RenderViewHost* host, bool enabled);
83 89
90 virtual void SendAccountCreationFormsToRenderer(
91 content::RenderViewHost* host, const std::vector<GURL>& origins);
92
84 // Causes the password generation bubble UI to be shown for the specified 93 // Causes the password generation bubble UI to be shown for the specified
85 // form. The popup will be anchored at |icon_bounds|. The generated 94 // form. The popup will be anchored at |icon_bounds|. The generated
86 // password will be no longer than |max_length|. 95 // password will be no longer than |max_length|.
87 void OnShowPasswordGenerationPopup(const gfx::Rect& icon_bounds, 96 void OnShowPasswordGenerationPopup(const gfx::Rect& icon_bounds,
88 int max_length, 97 int max_length,
89 const content::PasswordForm& form); 98 const content::PasswordForm& form);
90 99
91 // Whether password generation is enabled. 100 // Whether password generation is enabled.
92 bool enabled_; 101 bool enabled_;
93 102
94 // Listens for changes to the state of the password generation pref. 103 // Listens for changes to the state of the password generation pref.
95 PrefChangeRegistrar registrar_; 104 PrefChangeRegistrar registrar_;
96 105
97 // For vending a weak_ptr for |registrar_|. 106 // For vending a weak_ptr for |registrar_|.
98 base::WeakPtrFactory<PasswordGenerationManager> weak_factory_; 107 base::WeakPtrFactory<PasswordGenerationManager> weak_factory_;
99 108
100 // Controls how passwords are generated. 109 // Controls how passwords are generated.
101 scoped_ptr<autofill::PasswordGenerator> password_generator_; 110 scoped_ptr<autofill::PasswordGenerator> password_generator_;
102 111
103 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationManager); 112 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationManager);
104 }; 113 };
105 114
106 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_GENERATION_MANAGER_H_ 115 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_GENERATION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698