OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_SITE_LIST_H_ | 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SITE_LIST_H_ |
6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_SITE_LIST_H_ | 6 #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SITE_LIST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 | 15 |
16 class Profile; | 16 class Profile; |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 class DictionaryValue; | 19 class DictionaryValue; |
20 class ListValue; | 20 class ListValue; |
21 } | 21 } |
22 | 22 |
23 // This class represents a "site list" that is part of a content pack. It is | 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 | 24 // loaded from a JSON file inside the extension bundle, which defines the sites |
25 // on the list. | 25 // on the list. |
26 // Every site has -- among other attributes -- a whitelist of URLs that are | 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 | 27 // required to use it. All sites from all installed content packs together with |
28 // their respective whitelists are combined in the ManagedModeURLFilter, which | 28 // their respective whitelists are combined in the SupervisedUserURLFilter, |
29 // can tell for a given URL if it is part of the whitelist for any site. | 29 // which can tell for a given URL if it is part of the whitelist for any site. |
30 // Effectively, ManagedModeURLFilter then acts as a big whitelist which is the | 30 // Effectively, SupervisedUserURLFilter then acts as a big whitelist which is |
31 // union of the whitelists in all sites in all content packs. See | 31 // the union of the whitelists in all sites in all content packs. See |
32 // http://goo.gl/cBCB8 for a diagram. | 32 // http://goo.gl/cBCB8 for a diagram. |
33 class ManagedModeSiteList { | 33 class SupervisedUserSiteList { |
34 public: | 34 public: |
35 struct Site { | 35 struct Site { |
36 Site(const base::string16& name, int category_id); | 36 Site(const base::string16& name, int category_id); |
37 ~Site(); | 37 ~Site(); |
38 | 38 |
39 // The human-readable name for the site. | 39 // The human-readable name for the site. |
40 base::string16 name; | 40 base::string16 name; |
41 | 41 |
42 // An identifier for the category. Categories are hardcoded and start with | 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 | 43 // 1, but apart from the offset correspond to the return values from |
44 // GetCategoryNames() below. | 44 // GetCategoryNames() below. |
45 int category_id; | 45 int category_id; |
46 | 46 |
47 // A list of URL patterns that should be whitelisted for the site. | 47 // A list of URL patterns that should be whitelisted for the site. |
48 std::vector<std::string> patterns; | 48 std::vector<std::string> patterns; |
49 | 49 |
50 // A list of SHA1 hashes of hostnames that should be whitelisted | 50 // A list of SHA1 hashes of hostnames that should be whitelisted |
51 // for the site. | 51 // for the site. |
52 std::vector<std::string> hostname_hashes; | 52 std::vector<std::string> hostname_hashes; |
53 }; | 53 }; |
54 | 54 |
55 ManagedModeSiteList(const std::string& extension_id, | 55 SupervisedUserSiteList(const std::string& extension_id, |
56 const base::FilePath& path); | 56 const base::FilePath& path); |
57 ~ManagedModeSiteList(); | 57 ~SupervisedUserSiteList(); |
58 | 58 |
59 // Creates a copy of the site list. | 59 // Creates a copy of the site list. |
60 // Caller takes ownership of the returned value. | 60 // Caller takes ownership of the returned value. |
61 ManagedModeSiteList* Clone(); | 61 SupervisedUserSiteList* Clone(); |
62 | 62 |
63 // Returns a list of all categories. | 63 // Returns a list of all categories. |
64 // TODO(bauerb): The list is hardcoded for now, but if we allow custom | 64 // TODO(bauerb): The list is hardcoded for now, but if we allow custom |
65 // categories, this should live in some registry. | 65 // categories, this should live in some registry. |
66 static void GetCategoryNames(std::vector<base::string16>* categories); | 66 static void GetCategoryNames(std::vector<base::string16>* categories); |
67 | 67 |
68 // Returns a list of all sites in this site list. | 68 // Returns a list of all sites in this site list. |
69 void GetSites(std::vector<Site>* sites); | 69 void GetSites(std::vector<Site>* sites); |
70 | 70 |
71 private: | 71 private: |
72 bool LazyLoad(); | 72 bool LazyLoad(); |
73 void CopyThumbnailUrl(const base::DictionaryValue* source, | 73 void CopyThumbnailUrl(const base::DictionaryValue* source, |
74 base::DictionaryValue* dest); | 74 base::DictionaryValue* dest); |
75 | 75 |
76 std::string extension_id_; | 76 std::string extension_id_; |
77 base::FilePath path_; | 77 base::FilePath path_; |
78 scoped_ptr<base::DictionaryValue> categories_; | 78 scoped_ptr<base::DictionaryValue> categories_; |
79 scoped_ptr<base::ListValue> sites_; | 79 scoped_ptr<base::ListValue> sites_; |
80 | 80 |
81 DISALLOW_COPY_AND_ASSIGN(ManagedModeSiteList); | 81 DISALLOW_COPY_AND_ASSIGN(SupervisedUserSiteList); |
82 }; | 82 }; |
83 | 83 |
84 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_SITE_LIST_H_ | 84 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SITE_LIST_H_ |
OLD | NEW |