~abreu-alexandre/webbrowser-app/cookie-manager

« back to all changes in this revision

Viewing changes to src/app/webcontainer/chrome-cookie-store.h

  • Committer: Alexandre Abreu
  • Date: 2014-08-14 02:17:08 UTC
  • mfrom: (667.1.1 latest)
  • Revision ID: alexandre.abreu@canonical.com-20140814021708-2ljy9g6byo7mgvkp
Handle cookie manager & cookie copies w/ Oxide

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
#include "cookie-store.h"
23
23
 
24
 
#include <QSqlDatabase>
 
24
#include <QString>
 
25
#include <QUrl>
 
26
 
25
27
 
26
28
class ChromeCookieStore : public CookieStore
27
29
{
28
30
    Q_OBJECT
 
31
    Q_ENUMS(RequestStatus)
 
32
 
 
33
    Q_PROPERTY(QUrl homepage READ homepage WRITE setHomepage NOTIFY homepageChanged)
29
34
    Q_PROPERTY(QString dbPath READ dbPath WRITE setDbPath NOTIFY dbPathChanged)
 
35
    Q_PROPERTY(QObject* oxideStoreBackend READ oxideStoreBackend WRITE setOxideStoreBackend NOTIFY oxideStoreBackendChanged)
30
36
 
31
37
public:
 
38
 
 
39
    // Possibly not the best way to do it, but mimics some oxide public API
 
40
    // definition in order to make the type known to the QML type system so
 
41
    // that the QObject can be called by string.
 
42
    enum RequestStatus {
 
43
      RequestStatusOK,
 
44
      RequestStatusError,
 
45
      RequestStatusInternalFailure,
 
46
    };
 
47
 
32
48
    ChromeCookieStore(QObject* parent = 0);
33
49
 
 
50
    // dbpaths
34
51
    void setDbPath(const QString& path);
35
52
    QString dbPath() const;
36
53
 
 
54
    // dbpaths
 
55
    void setHomepage(const QUrl& path);
 
56
    QUrl homepage() const;
 
57
 
 
58
    // oxideStoreBackend
 
59
    void setOxideStoreBackend(QObject* backend);
 
60
    QObject* oxideStoreBackend() const;
 
61
 
 
62
    // CookieStore overrides
37
63
    QDateTime lastUpdateTimeStamp() const Q_DECL_OVERRIDE;
38
64
 
39
65
Q_SIGNALS:
40
66
    void dbPathChanged();
41
 
 
42
 
private:
43
 
    virtual Cookies doGetCookies() Q_DECL_OVERRIDE;
44
 
    virtual bool doSetCookies(const Cookies& cookies) Q_DECL_OVERRIDE;
45
 
 
46
 
    bool createDb();
47
 
 
48
 
private:
 
67
    void oxideStoreBackendChanged();
 
68
    void homepageChanged();
 
69
 
 
70
private Q_SLOTS:
 
71
    void oxideCookiesReceived(int requestId, const QVariant& cookies, RequestStatus status);
 
72
    void oxideCookiesUpdated(int requestId, RequestStatus status);
 
73
 
 
74
private:
 
75
    virtual void doGetCookies() Q_DECL_OVERRIDE;
 
76
    virtual void doSetCookies(const Cookies& cookies) Q_DECL_OVERRIDE;
 
77
 
 
78
private:
 
79
    QObject* m_backend;
 
80
    QUrl m_homepage;
49
81
    QString m_dbPath;
50
 
    QSqlDatabase m_db;
51
82
};
52
83
 
53
84
#endif // CHROME_COOKIE_STORE_H