OLD | NEW |
(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 #include "chrome/browser/permissions/chooser_permission_context.h" |
| 6 |
| 7 #include "chrome/browser/usb/usb_chooser_permission_context.h" |
| 8 #include "chrome/browser/usb/usb_chooser_permission_context_factory.h" |
| 9 #include "content/public/browser/permission_type.h" |
| 10 |
| 11 using content::PermissionType; |
| 12 |
| 13 // static |
| 14 ChooserPermissionContextBase* ChooserPermissionContext::Get( |
| 15 Profile* profile, |
| 16 PermissionType permission_type) { |
| 17 // NOTE: the factories used in this method have to stay in sync with |
| 18 // ::GetFactories() below. |
| 19 switch (permission_type) { |
| 20 case PermissionType::USB: |
| 21 return UsbChooserPermissionContextFactory::GetForProfile(profile); |
| 22 default: |
| 23 NOTREACHED() << "No ChooserPermissionContext associated with " |
| 24 << static_cast<int>(permission_type); |
| 25 break; |
| 26 } |
| 27 |
| 28 return nullptr; |
| 29 } |
| 30 |
| 31 // static |
| 32 const std::list<KeyedServiceBaseFactory*>& |
| 33 ChooserPermissionContext::GetFactories() { |
| 34 // NOTE: this list has to stay in sync with the factories used by ::Get(). |
| 35 CR_DEFINE_STATIC_LOCAL(std::list<KeyedServiceBaseFactory*>, factories, ()); |
| 36 |
| 37 if (factories.empty()) { |
| 38 factories.push_back(UsbChooserPermissionContextFactory::GetInstance()); |
| 39 } |
| 40 |
| 41 return factories; |
| 42 } |
OLD | NEW |