| Index: chrome/browser/permissions/chooser_context.cc
|
| diff --git a/chrome/browser/permissions/chooser_context.cc b/chrome/browser/permissions/chooser_context.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..108f6ed72798e3de2330c821b02396de4823418a
|
| --- /dev/null
|
| +++ b/chrome/browser/permissions/chooser_context.cc
|
| @@ -0,0 +1,46 @@
|
| +// 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_context.h"
|
| +
|
| +#include "base/logging.h"
|
| +#include "chrome/browser/permissions/chooser_type.h"
|
| +
|
| +#if !defined(OS_ANDROID)
|
| +#include "chrome/browser/usb/usb_chooser_context.h"
|
| +#include "chrome/browser/usb/usb_chooser_context_factory.h"
|
| +#endif
|
| +
|
| +// static
|
| +ChooserContextBase* ChooserContext::Get(Profile* profile,
|
| + ChooserType chooser_type) {
|
| + // NOTE: the factories used in this method have to stay in sync with
|
| + // ::GetFactories() below.
|
| + switch (chooser_type) {
|
| +#if !defined(OS_ANDROID)
|
| + case ChooserType::USB:
|
| + return UsbChooserContextFactory::GetForProfile(profile);
|
| +#endif
|
| + default:
|
| + NOTREACHED() << "No ChooserContext associated with "
|
| + << static_cast<int>(chooser_type);
|
| + break;
|
| + }
|
| +
|
| + return nullptr;
|
| +}
|
| +
|
| +// static
|
| +const std::list<KeyedServiceBaseFactory*>& ChooserContext::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()) {
|
| +#if !defined(OS_ANDROID)
|
| + factories.push_back(UsbChooserContextFactory::GetInstance());
|
| +#endif
|
| + }
|
| +
|
| + return factories;
|
| +}
|
|
|