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

Unified Diff: chrome/browser/permissions/chooser_permission_context.cc

Issue 1382783002: Store USB device permissions in website settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove UsbPermissionContext and add ChooserPermissionContext helper functions. 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
Index: chrome/browser/permissions/chooser_permission_context.cc
diff --git a/chrome/browser/permissions/chooser_permission_context.cc b/chrome/browser/permissions/chooser_permission_context.cc
new file mode 100644
index 0000000000000000000000000000000000000000..431000ebd1ad6dee8fc0a41ad92fe85015464878
--- /dev/null
+++ b/chrome/browser/permissions/chooser_permission_context.cc
@@ -0,0 +1,42 @@
+// 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.
+
+#include "chrome/browser/permissions/chooser_permission_context.h"
+
+#include "chrome/browser/usb/usb_chooser_permission_context.h"
+#include "chrome/browser/usb/usb_chooser_permission_context_factory.h"
+#include "content/public/browser/permission_type.h"
+
+using content::PermissionType;
+
+// static
+ChooserPermissionContextBase* ChooserPermissionContext::Get(
+ Profile* profile,
+ PermissionType permission_type) {
+ // NOTE: the factories used in this method have to stay in sync with
+ // ::GetFactories() below.
+ switch (permission_type) {
+ case PermissionType::USB:
+ return UsbChooserPermissionContextFactory::GetForProfile(profile);
+ default:
+ NOTREACHED() << "No ChooserPermissionContext associated with "
+ << static_cast<int>(permission_type);
+ break;
+ }
+
+ return nullptr;
+}
+
+// static
+const std::list<KeyedServiceBaseFactory*>&
+ChooserPermissionContext::GetFactories() {
+ // NOTE: this list has to stay in sync with the factories used by ::Get().
+ CR_DEFINE_STATIC_LOCAL(std::list<KeyedServiceBaseFactory*>, factories, ());
+
+ if (factories.empty()) {
+ factories.push_back(UsbChooserPermissionContextFactory::GetInstance());
+ }
+
+ return factories;
+}

Powered by Google App Engine
This is Rietveld 408576698