Expose the CLD data source in chrome://translate-internals

BUG=367239
TBR=toyoshim

Review URL: https://codereview.chromium.org/397623002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283550 0039d316-1c4b-4281-b951-d872f2087c98
parent 42df7673
......@@ -476,6 +476,10 @@
#
# For more information on switching the CLD2 data source, see:
# https://sites.google.com/a/chromium.org/dev/developers/how-tos/compact-language-detector-cld-data-source-configuration
#
# This string will be exposed in chrome://translate-internals under the
# heading "CLD Data Source". This allows easy determination of which
# data source the browser was built with.
'cld2_data_source%': 'static',
# Enable spell checker.
......@@ -2756,6 +2760,11 @@
['cld_version!=0', {
'defines': ['CLD_VERSION=<(cld_version)'],
}],
['cld_version==2', {
# This is used to populate the "CLD Data Source" field in:
# chrome://translate-internals
'defines': ['CLD2_DATA_SOURCE=<(cld2_data_source)'],
}],
['cld2_data_source=="static"', {
'defines': ['CLD_DATA_FROM_STATIC'],
}, {
......
......@@ -103,6 +103,10 @@ std::string CldComponentInstallerTraits::GetName() const {
}
void RegisterCldComponent(ComponentUpdateService* cus) {
// This log line is to help with determining which kind of provider has been
// configured. See also: chrome://translate-internals
VLOG(1) << "Registering CLD component with the component update service";
scoped_ptr<ComponentInstallerTraits> traits(
new CldComponentInstallerTraits());
// |cus| will take ownership of |installer| during installer->Register(cus).
......
......@@ -34,6 +34,10 @@ found in the LICENSE file.
<h2>CLD Version</h2>
<p i18n-content="cld-version"></p>
</section>
<section id="prefs-cld-data-source">
<h2>CLD Data Source</h2>
<p i18n-content="cld-data-source"></p>
</section>
</if>
</div>
<div>
......
......@@ -23,6 +23,11 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
// Macro stringification.
// https://gcc.gnu.org/onlinedocs/cpp/Stringification.html
#define XSTR(S) STR(S)
#define STR(S) #S
namespace {
// Sets the languages to |dict|. Each key is a language code and each value is
......@@ -63,16 +68,20 @@ content::WebUIDataSource* CreateTranslateInternalsHTMLSource() {
}
std::string cld_version = "";
std::string cld_data_source = "";
// The version strings are hardcoded here to avoid linking with the CLD
// library, see http://crbug.com/297777.
#if CLD_VERSION==1
cld_version = "1.6";
cld_data_source = "static"; // CLD1.x does not support dynamic data loading
#elif CLD_VERSION==2
cld_version = "2";
cld_data_source = std::string(XSTR(CLD2_DATA_SOURCE));
#else
NOTREACHED();
#endif
source->AddString("cld-version", cld_version);
source->AddString("cld-data-source", cld_data_source);
return source;
}
......
......@@ -40,6 +40,7 @@ namespace translate {
// hooking up this specific implementation for all of Chromium.
BrowserCldDataProvider* CreateBrowserCldDataProviderFor(
content::WebContents* web_contents) {
VLOG(1) << "Creating DataFileBrowserCldDataProvider";
return new DataFileBrowserCldDataProvider(web_contents);
}
......
......@@ -4,6 +4,7 @@
#include "static_browser_cld_data_provider.h"
#include "base/logging.h"
#include "content/public/browser/web_contents.h"
#include "ipc/ipc_message.h"
......@@ -13,6 +14,9 @@ namespace translate {
// hooking up this specific implementation for all of Chromium.
BrowserCldDataProvider* CreateBrowserCldDataProviderFor(
content::WebContents* web_contents) {
// This log line is to help with determining which kind of provider has been
// configured. See also: chrome://translate-internals
VLOG(1) << "Creating StaticBrowserCldDataProvider";
return new StaticBrowserCldDataProvider();
}
......
......@@ -8,6 +8,7 @@
#include "base/files/file.h"
#include "base/files/memory_mapped_file.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "components/translate/content/common/data_file_cld_data_provider_messages.h"
#include "content/public/renderer/render_view_observer.h"
#include "ipc/ipc_message.h"
......@@ -34,6 +35,9 @@ namespace translate {
// hooking up this specific implementation for all of Chromium.
RendererCldDataProvider* CreateRendererCldDataProviderFor(
content::RenderViewObserver* render_view_observer) {
// This log line is to help with determining which kind of provider has been
// configured. See also: chrome://translate-internals
VLOG(1) << "Creating DataFileRendererCldDataProvider";
return new DataFileRendererCldDataProvider(render_view_observer);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment