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

Unified Diff: components/translate/content/renderer/renderer_cld_utils.cc

Issue 461633002: Refactor language detection logic to allow non-static CLD data sources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make some of the harness factory methods private Created 6 years, 1 month 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: components/translate/content/renderer/renderer_cld_utils.cc
diff --git a/components/translate/content/renderer/renderer_cld_utils.cc b/components/translate/content/renderer/renderer_cld_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..210b977af4188b4a0ffb830b3b4896fbb0634000
--- /dev/null
+++ b/components/translate/content/renderer/renderer_cld_utils.cc
@@ -0,0 +1,39 @@
+// Copyright 2014 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 "components/translate/content/renderer/renderer_cld_utils.h"
+
+#include "components/translate/content/common/cld_data_source.h"
+#include "components/translate/content/renderer/renderer_cld_data_provider.h"
+
+namespace translate {
+
+// static
+void RendererCldUtils::ConfigureDefaultDataProvider() {
+ if (!RendererCldDataProvider::IsInitialized()) {
+ RendererCldDataProvider* provider = NULL;
+ CldDataSource* data_source = NULL;
+
+ // Maintainers: Customize platform defaults here as necessary.
+ // It is appropriate to ifdef this code and customize per-platform.
+ //
+ // Remember to update GYP/GN dependencies of high-level targets as well:
+ // - For the NONE or STATIC data sources, depend upon
+ // third_party/cld_2/cld_2.gyp:cld2_static.
+ // - For the COMPONENT or STANDALONE data sources, depend upon
+ // third_party/cld_2/cld_2.gyp:cld2_dynamic.
+ // - For any other sources, the embedder should already have set a provider
+ // and so this code should never be invoked.
+ // -----------------------------------------------------------------------
+ provider = new RendererCldDataProvider();
+ data_source = CldDataSource::GetStaticDataSource();
+ // -----------------------------------------------------------------------
+
+ // Apply the values defined above
+ RendererCldDataProvider::SetDefault(provider);
+ CldDataSource::SetDefault(data_source);
+ }
+}
+
+} // namespace translate

Powered by Google App Engine
This is Rietveld 408576698