Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: chrome/browser/permissions/chooser_context_base.h

Issue 1382783002: Store USB device permissions in website settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed ChooserType for now. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/permissions/chooser_context_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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.
4
5 #ifndef CHROME_BROWSER_PERMISSIONS_CHOOSER_CONTEXT_BASE_H_
6 #define CHROME_BROWSER_PERMISSIONS_CHOOSER_CONTEXT_BASE_H_
7
8 #include <string>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/scoped_vector.h"
12 #include "components/content_settings/core/common/content_settings_types.h"
13 #include "components/keyed_service/core/keyed_service.h"
14
15 namespace base {
16 class DictionaryValue;
17 class Value;
18 }
19
20 class GURL;
21 class HostContentSettingsMap;
22 class Profile;
23
24 // This is the base class for services that manage any type of permission that
25 // is granted through a chooser-style UI instead of a simple allow/deny prompt.
26 // Subclasses must define the structure of the objects that are stored.
27 class ChooserContextBase : public KeyedService {
28 public:
29 ChooserContextBase(Profile* profile,
30 ContentSettingsType permission_type,
31 ContentSettingsType chooser_type);
32 ~ChooserContextBase() override;
33
34 // Returns the list of objects that |requesting_origin| has been granted
35 // permission to access when embedded within |embedding_origin|.
36 //
37 // This method may be extended by a subclass to return objects not stored in
38 // |host_content_settings_map_|.
39 virtual ScopedVector<base::DictionaryValue> GetPreviouslyChosenObjects(
raymes 2015/11/02 03:00:13 This and the function below weren't virtual in the
Reilly Grant (use Gerrit) 2015/11/02 21:14:51 Done.
40 const GURL& requesting_origin,
41 const GURL& embedding_origin);
42
43 // Grants |requesting_origin| access to |object| when embedded within
44 // |embedding_origin| by writing it into |host_content_settings_map_|.
45 void GrantObjectPermission(const GURL& requesting_origin,
46 const GURL& embedding_origin,
47 scoped_ptr<base::DictionaryValue> object);
48
49 // Revokes |requesting_origin|'s permission to access |object| when embedded
50 // within |embedding_origin|.
51 //
52 // This method may be extended by a subclass to be revoke permission for
53 // objects returned by GetPreviouslyChosenObjects but not stored in
54 // |host_content_settings_map_|.
55 virtual void RevokeObjectPermission(const GURL& requesting_origin,
56 const GURL& embedding_origin,
57 const base::DictionaryValue& object);
58
59 // Validates the structure of an object read from
60 // |host_content_settings_map_|.
61 virtual bool IsValidObject(const base::DictionaryValue& object) = 0;
62
63 private:
64 scoped_ptr<base::DictionaryValue> GetWebsiteSetting(
65 const GURL& requesting_origin,
66 const GURL& embedding_origin);
67 void SetWebsiteSetting(const GURL& requesting_origin,
68 const GURL& embedding_origin,
69 scoped_ptr<base::Value> value);
70
71 HostContentSettingsMap* const host_content_settings_map_;
72 const ContentSettingsType permission_type_;
73 const ContentSettingsType chooser_type_;
74 };
75
76 #endif // CHROME_BROWSER_PERMISSIONS_CHOOSER_CONTEXT_BASE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/permissions/chooser_context_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698