autofill_options_handler.h revision ddb351dbec246cf1fab5ec20d2d5520909041de1
1// Copyright (c) 2011 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 CHROME_BROWSER_UI_WEBUI_OPTIONS_AUTOFILL_OPTIONS_HANDLER_H_
6#define CHROME_BROWSER_UI_WEBUI_OPTIONS_AUTOFILL_OPTIONS_HANDLER_H_
7
8#include <string>
9
10#include "chrome/browser/autofill/personal_data_manager.h"
11#include "chrome/browser/ui/webui/options/options_ui.h"
12
13class DictionaryValue;
14class ListValue;
15
16class AutofillOptionsHandler : public OptionsPageUIHandler,
17                               public PersonalDataManager::Observer {
18 public:
19  AutofillOptionsHandler();
20  virtual ~AutofillOptionsHandler();
21
22  // OptionsPageUIHandler implementation.
23  virtual void GetLocalizedValues(DictionaryValue* localized_strings);
24  virtual void Initialize();
25  virtual void RegisterMessages();
26
27  // PersonalDataManager::Observer implementation.
28  virtual void OnPersonalDataLoaded();
29  virtual void OnPersonalDataChanged();
30
31 private:
32  // Loads the strings for the address and credit card overlays.
33  void SetAddressOverlayStrings(DictionaryValue* localized_strings);
34  void SetCreditCardOverlayStrings(DictionaryValue* localized_strings);
35
36  // Loads Autofill addresses and credit cards using the PersonalDataManager.
37  void LoadAutofillData();
38
39  // Removes an address from the PersonalDataManager.
40  // |args| - A string, the GUID of the address to remove.
41  void RemoveAddress(const ListValue* args);
42
43  // Removes a credit card from the PersonalDataManager.
44  // |args| - A string, the GUID of the credit card to remove.
45  void RemoveCreditCard(const ListValue* args);
46
47  // Requests profile data for a specific address. Calls into WebUI with the
48  // loaded profile data to open the address editor.
49  // |args| - A string, the GUID of the address to load.
50  void LoadAddressEditor(const ListValue* args);
51
52  // Requests profile data for a specific credit card. Calls into WebUI with the
53  // loaded profile data to open the credit card editor.
54  // |args| - A string, the GUID of the credit card to load.
55  void LoadCreditCardEditor(const ListValue* args);
56
57  // Adds or updates an address, depending on the GUID of the profile. If the
58  // GUID is empty, a new address is added to the WebDatabase; otherwise, the
59  // address with the matching GUID is updated. Called from WebUI.
60  // |args| - an array containing the GUID of the address followed by the
61  // address data.
62  void SetAddress(const ListValue* args);
63
64  // Adds or updates a credit card, depending on the GUID of the profile. If the
65  // GUID is empty, a new credit card is added to the WebDatabase; otherwise,
66  // the credit card with the matching GUID is updated. Called from WebUI.
67  // |args| - an array containing the GUID of the credit card followed by the
68  // credit card data.
69  void SetCreditCard(const ListValue* args);
70
71  // The personal data manager, used to load Autofill profiles and credit cards.
72  // Unowned pointer, may not be NULL.
73  PersonalDataManager* personal_data_;
74
75  DISALLOW_COPY_AND_ASSIGN(AutofillOptionsHandler);
76};
77
78#endif  // CHROME_BROWSER_UI_WEBUI_OPTIONS_AUTOFILL_OPTIONS_HANDLER_H_
79