Home | History | Annotate | Download | only in browser
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_
      6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_
      7 
      8 #include <vector>
      9 
     10 #include "base/callback_forward.h"
     11 #include "base/i18n/rtl.h"
     12 #include "base/memory/weak_ptr.h"
     13 #include "base/strings/string16.h"
     14 
     15 namespace gfx {
     16 class Rect;
     17 class RectF;
     18 }
     19 
     20 class GURL;
     21 class InfoBarService;
     22 class PrefService;
     23 
     24 namespace autofill {
     25 
     26 class AutofillMetrics;
     27 class AutofillPopupDelegate;
     28 class AutofillWebDataService;
     29 class CreditCard;
     30 class FormStructure;
     31 class PasswordGenerator;
     32 class PersonalDataManager;
     33 struct FormData;
     34 struct PasswordForm;
     35 
     36 // A delegate interface that needs to be supplied to AutofillManager
     37 // by the embedder.
     38 //
     39 // Each delegate instance is associated with a given context within
     40 // which an AutofillManager is used (e.g. a single tab), so when we
     41 // say "for the delegate" below, we mean "in the execution context the
     42 // delegate is associated with" (e.g. for the tab the AutofillManager is
     43 // attached to).
     44 class AutofillManagerDelegate {
     45  public:
     46   virtual ~AutofillManagerDelegate() {}
     47 
     48   // Gets the PersonalDataManager instance associated with the delegate.
     49   virtual PersonalDataManager* GetPersonalDataManager() = 0;
     50 
     51   // Gets the AutofillWebDataService instance associated with the delegate.
     52   virtual scoped_refptr<AutofillWebDataService> GetDatabase() = 0;
     53 
     54   // Gets the preferences associated with the delegate.
     55   virtual PrefService* GetPrefs() = 0;
     56 
     57   // Hides the associated request autocomplete dialog (if it exists).
     58   virtual void HideRequestAutocompleteDialog() = 0;
     59 
     60   // Causes the Autofill settings UI to be shown.
     61   virtual void ShowAutofillSettings() = 0;
     62 
     63   // Run |save_card_callback| if the credit card should be imported as personal
     64   // data. |metric_logger| can be used to log user actions.
     65   virtual void ConfirmSaveCreditCard(
     66       const AutofillMetrics& metric_logger,
     67       const base::Closure& save_card_callback) = 0;
     68 
     69   // Causes the dialog for request autocomplete feature to be shown.
     70   virtual void ShowRequestAutocompleteDialog(
     71       const FormData& form,
     72       const GURL& source_url,
     73       const base::Callback<void(const FormStructure*)>& callback) = 0;
     74 
     75   // Shows an Autofill popup with the given |values|, |labels|, |icons|, and
     76   // |identifiers| for the element at |element_bounds|. |delegate| will be
     77   // notified of popup events.
     78   virtual void ShowAutofillPopup(
     79       const gfx::RectF& element_bounds,
     80       base::i18n::TextDirection text_direction,
     81       const std::vector<base::string16>& values,
     82       const std::vector<base::string16>& labels,
     83       const std::vector<base::string16>& icons,
     84       const std::vector<int>& identifiers,
     85       base::WeakPtr<AutofillPopupDelegate> delegate) = 0;
     86 
     87   // Update the data list values shown by the Autofill popup, if visible.
     88   virtual void UpdateAutofillPopupDataListValues(
     89       const std::vector<base::string16>& values,
     90       const std::vector<base::string16>& labels) = 0;
     91 
     92   // Hide the Autofill popup if one is currently showing.
     93   virtual void HideAutofillPopup() = 0;
     94 
     95   // Whether the Autocomplete feature of Autofill should be enabled.
     96   virtual bool IsAutocompleteEnabled() = 0;
     97 
     98   // Pass the form structures to the password generation manager to detect
     99   // account creation forms.
    100   virtual void DetectAccountCreationForms(
    101       const std::vector<autofill::FormStructure*>& forms) = 0;
    102 };
    103 
    104 }  // namespace autofill
    105 
    106 #endif  // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_
    107