Rename desktop_cursor_loader_updater_aurax11.
[chromium-blink-merge.git] / chrome / browser / managed_mode / managed_mode_site_list.h
blob558dd464c5148fe1e8db115cac72702098baaa9e
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_MANAGED_MODE_MANAGED_MODE_SITE_LIST_H_
6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_SITE_LIST_H_
8 #include <string>
9 #include <vector>
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"
15 #include "extensions/common/extension_resource.h"
17 class ExtensionServiceInterface;
18 class Profile;
20 namespace base {
21 class DictionaryValue;
22 class ListValue;
25 namespace extensions {
26 class Extension;
29 // This class represents a "site list" that is part of a content pack. It is
30 // loaded from a JSON file inside the extension bundle, which defines the sites
31 // on the list.
32 // Every site has -- among other attributes -- a whitelist of URLs that are
33 // required to use it. All sites from all installed content packs together with
34 // their respective whitelists are combined in the ManagedModeURLFilter, which
35 // can tell for a given URL if it is part of the whitelist for any site.
36 // Effectively, ManagedModeURLFilter then acts as a big whitelist which is the
37 // union of the whitelists in all sites in all content packs. See
38 // http://goo.gl/cBCB8 for a diagram.
39 class ManagedModeSiteList {
40 public:
41 struct Site {
42 Site(const string16& name, int category_id);
43 ~Site();
45 // The human-readable name for the site.
46 string16 name;
48 // An identifier for the category. Categories are hardcoded and start with
49 // 1, but apart from the offset correspond to the return values from
50 // GetCategoryNames() below.
51 int category_id;
53 // A list of URL patterns that should be whitelisted for the site.
54 std::vector<std::string> patterns;
56 // A list of SHA1 hashes of hostnames that should be whitelisted
57 // for the site.
58 std::vector<std::string> hostname_hashes;
61 ManagedModeSiteList(const std::string& extension_id,
62 const extensions::ExtensionResource& path);
63 ~ManagedModeSiteList();
65 // Creates a copy of the site list.
66 // Caller takes ownership of the returned value.
67 ManagedModeSiteList* Clone();
69 // Returns a list of all categories.
70 // TODO(bauerb): The list is hardcoded for now, but if we allow custom
71 // categories, this should live in some registry.
72 static void GetCategoryNames(std::vector<string16>* categories);
74 // Returns a list of all sites in this site list.
75 void GetSites(std::vector<Site>* sites);
77 private:
78 bool LazyLoad();
79 void CopyThumbnailUrl(const base::DictionaryValue* source,
80 base::DictionaryValue* dest);
82 std::string extension_id_;
83 extensions::ExtensionResource path_;
84 scoped_ptr<base::DictionaryValue> categories_;
85 scoped_ptr<base::ListValue> sites_;
87 DISALLOW_COPY_AND_ASSIGN(ManagedModeSiteList);
90 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_SITE_LIST_H_