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 PrefService; | 11 class PrefService; |
11 | 12 |
12 // Singleton managing the resources required for Translate. | 13 // Singleton managing the resources required for Translate. |
13 class TranslateService : public ResourceRequestAllowedNotifier::Observer { | 14 class TranslateService : public ResourceRequestAllowedNotifier::Observer { |
14 public: | 15 public: |
15 // Must be called before the Translate feature can be used. | 16 // Must be called before the Translate feature can be used. |
16 static void Initialize(); | 17 static void Initialize(); |
17 | 18 |
18 // Must be called to shut down the Translate feature. | 19 // Must be called to shut down the Translate feature. |
19 static void Shutdown(bool cleanup_pending_fetcher); | 20 static void Shutdown(bool cleanup_pending_fetcher); |
(...skipping 20 matching lines...) Expand all Loading... |
40 static void SetUseInfobar(bool value); | 41 static void SetUseInfobar(bool value); |
41 | 42 |
42 // Returns the language to translate to. The language returned is the | 43 // Returns the language to translate to. The language returned is the |
43 // first language found in the following list that is supported by the | 44 // first language found in the following list that is supported by the |
44 // translation service: | 45 // translation service: |
45 // the UI language | 46 // the UI language |
46 // the accept-language list | 47 // the accept-language list |
47 // If no language is found then an empty string is returned. | 48 // If no language is found then an empty string is returned. |
48 static std::string GetTargetLanguage(PrefService* prefs); | 49 static std::string GetTargetLanguage(PrefService* prefs); |
49 | 50 |
| 51 // Returns true if the URL can be translated. |
| 52 static bool IsTranslatableURL(const GURL& url); |
| 53 |
50 private: | 54 private: |
51 TranslateService(); | 55 TranslateService(); |
52 ~TranslateService(); | 56 ~TranslateService(); |
53 | 57 |
54 // ResourceRequestAllowedNotifier::Observer methods. | 58 // ResourceRequestAllowedNotifier::Observer methods. |
55 virtual void OnResourceRequestsAllowed() OVERRIDE; | 59 virtual void OnResourceRequestsAllowed() OVERRIDE; |
56 | 60 |
57 // Helper class to know if it's allowed to make network resource requests. | 61 // Helper class to know if it's allowed to make network resource requests. |
58 ResourceRequestAllowedNotifier resource_request_allowed_notifier_; | 62 ResourceRequestAllowedNotifier resource_request_allowed_notifier_; |
59 | 63 |
60 // Whether or not the infobar is used. This is intended to be used | 64 // Whether or not the infobar is used. This is intended to be used |
61 // only for testing. | 65 // only for testing. |
62 bool use_infobar_; | 66 bool use_infobar_; |
63 }; | 67 }; |
64 | 68 |
65 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_SERVICE_H_ | 69 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_SERVICE_H_ |
OLD | NEW |