Chromium Code Reviews| Index: media/base/media_resources.cc |
| diff --git a/media/base/media_resources.cc b/media/base/media_resources.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..66f20ccc75b1274a3cc994ebe756b2b1b73a5a79 |
| --- /dev/null |
| +++ b/media/base/media_resources.cc |
| @@ -0,0 +1,29 @@ |
| +// 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 "base/lazy_instance.h" |
| +#include "base/strings/utf_string_conversions.h" |
| +#include "media/base/media_resources.h" |
| + |
| +namespace media { |
| + |
| +static base::LazyInstance<LocalizedStringProvider>::Leaky |
| + g_localized_string_provider = LAZY_INSTANCE_INITIALIZER; |
| + |
| +void SetLocalizedStringProvider(const LocalizedStringProvider& callback) { |
| + DCHECK(g_localized_string_provider == nullptr); |
|
ajm
2015/09/18 00:43:21
Not sure if this is a common pattern with LazyInst
|
| + g_localized_string_provider.Get() = callback; |
| +} |
| + |
| +std::string GetLocalizedStringUTF8(MessageId message_id) { |
| + return base::UTF16ToUTF8(GetLocalizedStringUTF16(message_id)); |
| +} |
| + |
| +base::string16 GetLocalizedStringUTF16(MessageId message_id) { |
| + return g_localized_string_provider == nullptr |
| + ? base::string16() |
| + : g_localized_string_provider.Get().Run(message_id); |
| +} |
| + |
| +} // namespace media |