1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_GENERATION_MANAGER_H_ 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_GENERATION_MANAGER_H_ 7 8 #include <vector> 9 10 #include "base/basictypes.h" 11 12 namespace autofill { 13 class FormStructure; 14 } 15 16 namespace password_manager { 17 18 class PasswordManagerClient; 19 class PasswordManagerDriver; 20 21 // Per-tab manager for password generation. Will enable this feature only if 22 // 23 // - Password manager is enabled 24 // - Password sync is enabled 25 // 26 // NOTE: At the moment, the creation of the renderer PasswordGenerationManager 27 // is controlled by a switch (--enable-password-generation) so this feature will 28 // not be enabled regardless of the above criteria without the switch being 29 // present. 30 // 31 // This class is used to determine what forms we should offer to generate 32 // passwords for and manages the popup which is created if the user chooses to 33 // generate a password. 34 class PasswordGenerationManager { 35 public: 36 explicit PasswordGenerationManager(PasswordManagerClient* client); 37 virtual ~PasswordGenerationManager(); 38 39 // Detect account creation forms from forms with autofill type annotated. 40 // Will send a message to the renderer if we find a correctly annotated form 41 // and the feature is enabled. 42 void DetectAccountCreationForms( 43 const std::vector<autofill::FormStructure*>& forms); 44 45 private: 46 friend class PasswordGenerationManagerTest; 47 48 // Determines current state of password generation 49 bool IsGenerationEnabled() const; 50 51 // The PasswordManagerClient instance associated with this instance. Must 52 // outlive this instance. 53 PasswordManagerClient* client_; 54 55 // The PasswordManagerDriver instance associated with this instance. Must 56 // outlive this instance. 57 PasswordManagerDriver* driver_; 58 59 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationManager); 60 }; 61 62 } // namespace password_manager 63 64 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_GENERATION_MANAGER_H_ 65