Roll src/third_party/WebKit f36d5e0:68b67cd (svn 193299:193303)
[chromium-blink-merge.git] / components / translate / content / renderer / renderer_cld_data_provider_factory.h
blob3cc7fa22372f6aa58346d260c6fcb3196c136dae
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.
5 #ifndef COMPONENTS_TRANSLATE_CONTENT_RENDERER_RENDERER_CLD_DATA_PROVIDER_FACTORY_H_
6 #define COMPONENTS_TRANSLATE_CONTENT_RENDERER_RENDERER_CLD_DATA_PROVIDER_FACTORY_H_
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "components/translate/content/renderer/renderer_cld_data_provider.h"
12 namespace content {
13 class RenderViewObserver;
16 namespace translate {
18 // A factory for the Renderer side of CLD Data Providers. The embedder should
19 // set an instance as soon as feasible during startup. The renderer process will
20 // use this factory to create the one RendererCldDataProvider for each render
21 // view in order to communicate with a BrowserCldDataProvider in the browser
22 // process. For more information on the RendererCldDataProvider, see:
23 // ../renderer/renderer_cld_data_provider.h
24 class RendererCldDataProviderFactory {
25 public:
26 RendererCldDataProviderFactory() {}
27 virtual ~RendererCldDataProviderFactory() {}
29 // Create and return a new instance of a RendererCldDataProvider. The default
30 // implementation of this method produces a no-op RendererCldDataProvider that
31 // is suitable only when CLD data has been statically linked.
32 // Every invocation creates a new provider; the caller is responsible for
33 // deleting the object when it is no longer needed.
34 virtual scoped_ptr<RendererCldDataProvider> CreateRendererCldDataProvider(
35 content::RenderViewObserver* render_view_observer);
37 // Returns true if and only if the current instance for this process is not
38 // NULL.
39 static bool IsInitialized();
41 // Sets the default factory for this process, i.e. the factory to be used
42 // unless the embedder calls Set(RendererCldDataProviderFactory*). This is the
43 // method that normal (i.e., non-test) Chromium code should use; embedders can
44 // and should use the unconditional Set(RendererCldDataProviderFactory*)
45 // method instead. If a default factory has already been set, this method does
46 // nothing.
47 static void SetDefault(RendererCldDataProviderFactory* instance);
49 // Unconditionally sets the factory for this process, overwriting any
50 // previously-configured default. Normal Chromium code should never use this
51 // method; it is provided for embedders to inject a factory from outside of
52 // the Chromium code base. Test code can also use this method to force the
53 // runtime to have a desired behavior.
54 static void Set(RendererCldDataProviderFactory* instance);
56 // Returns the instance of the factory previously set by Set()/SetDefault().
57 // If no instance has been set, a default factory will be returned that
58 // produces no-op RendererCldDataProviders as described by
59 // CreateRendererCldDataProvider(...) above.
60 static RendererCldDataProviderFactory* Get();
62 private:
63 DISALLOW_COPY_AND_ASSIGN(RendererCldDataProviderFactory);
66 } // namespace translate
68 #endif // COMPONENTS_TRANSLATE_CONTENT_RENDERER_RENDERER_CLD_DATA_PROVIDER_FACTORY_H_