summaryrefslogtreecommitdiffstats
path: root/webkit/quota/mock_special_storage_policy.h
blob: 6f0ec1319f96b18a7b5b476a63b098a045aa340c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef WEBKIT_QUOTA_MOCK_SPECIAL_STORAGE_POLICY_H_
#define WEBKIT_QUOTA_MOCK_SPECIAL_STORAGE_POLICY_H_

#include <set>
#include <string>
#include "googleurl/src/gurl.h"
#include "webkit/quota/special_storage_policy.h"

namespace quota {

class MockSpecialStoragePolicy : public quota::SpecialStoragePolicy {
 public:
  MockSpecialStoragePolicy();
  virtual ~MockSpecialStoragePolicy();

  virtual bool IsStorageProtected(const GURL& origin);
  virtual bool IsStorageUnlimited(const GURL& origin);
  virtual bool IsStorageSessionOnly(const GURL& origin);
  virtual bool IsFileHandler(const std::string& extension_id);
  virtual bool HasSessionOnlyOrigins();

  void AddProtected(const GURL& origin) {
    protected_.insert(origin);
  }

  void AddUnlimited(const GURL& origin) {
    unlimited_.insert(origin);
  }

  void AddSessionOnly(const GURL& origin) {
    session_only_.insert(origin);
  }

  void AddFileHandler(const std::string& id) {
    file_handlers_.insert(id);
  }

  void SetAllUnlimited(bool all_unlimited) {
      all_unlimited_ = all_unlimited;
  }

  void Reset() {
    protected_.clear();
    unlimited_.clear();
    session_only_.clear();
    file_handlers_.clear();
    all_unlimited_ = false;
  }

  void NotifyChanged() {
    SpecialStoragePolicy::NotifyObservers();
  }

 private:
  std::set<GURL> protected_;
  std::set<GURL> unlimited_;
  std::set<GURL> session_only_;
  std::set<std::string> file_handlers_;

  bool all_unlimited_;
};
}  // namespace quota

#endif  // WEBKIT_QUOTA_MOCK_SPECIAL_STORAGE_POLICY_H_