BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / supervised_user / supervised_user_site_list.h
blob014611e64ff8dfc3199d7aafaa4175b069b161a9
1 // Copyright 2014 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_SUPERVISED_USER_SUPERVISED_USER_SITE_LIST_H_
6 #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SITE_LIST_H_
8 #include <string>
9 #include <vector>
11 #include "base/callback_forward.h"
12 #include "base/files/file_path.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/time/time.h"
17 class Profile;
19 namespace base {
20 class DictionaryValue;
21 class ListValue;
22 class Value;
25 // This class represents a "site list" that is part of a content pack. It is
26 // loaded from a JSON file inside the extension bundle, which defines the sites
27 // on the list.
28 // Every site has -- among other attributes -- a whitelist of URLs that are
29 // required to use it. All sites from all installed content packs together with
30 // their respective whitelists are combined in the SupervisedUserURLFilter,
31 // which can tell for a given URL if it is part of the whitelist for any site.
32 // Effectively, SupervisedUserURLFilter then acts as a big whitelist which is
33 // the union of the whitelists in all sites in all content packs. See
34 // http://goo.gl/cBCB8 for a diagram.
35 class SupervisedUserSiteList
36 : public base::RefCountedThreadSafe<SupervisedUserSiteList> {
37 public:
38 typedef base::Callback<void(const scoped_refptr<SupervisedUserSiteList>&)>
39 LoadedCallback;
41 struct Site {
42 explicit Site(const base::string16& name);
43 ~Site();
45 // The human-readable name for the site.
46 base::string16 name;
48 // A list of URL patterns that should be whitelisted for the site.
49 std::vector<std::string> patterns;
51 // A list of hex-encoded SHA1 hashes of hostnames that should be whitelisted
52 // for the site.
53 std::vector<std::string> hostname_hashes;
55 // Copying and assignment is allowed.
58 // Asynchronously loads the site list from |file| and calls |callback| with
59 // the newly created object.
60 static void Load(const base::FilePath& file, const LoadedCallback& callback);
62 // Returns a list of all sites in this site list.
63 const std::vector<Site>& sites() const { return sites_; }
65 private:
66 friend class base::RefCountedThreadSafe<SupervisedUserSiteList>;
68 explicit SupervisedUserSiteList(const base::ListValue& sites);
69 ~SupervisedUserSiteList();
71 // Static private so it can access the private constructor.
72 static void OnJsonLoaded(
73 const base::FilePath& path,
74 base::TimeTicks start_time,
75 const SupervisedUserSiteList::LoadedCallback& callback,
76 scoped_ptr<base::Value> value);
78 std::vector<Site> sites_;
80 DISALLOW_COPY_AND_ASSIGN(SupervisedUserSiteList);
83 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SITE_LIST_H_