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

Side by Side Diff: components/translate/content/browser/browser_cld_data_provider_factory.h

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 #ifndef COMPONENTS_TRANSLATE_CONTENT_BROWSER_BROWSER_CLD_DATA_PROVIDER_FACTORY_H _
6 #define COMPONENTS_TRANSLATE_CONTENT_BROWSER_BROWSER_CLD_DATA_PROVIDER_FACTORY_H _
7
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "components/translate/content/browser/browser_cld_data_provider.h"
11
12 namespace content {
13 class WebContents;
14 }
15
16 namespace translate {
17
18 // A factory for the Browser side of CLD Data Providers. The embedder should
19 // set an instance as soon as feasible during startup. The browser process will
20 // use this factory to create the one BrowserCldDataProvider for each render
21 // view host in order to communicate with a RendererCldDataProvider in the
22 // renderer process. For more information on the RendererCldDataProvider, see:
23 // ../renderer/renderer_cld_data_provider.h
24 class BrowserCldDataProviderFactory {
25 public:
26 BrowserCldDataProviderFactory() {}
27 virtual ~BrowserCldDataProviderFactory() {}
28
29 // Create and return a new instance of a BrowserCldDataProvider. The default
30 // implementation of this method produces a no-op BrowserCldDataProvider 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<BrowserCldDataProvider> CreateBrowserCldDataProvider(
35 content::WebContents* web_contents);
36
37 // Returns true if and only if the current instance for this process is not
38 // NULL.
39 static bool IsInitialized();
40
41 // Sets the default factory for this process, i.e. the factory to be used
42 // unless the embedder calls Set(BrowserCldDataProviderFactory*). This is the
43 // method that normal (i.e., non-test) Chromium code should use; embedders can
44 // and should use the unconditional Set(BrowserCldDataProviderFactory*) method
45 // instead. If a default factory has already been set, this method does
46 // nothing.
47 static void SetDefault(BrowserCldDataProviderFactory* instance);
48
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(BrowserCldDataProviderFactory* instance);
55
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 BrowserCldDataProviders as described by NewProvider(...)
59 // above.
60 static BrowserCldDataProviderFactory* Get();
61
62 private:
63 DISALLOW_COPY_AND_ASSIGN(BrowserCldDataProviderFactory);
64 };
65
66 } // namespace translate
67
68 #endif // COMPONENTS_TRANSLATE_CONTENT_BROWSER_BROWSER_CLD_DATA_PROVIDER_FACTOR Y_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698