Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(690)

Unified Diff: media/base/media_resources.cc

Issue 1339183002: Add localized default audio device names. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initialize in run_all_unittests. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698