Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / chrome / browser / browsing_data / browsing_data_local_storage_helper.h
blobd279bbbbd66ec99c6b5f8665410e001fd6c11cd9
1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_LOCAL_STORAGE_HELPER_H_
6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_LOCAL_STORAGE_HELPER_H_
8 #include <list>
9 #include <set>
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/files/file_path.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/time/time.h"
16 #include "content/public/browser/dom_storage_context.h"
17 #include "url/gurl.h"
19 class Profile;
21 // This class fetches local storage information and provides a
22 // means to delete the data associated with an origin.
23 class BrowsingDataLocalStorageHelper
24 : public base::RefCounted<BrowsingDataLocalStorageHelper> {
25 public:
26 // Contains detailed information about local storage.
27 struct LocalStorageInfo {
28 LocalStorageInfo(
29 const GURL& origin_url,
30 int64 size,
31 base::Time last_modified);
32 ~LocalStorageInfo();
34 GURL origin_url;
35 int64 size;
36 base::Time last_modified;
39 using FetchCallback =
40 base::Callback<void(const std::list<LocalStorageInfo>&)>;
42 explicit BrowsingDataLocalStorageHelper(Profile* profile);
44 // Starts the fetching process, which will notify its completion via
45 // callback. This must be called only in the UI thread.
46 virtual void StartFetching(const FetchCallback& callback);
48 // Deletes the local storage for the |origin|.
49 virtual void DeleteOrigin(const GURL& origin);
51 protected:
52 friend class base::RefCounted<BrowsingDataLocalStorageHelper>;
53 virtual ~BrowsingDataLocalStorageHelper();
55 content::DOMStorageContext* dom_storage_context_; // Owned by the profile
57 private:
58 DISALLOW_COPY_AND_ASSIGN(BrowsingDataLocalStorageHelper);
61 // This class is a thin wrapper around BrowsingDataLocalStorageHelper that does
62 // not fetch its information from the local storage tracker, but gets them
63 // passed as a parameter during construction.
64 class CannedBrowsingDataLocalStorageHelper
65 : public BrowsingDataLocalStorageHelper {
66 public:
67 explicit CannedBrowsingDataLocalStorageHelper(Profile* profile);
69 // Add a local storage to the set of canned local storages that is returned
70 // by this helper.
71 void AddLocalStorage(const GURL& origin);
73 // Clear the list of canned local storages.
74 void Reset();
76 // True if no local storages are currently stored.
77 bool empty() const;
79 // Returns the number of local storages currently stored.
80 size_t GetLocalStorageCount() const;
82 // Returns the set of origins that use local storage.
83 const std::set<GURL>& GetLocalStorageInfo() const;
85 // BrowsingDataLocalStorageHelper implementation.
86 void StartFetching(const FetchCallback& callback) override;
87 void DeleteOrigin(const GURL& origin) override;
89 private:
90 ~CannedBrowsingDataLocalStorageHelper() override;
92 std::set<GURL> pending_local_storage_info_;
94 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataLocalStorageHelper);
97 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_LOCAL_STORAGE_HELPER_H_