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

Side by Side Diff: components/translate/content/renderer/renderer_cld_data_provider.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/lazy_instance.h"
6 #include "components/translate/content/renderer/renderer_cld_data_provider.h"
7
8 namespace {
9
10 // Our global default instance, alive for the entire lifetime of the process.
11 translate::RendererCldDataProvider* g_instance = NULL;
12
13 // The default factory, which produces no-op instances of
14 // RendererCldDataProvider suitable for use when CLD data is statically-linked.
15 base::LazyInstance<translate::RendererCldDataProvider>::Leaky
16 g_wrapped_default = LAZY_INSTANCE_INITIALIZER;
17
18 } // namespace
19
20
21 namespace translate {
22
23 bool RendererCldDataProvider::IsCldDataAvailable() {
24 return true;
25 }
26
27 bool RendererCldDataProvider::OnMessageReceived(const IPC::Message& message) {
28 return false; // Message not handled
29 }
30
31 void RendererCldDataProvider::SetCldAvailableCallback
32 (base::Callback<void(void)> callback) {
33 callback.Run();
34 }
35
36 // static
37 void RendererCldDataProvider::SetDefault(
38 RendererCldDataProvider* instance) {
39 if (!IsInitialized()) Set(instance);
40 }
41
42 // static
43 void RendererCldDataProvider::Set(
44 RendererCldDataProvider* instance) {
45 g_instance = instance;
46 }
47
48 // static
49 bool RendererCldDataProvider::IsInitialized() {
50 return g_instance != NULL;
51 }
52
53 // static
54 RendererCldDataProvider* RendererCldDataProvider::Get() {
55 if (IsInitialized()) return g_instance;
56 return &g_wrapped_default.Get();
57 }
58
59 } // namespace translate
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698