| 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_RENDERER_RENDERER_CLD_DATA_PROVIDER_FACTORY
_H_ | |
| 10 #define COMPONENTS_TRANSLATE_CONTENT_RENDERER_RENDERER_CLD_DATA_PROVIDER_FACTORY
_H_ | |
| 11 | |
| 12 #include <memory> | |
| 13 | |
| 14 #include "base/macros.h" | |
| 15 #include "components/translate/content/renderer/renderer_cld_data_provider.h" | |
| 16 | |
| 17 namespace content { | |
| 18 class RenderFrameObserver; | |
| 19 } | |
| 20 | |
| 21 namespace translate { | |
| 22 | |
| 23 // A factory for the Renderer side of CLD Data Providers. The embedder should | |
| 24 // set an instance as soon as feasible during startup. The renderer process will | |
| 25 // use this factory to create the one RendererCldDataProvider for each render | |
| 26 // view in order to communicate with a BrowserCldDataProvider in the browser | |
| 27 // process. For more information on the RendererCldDataProvider, see: | |
| 28 // ../renderer/renderer_cld_data_provider.h | |
| 29 class RendererCldDataProviderFactory { | |
| 30 public: | |
| 31 RendererCldDataProviderFactory() {} | |
| 32 virtual ~RendererCldDataProviderFactory() {} | |
| 33 | |
| 34 // Create and return a new instance of a RendererCldDataProvider. The default | |
| 35 // implementation of this method produces a no-op RendererCldDataProvider 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<RendererCldDataProvider> | |
| 40 CreateRendererCldDataProvider( | |
| 41 content::RenderFrameObserver* render_frame_observer); | |
| 42 | |
| 43 // Returns true if and only if the current instance for this process is not | |
| 44 // NULL. | |
| 45 static bool IsInitialized(); | |
| 46 | |
| 47 // Sets the default factory for this process, i.e. the factory to be used | |
| 48 // unless the embedder calls Set(RendererCldDataProviderFactory*). This is the | |
| 49 // method that normal (i.e., non-test) Chromium code should use; embedders can | |
| 50 // and should use the unconditional Set(RendererCldDataProviderFactory*) | |
| 51 // method instead. If a default factory has already been set, this method does | |
| 52 // nothing. | |
| 53 static void SetDefault(RendererCldDataProviderFactory* instance); | |
| 54 | |
| 55 // Unconditionally sets the factory for this process, overwriting any | |
| 56 // previously-configured default. Normal Chromium code should never use this | |
| 57 // method; it is provided for embedders to inject a factory from outside of | |
| 58 // the Chromium code base. Test code can also use this method to force the | |
| 59 // runtime to have a desired behavior. | |
| 60 static void Set(RendererCldDataProviderFactory* instance); | |
| 61 | |
| 62 // Returns the instance of the factory previously set by Set()/SetDefault(). | |
| 63 // If no instance has been set, a default factory will be returned that | |
| 64 // produces no-op RendererCldDataProviders as described by | |
| 65 // CreateRendererCldDataProvider(...) above. | |
| 66 static RendererCldDataProviderFactory* Get(); | |
| 67 | |
| 68 private: | |
| 69 DISALLOW_COPY_AND_ASSIGN(RendererCldDataProviderFactory); | |
| 70 }; | |
| 71 | |
| 72 } // namespace translate | |
| 73 | |
| 74 #endif // COMPONENTS_TRANSLATE_CONTENT_RENDERER_RENDERER_CLD_DATA_PROVIDER_FACT
ORY_H_ | |
| OLD | NEW |