OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 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 CHROME_BROWSER_TRANSLATE_TRANSLATE_LANGUAGE_LIST_H_ | |
6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_LANGUAGE_LIST_H_ | |
7 | |
8 #include <set> | |
MAD
2013/05/22 14:00:04
I don't think this is needed here. Right?
Takashi Toyoshima
2013/05/23 08:21:19
Done.
| |
9 #include <string> | |
10 #include <vector> | |
11 | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/memory/singleton.h" | |
14 #include "net/url_request/url_fetcher_delegate.h" | |
15 | |
16 class TranslateManager; | |
17 class TranslateManagerBrowserTest; | |
18 | |
19 namespace net { | |
20 class URLFetcher; | |
21 } | |
22 | |
23 // The TranslateLanguageList class is responsible for maintaining the latest | |
24 // supporting language list. | |
25 // It is a singleton. | |
26 | |
MAD
2013/05/22 14:00:04
No empty line here.
Takashi Toyoshima
2013/05/23 08:21:19
Done.
| |
27 class TranslateLanguageList : public net::URLFetcherDelegate { | |
28 public: | |
29 // Returns the singleton instance. | |
30 static TranslateLanguageList* GetInstance(); | |
31 | |
32 virtual ~TranslateLanguageList(); | |
33 | |
34 // net::URLFetcherDelegate implementation: | |
35 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | |
36 | |
37 // Fills |languages| with the list of languages that the translate server can | |
38 // translate to and from. | |
39 static void GetSupportedLanguages(std::vector<std::string>* languages); | |
40 | |
41 // Returns true if |language| is supported by the translation server. | |
42 static bool IsSupportedLanguage(const std::string& language); | |
43 | |
44 // TODO(toyoshim): Add IsSupportedAlphaLanguage() here. | |
45 | |
46 // Returns the language code that can be used with the Translate method for a | |
47 // specified |chrome_locale|. | |
48 static std::string GetLanguageCode(const std::string& chrome_locale); | |
49 | |
50 // static const values shared with our browser tests. | |
51 static const char kLanguageListCallbackName[]; | |
52 static const char kTargetLanguagesKey[]; | |
53 | |
54 protected: | |
55 TranslateLanguageList(); | |
56 | |
57 private: | |
58 friend class TranslateManager; | |
MAD
2013/05/22 14:00:04
I'm a bit unsure about this... We usually do this,
Takashi Toyoshima
2013/05/22 14:29:17
How about just exposing RequestLanguageList(), Ha
Takashi Toyoshima
2013/05/23 08:21:19
Done (move these three functions to public)
| |
59 friend struct DefaultSingletonTraits<TranslateLanguageList>; | |
60 | |
61 // Following three functions, RequestLanguageList(), HasPendingRequest(), | |
62 // and ResetPendingRequest() should be called only by TranslateManager. | |
63 | |
64 // Fetches the language list from the translate server. It will not retry | |
65 // more than kMaxRetryLanguageListFetch times. | |
66 static void RequestLanguageList(); | |
67 | |
68 // Returns true if there is a pending URLFetcher request. | |
69 static bool HasPendingRequest(); | |
70 | |
71 // Cleanups pending URLFetcher objects to make sure they get released in the | |
MAD
2013/05/23 15:58:13
Cleanups -> Cleans up
| |
72 // appropriate thread. | |
73 static void ResetPendingRequest(); | |
74 | |
75 // Set when the list of languages is currently being retrieved. | |
76 // NULL otherwise. | |
77 scoped_ptr<net::URLFetcher> url_fetcher_; | |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(TranslateLanguageList); | |
80 }; | |
81 | |
82 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_LANGUAGE_LIST_H_ | |
OLD | NEW |