Home | History | Annotate | Download | only in browser
      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_MANAGER_DRIVER_H_
      6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_DRIVER_H_
      7 
      8 #include <vector>
      9 
     10 #include "base/macros.h"
     11 #include "base/strings/string16.h"
     12 
     13 namespace autofill {
     14 class AutofillManager;
     15 struct FormData;
     16 struct PasswordForm;
     17 struct PasswordFormFillData;
     18 }  // namespace autofill
     19 
     20 namespace password_manager {
     21 
     22 class PasswordAutofillManager;
     23 class PasswordGenerationManager;
     24 class PasswordManager;
     25 
     26 // Interface that allows PasswordManager core code to interact with its driver
     27 // (i.e., obtain information from it and give information to it).
     28 class PasswordManagerDriver {
     29  public:
     30   PasswordManagerDriver() {}
     31   virtual ~PasswordManagerDriver() {}
     32 
     33   // Fills forms matching |form_data|.
     34   virtual void FillPasswordForm(
     35       const autofill::PasswordFormFillData& form_data) = 0;
     36 
     37   // Returns whether any SSL certificate errors were encountered as a result of
     38   // the last page load.
     39   virtual bool DidLastPageLoadEncounterSSLErrors() = 0;
     40 
     41   // If this browsing session should not be persisted.
     42   virtual bool IsOffTheRecord() = 0;
     43 
     44   // Informs the driver that |form| can be used for password generation.
     45   virtual void AllowPasswordGenerationForForm(autofill::PasswordForm* form) = 0;
     46 
     47   // Notifies the driver that account creation |forms| were found.
     48   virtual void AccountCreationFormsFound(
     49       const std::vector<autofill::FormData>& forms) = 0;
     50 
     51   // Tells the driver to fill the form with the |username| and |password|.
     52   virtual void FillSuggestion(const base::string16& username,
     53                               const base::string16& password) = 0;
     54 
     55   // Tells the driver to preview filling form with the |username| and
     56   // |password|.
     57   virtual void PreviewSuggestion(const base::string16& username,
     58                                  const base::string16& password) = 0;
     59 
     60   // Tells the driver to clear previewed password and username fields.
     61   virtual void ClearPreviewedForm() = 0;
     62 
     63   // Returns the PasswordGenerationManager associated with this instance.
     64   virtual PasswordGenerationManager* GetPasswordGenerationManager() = 0;
     65 
     66   // Returns the PasswordManager associated with this instance.
     67   virtual PasswordManager* GetPasswordManager() = 0;
     68 
     69   // Returns the PasswordAutofillManager associated with this instance.
     70   virtual PasswordAutofillManager* GetPasswordAutofillManager() = 0;
     71 
     72   // Returns the AutofillManager associated with this instance.
     73   virtual autofill::AutofillManager* GetAutofillManager() = 0;
     74 
     75  private:
     76   DISALLOW_COPY_AND_ASSIGN(PasswordManagerDriver);
     77 };
     78 
     79 }  // namespace password_manager
     80 
     81 #endif  // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_DRIVER_H_
     82