OLD | NEW |
| (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 // NOT DEAD CODE! | |
6 // This code isn't dead, even if it isn't currently being used. Please refer to: | |
7 // https://www.chromium.org/developers/how-tos/compact-language-detector-cld-dat
a-source-configuration | |
8 | |
9 #ifndef COMPONENTS_TRANSLATE_CONTENT_BROWSER_BROWSER_CLD_DATA_PROVIDER_FACTORY_H
_ | |
10 #define COMPONENTS_TRANSLATE_CONTENT_BROWSER_BROWSER_CLD_DATA_PROVIDER_FACTORY_H
_ | |
11 | |
12 #include <memory> | |
13 | |
14 #include "base/macros.h" | |
15 #include "components/translate/content/browser/browser_cld_data_provider.h" | |
16 | |
17 namespace content { | |
18 class WebContents; | |
19 } | |
20 | |
21 namespace translate { | |
22 | |
23 // A factory for the Browser side of CLD Data Providers. The embedder should | |
24 // set an instance as soon as feasible during startup. The browser process will | |
25 // use this factory to create the one BrowserCldDataProvider for each render | |
26 // view host in order to communicate with a RendererCldDataProvider in the | |
27 // renderer process. For more information on the RendererCldDataProvider, see: | |
28 // ../renderer/renderer_cld_data_provider.h | |
29 class BrowserCldDataProviderFactory { | |
30 public: | |
31 BrowserCldDataProviderFactory() {} | |
32 virtual ~BrowserCldDataProviderFactory() {} | |
33 | |
34 // Create and return a new instance of a BrowserCldDataProvider. The default | |
35 // implementation of this method produces a no-op BrowserCldDataProvider that | |
36 // is suitable only when CLD data has been statically linked. | |
37 // Every invocation creates a new provider; the caller is responsible for | |
38 // deleting the object when it is no longer needed. | |
39 virtual std::unique_ptr<BrowserCldDataProvider> CreateBrowserCldDataProvider( | |
40 content::WebContents* web_contents); | |
41 | |
42 // Returns true if and only if the current instance for this process is not | |
43 // NULL. | |
44 static bool IsInitialized(); | |
45 | |
46 // Sets the default factory for this process, i.e. the factory to be used | |
47 // unless the embedder calls Set(BrowserCldDataProviderFactory*). This is the | |
48 // method that normal (i.e., non-test) Chromium code should use; embedders can | |
49 // and should use the unconditional Set(BrowserCldDataProviderFactory*) method | |
50 // instead. If a default factory has already been set, this method does | |
51 // nothing. | |
52 static void SetDefault(BrowserCldDataProviderFactory* instance); | |
53 | |
54 // Unconditionally sets the factory for this process, overwriting any | |
55 // previously-configured default. Normal Chromium code should never use this | |
56 // method; it is provided for embedders to inject a factory from outside of | |
57 // the Chromium code base. Test code can also use this method to force the | |
58 // runtime to have a desired behavior. | |
59 static void Set(BrowserCldDataProviderFactory* instance); | |
60 | |
61 // Returns the instance of the factory previously set by Set()/SetDefault(). | |
62 // If no instance has been set, a default factory will be returned that | |
63 // produces no-op BrowserCldDataProviders as described by | |
64 // CreateBrowserCldDataProvider(...) above. | |
65 static BrowserCldDataProviderFactory* Get(); | |
66 | |
67 private: | |
68 DISALLOW_COPY_AND_ASSIGN(BrowserCldDataProviderFactory); | |
69 }; | |
70 | |
71 } // namespace translate | |
72 | |
73 #endif // COMPONENTS_TRANSLATE_CONTENT_BROWSER_BROWSER_CLD_DATA_PROVIDER_FACTOR
Y_H_ | |
OLD | NEW |