|
| 1 | +// Copyright 2022 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +#include "firebase/app_check/debug_provider.h" |
| 16 | + |
| 17 | +// Include the header that matches the platform being used. |
| 18 | +#if FIREBASE_PLATFORM_ANDROID |
| 19 | +#include "app_check/src/android/debug_provider_android.h" |
| 20 | +#elif FIREBASE_PLATFORM_IOS || FIREBASE_PLATFORM_TVOS |
| 21 | +#include "app_check/src/ios/debug_provider_ios.h" |
| 22 | +#else |
| 23 | +#include "app_check/src/desktop/debug_provider_desktop.h" |
| 24 | +#endif // FIREBASE_PLATFORM_ANDROID, FIREBASE_PLATFORM_IOS, |
| 25 | + // FIREBASE_PLATFORM_TVOS |
| 26 | + |
| 27 | +namespace firebase { |
| 28 | +namespace app_check { |
| 29 | + |
| 30 | +static DebugAppCheckProviderFactory* g_debug_app_check_provider_factory = |
| 31 | + nullptr; |
| 32 | + |
| 33 | +DebugAppCheckProviderFactory* DebugAppCheckProviderFactory::GetInstance() { |
| 34 | + if (!g_debug_app_check_provider_factory) { |
| 35 | + g_debug_app_check_provider_factory = new DebugAppCheckProviderFactory(); |
| 36 | + } |
| 37 | + return g_debug_app_check_provider_factory; |
| 38 | +} |
| 39 | + |
| 40 | +DebugAppCheckProviderFactory::DebugAppCheckProviderFactory() |
| 41 | + : internal_(new internal::DebugAppCheckProviderFactoryInternal()) {} |
| 42 | + |
| 43 | +DebugAppCheckProviderFactory::~DebugAppCheckProviderFactory() { |
| 44 | + if (internal_) { |
| 45 | + delete internal_; |
| 46 | + internal_ = nullptr; |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +AppCheckProvider* DebugAppCheckProviderFactory::CreateProvider(App* app) { |
| 51 | + if (internal_) { |
| 52 | + return internal_->CreateProvider(app); |
| 53 | + } |
| 54 | + return nullptr; |
| 55 | +} |
| 56 | + |
| 57 | +} // namespace app_check |
| 58 | +} // namespace firebase |
0 commit comments