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_
11 #include "base/files/file_path.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_vector.h"
19 class DictionaryValue
;
23 // This class represents a "site list" that is part of a content pack. It is
24 // loaded from a JSON file inside the extension bundle, which defines the sites
26 // Every site has -- among other attributes -- a whitelist of URLs that are
27 // required to use it. All sites from all installed content packs together with
28 // their respective whitelists are combined in the SupervisedUserURLFilter,
29 // which can tell for a given URL if it is part of the whitelist for any site.
30 // Effectively, SupervisedUserURLFilter then acts as a big whitelist which is
31 // the union of the whitelists in all sites in all content packs. See
32 // http://goo.gl/cBCB8 for a diagram.
33 class SupervisedUserSiteList
{
36 Site(const base::string16
& name
, int category_id
);
39 // The human-readable name for the site.
42 // An identifier for the category. Categories are hardcoded and start with
43 // 1, but apart from the offset correspond to the return values from
44 // GetCategoryNames() below.
47 // A list of URL patterns that should be whitelisted for the site.
48 std::vector
<std::string
> patterns
;
50 // A list of SHA1 hashes of hostnames that should be whitelisted
52 std::vector
<std::string
> hostname_hashes
;
55 SupervisedUserSiteList(const std::string
& extension_id
,
56 const base::FilePath
& path
);
57 ~SupervisedUserSiteList();
59 // Creates a copy of the site list.
60 // Caller takes ownership of the returned value.
61 SupervisedUserSiteList
* Clone();
63 // Returns a list of all categories.
64 // TODO(bauerb): The list is hardcoded for now, but if we allow custom
65 // categories, this should live in some registry.
66 static void GetCategoryNames(std::vector
<base::string16
>* categories
);
68 // Returns a list of all sites in this site list.
69 void GetSites(std::vector
<Site
>* sites
);
73 void CopyThumbnailUrl(const base::DictionaryValue
* source
,
74 base::DictionaryValue
* dest
);
76 std::string extension_id_
;
78 scoped_ptr
<base::DictionaryValue
> categories_
;
79 scoped_ptr
<base::ListValue
> sites_
;
81 DISALLOW_COPY_AND_ASSIGN(SupervisedUserSiteList
);
84 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SITE_LIST_H_