OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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_context.h" |
| 6 |
| 7 #include "chrome/browser/bluetooth/bluetooth_permission_context.h" |
| 8 #include "chrome/browser/bluetooth/bluetooth_permission_context_factory.h" |
| 9 #include "chrome/browser/permissions/chooser_context_base.h" |
| 10 #include "content/public/browser/permission_type.h" |
| 11 |
| 12 using content::PermissionType; |
| 13 |
| 14 // static |
| 15 ChooserContextBase* ChooserContext::Get(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::BLUETOOTH: |
| 21 return BluetoothPermissionContextFactory::GetForProfile(profile); |
| 22 default: |
| 23 NOTREACHED() << "No ChooserContext associated with " |
| 24 << static_cast<int>(permission_type); |
| 25 break; |
| 26 } |
| 27 |
| 28 return nullptr; |
| 29 } |
| 30 |
| 31 // static |
| 32 const std::list<KeyedServiceBaseFactory*>& ChooserContext::GetFactories() { |
| 33 // NOTE: this list has to stay in sync with the factories used by ::Get(). |
| 34 CR_DEFINE_STATIC_LOCAL(std::list<KeyedServiceBaseFactory*>, factories, ()); |
| 35 |
| 36 if (factories.empty()) { |
| 37 factories.push_back(BluetoothPermissionContextFactory::GetInstance()); |
| 38 } |
| 39 |
| 40 return factories; |
| 41 } |
OLD | NEW |