blob: 3655f5e3e282390671f0dba5e1984f3d620fcfa5 [file] [log] [blame]
gogerald6d16ea52017-04-13 20:43:281// Copyright 2017 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_PAYMENTS_ANDROID_PAYMENT_METHOD_MANIFEST_TABLE_H_
6#define COMPONENTS_PAYMENTS_ANDROID_PAYMENT_METHOD_MANIFEST_TABLE_H_
7
8#include <string>
9#include <vector>
10
11#include "components/webdata/common/web_database.h"
12#include "components/webdata/common/web_database_table.h"
13
14namespace payments {
15
16// This class manages payment_method_manifest table in SQLite database. It
17// expects the following schema.
18//
19// payment_method_manifest The table stores WebAppManifestSection.id of the
20// supported web app in this payment method manifest.
21// Note that a payment method manifest might contain
22// multiple supported web apps ids.
gogerald69a1f752017-04-27 21:18:0723//
24// expire_date The expire date in seconds from 1601-01-01 00:00:00
25// UTC.
gogerald6d16ea52017-04-13 20:43:2826// method_name The method name.
27// web_app_id The supported web app id.
28// (WebAppManifestSection.id).
29//
30class PaymentMethodManifestTable : public WebDatabaseTable {
31 public:
32 PaymentMethodManifestTable();
33 ~PaymentMethodManifestTable() override;
34
35 // Retrieves the PaymentMethodManifestTable* owned by |db|.
36 static PaymentMethodManifestTable* FromWebDatabase(WebDatabase* db);
37
38 // WebDatabaseTable:
39 WebDatabaseTable::TypeKey GetTypeKey() const override;
40 bool CreateTablesIfNecessary() override;
41 bool IsSyncable() override;
42 bool MigrateToVersion(int version, bool* update_compatible_version) override;
43
gogerald69a1f752017-04-27 21:18:0744 // Remove expired data.
45 void RemoveExpiredData();
46
gogerald6d16ea52017-04-13 20:43:2847 // Adds |payment_method|'s manifest. |web_app_ids| contains supported web apps
48 // ids.
49 bool AddManifest(const std::string& payment_method,
50 const std::vector<std::string>& web_app_ids);
51
52 // Gets manifest for |payment_method|. Return empty vector if no manifest
53 // exists for this method.
54 std::vector<std::string> GetManifest(const std::string& payment_method);
55
56 private:
57 DISALLOW_COPY_AND_ASSIGN(PaymentMethodManifestTable);
58};
59
60} // namespace payments
61
62#endif // COMPONENTS_PAYMENTS_ANDROID_PAYMENT_METHOD_MANIFEST_TABLE_H_