OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_SERVICE_H_ |
6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_SERVICE_H_ | 6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_SERVICE_H_ |
7 | 7 |
8 #include "chrome/browser/web_resource/resource_request_allowed_notifier.h" | 8 #include "chrome/browser/web_resource/resource_request_allowed_notifier.h" |
9 | 9 |
10 class GURL; | 10 class GURL; |
(...skipping 18 matching lines...) Expand all Loading... |
29 static void ShutdownForTesting(); | 29 static void ShutdownForTesting(); |
30 | 30 |
31 // Let the caller decide if and when we should fetch the language list from | 31 // Let the caller decide if and when we should fetch the language list from |
32 // the translate server. This is a NOOP if switches::kDisableTranslate is set | 32 // the translate server. This is a NOOP if switches::kDisableTranslate is set |
33 // or if prefs::kEnableTranslate is set to false. | 33 // or if prefs::kEnableTranslate is set to false. |
34 static void FetchLanguageListFromTranslateServer(PrefService* prefs); | 34 static void FetchLanguageListFromTranslateServer(PrefService* prefs); |
35 | 35 |
36 // Returns true if the new translate bubble is enabled. | 36 // Returns true if the new translate bubble is enabled. |
37 static bool IsTranslateBubbleEnabled(); | 37 static bool IsTranslateBubbleEnabled(); |
38 | 38 |
39 // Sets whether of not the infobar UI is used. This method is intended to be | |
40 // used only for tests. | |
41 static void SetUseInfobar(bool value); | |
42 | |
43 // Returns the language to translate to. The language returned is the | 39 // Returns the language to translate to. The language returned is the |
44 // first language found in the following list that is supported by the | 40 // first language found in the following list that is supported by the |
45 // translation service: | 41 // translation service: |
46 // the UI language | 42 // the UI language |
47 // the accept-language list | 43 // the accept-language list |
48 // If no language is found then an empty string is returned. | 44 // If no language is found then an empty string is returned. |
49 static std::string GetTargetLanguage(PrefService* prefs); | 45 static std::string GetTargetLanguage(PrefService* prefs); |
50 | 46 |
51 // Returns true if the URL can be translated. | 47 // Returns true if the URL can be translated. |
52 static bool IsTranslatableURL(const GURL& url); | 48 static bool IsTranslatableURL(const GURL& url); |
53 | 49 |
54 private: | 50 private: |
55 TranslateService(); | 51 TranslateService(); |
56 ~TranslateService(); | 52 ~TranslateService(); |
57 | 53 |
58 // ResourceRequestAllowedNotifier::Observer methods. | 54 // ResourceRequestAllowedNotifier::Observer methods. |
59 virtual void OnResourceRequestsAllowed() OVERRIDE; | 55 virtual void OnResourceRequestsAllowed() OVERRIDE; |
60 | 56 |
61 // Helper class to know if it's allowed to make network resource requests. | 57 // Helper class to know if it's allowed to make network resource requests. |
62 ResourceRequestAllowedNotifier resource_request_allowed_notifier_; | 58 ResourceRequestAllowedNotifier resource_request_allowed_notifier_; |
63 | |
64 // Whether or not the infobar is used. This is intended to be used | |
65 // only for testing. | |
66 bool use_infobar_; | |
67 }; | 59 }; |
68 | 60 |
69 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_SERVICE_H_ | 61 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_SERVICE_H_ |
OLD | NEW |