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

Unified 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, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/permissions/chooser_context_base.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/permissions/chooser_context_base.h
diff --git a/chrome/browser/permissions/chooser_context_base.h b/chrome/browser/permissions/chooser_context_base.h
new file mode 100644
index 0000000000000000000000000000000000000000..2d984b0a7e2781b241695860c0e51059c01d6676
--- /dev/null
+++ b/chrome/browser/permissions/chooser_context_base.h
@@ -0,0 +1,76 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_PERMISSIONS_CHOOSER_CONTEXT_BASE_H_
+#define CHROME_BROWSER_PERMISSIONS_CHOOSER_CONTEXT_BASE_H_
+
+#include <string>
+
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_vector.h"
+#include "components/content_settings/core/common/content_settings_types.h"
+#include "components/keyed_service/core/keyed_service.h"
+
+namespace base {
+class DictionaryValue;
+class Value;
+}
+
+class GURL;
+class HostContentSettingsMap;
+class Profile;
+
+// This is the base class for services that manage any type of permission that
+// is granted through a chooser-style UI instead of a simple allow/deny prompt.
+// Subclasses must define the structure of the objects that are stored.
+class ChooserContextBase : public KeyedService {
+ public:
+ ChooserContextBase(Profile* profile,
+ ContentSettingsType permission_type,
+ ContentSettingsType chooser_type);
+ ~ChooserContextBase() override;
+
+ // Returns the list of objects that |requesting_origin| has been granted
+ // permission to access when embedded within |embedding_origin|.
+ //
+ // This method may be extended by a subclass to return objects not stored in
+ // |host_content_settings_map_|.
+ 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.
+ const GURL& requesting_origin,
+ const GURL& embedding_origin);
+
+ // Grants |requesting_origin| access to |object| when embedded within
+ // |embedding_origin| by writing it into |host_content_settings_map_|.
+ void GrantObjectPermission(const GURL& requesting_origin,
+ const GURL& embedding_origin,
+ scoped_ptr<base::DictionaryValue> object);
+
+ // Revokes |requesting_origin|'s permission to access |object| when embedded
+ // within |embedding_origin|.
+ //
+ // This method may be extended by a subclass to be revoke permission for
+ // objects returned by GetPreviouslyChosenObjects but not stored in
+ // |host_content_settings_map_|.
+ virtual void RevokeObjectPermission(const GURL& requesting_origin,
+ const GURL& embedding_origin,
+ const base::DictionaryValue& object);
+
+ // Validates the structure of an object read from
+ // |host_content_settings_map_|.
+ virtual bool IsValidObject(const base::DictionaryValue& object) = 0;
+
+ private:
+ scoped_ptr<base::DictionaryValue> GetWebsiteSetting(
+ const GURL& requesting_origin,
+ const GURL& embedding_origin);
+ void SetWebsiteSetting(const GURL& requesting_origin,
+ const GURL& embedding_origin,
+ scoped_ptr<base::Value> value);
+
+ HostContentSettingsMap* const host_content_settings_map_;
+ const ContentSettingsType permission_type_;
+ const ContentSettingsType chooser_type_;
+};
+
+#endif // CHROME_BROWSER_PERMISSIONS_CHOOSER_CONTEXT_BASE_H_
« 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