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

Side by Side Diff: chrome/browser/translate/translate_language_list.h

Issue 15317007: Translate: split supporting language list handling to TranslateLanguageList (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reviewed Created 7 years, 6 months 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
« no previous file with comments | « no previous file | chrome/browser/translate/translate_language_list.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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>
9 #include <string>
10 #include <vector>
11
12 #include "base/memory/scoped_ptr.h"
13 #include "net/url_request/url_fetcher_delegate.h"
14
15 namespace net {
16 class URLFetcher;
17 }
18
19 // The TranslateLanguageList class is responsible for maintaining the latest
20 // supporting language list.
21 // This class is defined to be owned only by TranslateManager.
22 class TranslateLanguageList : public net::URLFetcherDelegate {
23 public:
24 TranslateLanguageList();
25 virtual ~TranslateLanguageList();
26
27 // net::URLFetcherDelegate implementation:
28 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
29
30 // Fills |languages| with the list of languages that the translate server can
31 // translate to and from.
32 void GetSupportedLanguages(std::vector<std::string>* languages);
33
34 // Returns the language code that can be used with the Translate method for a
35 // specified |chrome_locale|.
36 std::string GetLanguageCode(const std::string& chrome_locale);
37
38 // Returns true if |language| is supported by the translation server.
39 bool IsSupportedLanguage(const std::string& language);
40
41 // TODO(toyoshim): Add IsSupportedAlphaLanguage() here.
42
43 // Fetches the language list from the translate server. It will not retry
44 // more than kMaxRetryLanguageListFetch times.
45 void RequestLanguageList();
46
47 // static const values shared with our browser tests.
48 static const char kLanguageListCallbackName[];
49 static const char kTargetLanguagesKey[];
50
51 private:
52 // Parses |language_list| and fills |supported_languages_| with the list of
53 // languages that the translate server can translate to and from.
54 void SetSupportedLanguages(const std::string& language_list);
55
56 // The languages supported by the translation server.
57 std::set<std::string> supported_languages_;
58
59 // An URLFetcher instance to fetch a server providing supported language list.
60 scoped_ptr<net::URLFetcher> url_fetcher_;
61
62 DISALLOW_COPY_AND_ASSIGN(TranslateLanguageList);
63 };
64
65 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_LANGUAGE_LIST_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/translate/translate_language_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698