Chromium Code Reviews| Index: components/translate/content/browser/browser_cld_data_provider_factory.h |
| diff --git a/components/translate/content/browser/browser_cld_data_provider_factory.h b/components/translate/content/browser/browser_cld_data_provider_factory.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..57196134142b563a7e0e0c906116d9a916ccc8b3 |
| --- /dev/null |
| +++ b/components/translate/content/browser/browser_cld_data_provider_factory.h |
| @@ -0,0 +1,68 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_TRANSLATE_CONTENT_BROWSER_BROWSER_CLD_DATA_PROVIDER_FACTORY_H_ |
| +#define COMPONENTS_TRANSLATE_CONTENT_BROWSER_BROWSER_CLD_DATA_PROVIDER_FACTORY_H_ |
| + |
| +#include "base/macros.h" |
| +#include "components/translate/content/browser/browser_cld_data_provider.h" |
| + |
| +namespace content { |
| +class WebContents; |
| +} |
| + |
| +namespace translate { |
| + |
| +// A factory for the Browser side of CLD Data Providers. The embedder should |
| +// set an instance as soon as feasible during startup. The browser process will |
| +// use this factory to create the one BrowserCldDataProvider for each render |
| +// view host in order to communicate with a RendererCldDataProvider in the |
| +// renderer process. For more information on the RendererCldDataProvider, see: |
| +// ../renderer/renderer_cld_data_provider.h |
| +class BrowserCldDataProviderFactory { |
| + public: |
| + BrowserCldDataProviderFactory() {} |
| + virtual ~BrowserCldDataProviderFactory() {} |
| + |
| + // Create and return a new instance of a BrowserCldDataProvider. The default |
| + // implementation of this method produces a no-op BrowserCldDataProvider that |
| + // is suitable only when CLD data has been statically linked. |
| + // Every invocation creates a new provider; the caller is responsible for |
| + // deleting the object when it is no longer needed. |
| + // TODO(andrewhayden) scoped_ptr? |
|
Andrew Hayden (chromium.org)
2014/11/10 14:06:35
This still needs to be done, and it seems to make
|
| + virtual BrowserCldDataProvider* NewProvider( |
|
Takashi Toyoshima
2014/11/06 14:34:29
NewProvider() does not sound a consistent name wit
Andrew Hayden (chromium.org)
2014/11/10 14:06:35
I took a look at cs.chromium.org and tried to find
Takashi Toyoshima
2014/11/11 07:16:36
I agreed to use CreateFoo() pattern.
|
| + content::WebContents* web_contents); |
| + |
| + // Returns true if and only if the current instance for this process is not |
| + // NULL. |
| + static bool IsInitialized(); |
| + |
| + // Sets the default factory for this process, i.e. the factory to be used |
| + // unless the embedder calls Set(BrowserCldDataProviderFactory*). This is the |
| + // method that normal (i.e., non-test) Chromium code should use; embedders can |
| + // and should use the unconditional Set(BrowserCldDataProviderFactory*) method |
| + // instead. If a default factory has already been set, this method does |
| + // nothing. |
| + static void SetDefault(BrowserCldDataProviderFactory* instance); |
| + |
| + // Unconditionally sets the factory for this process, overwriting any |
| + // previously-configured default. Normal Chromium code should never use this |
| + // method; it is provided for embedders to inject a factory from outside of |
| + // the Chromium code base. Test code can also use this method to force the |
| + // runtime to have a desired behavior. |
| + static void Set(BrowserCldDataProviderFactory* instance); |
| + |
| + // Returns the instance of the factory previously set by Set()/SetDefault(). |
| + // If no instance has been set, a default factory will be returned that |
| + // produces no-op BrowserCldDataProviders as described by NewProvider(...) |
| + // above. |
| + static BrowserCldDataProviderFactory* Get(); |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(BrowserCldDataProviderFactory); |
| +}; |
| + |
| +} // namespace translate |
| + |
| +#endif // COMPONENTS_TRANSLATE_CONTENT_BROWSER_BROWSER_CLD_DATA_PROVIDER_FACTORY_H_ |