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_context.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "chrome/browser/permissions/chooser_type.h" |
| 9 |
| 10 #if !defined(OS_ANDROID) |
| 11 #include "chrome/browser/usb/usb_chooser_context.h" |
| 12 #include "chrome/browser/usb/usb_chooser_context_factory.h" |
| 13 #endif |
| 14 |
| 15 // static |
| 16 ChooserContextBase* ChooserContext::Get(Profile* profile, |
| 17 ChooserType chooser_type) { |
| 18 // NOTE: the factories used in this method have to stay in sync with |
| 19 // ::GetFactories() below. |
| 20 switch (chooser_type) { |
| 21 #if !defined(OS_ANDROID) |
| 22 case ChooserType::USB: |
| 23 return UsbChooserContextFactory::GetForProfile(profile); |
| 24 #endif |
| 25 default: |
| 26 NOTREACHED() << "No ChooserContext associated with " |
| 27 << static_cast<int>(chooser_type); |
| 28 break; |
| 29 } |
| 30 |
| 31 return nullptr; |
| 32 } |
| 33 |
| 34 // static |
| 35 const std::list<KeyedServiceBaseFactory*>& ChooserContext::GetFactories() { |
| 36 // NOTE: this list has to stay in sync with the factories used by ::Get(). |
| 37 CR_DEFINE_STATIC_LOCAL(std::list<KeyedServiceBaseFactory*>, factories, ()); |
| 38 |
| 39 if (factories.empty()) { |
| 40 #if !defined(OS_ANDROID) |
| 41 factories.push_back(UsbChooserContextFactory::GetInstance()); |
| 42 #endif |
| 43 } |
| 44 |
| 45 return factories; |
| 46 } |
OLD | NEW |