Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / translate / translate_service.h
blob15340cbc3ea9c17ea924ec24e3f29bc0c6c0461e
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.
5 #ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_SERVICE_H_
6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_SERVICE_H_
8 #include "components/web_resource/resource_request_allowed_notifier.h"
10 class GURL;
11 class PrefService;
13 // Singleton managing the resources required for Translate.
14 class TranslateService
15 : public web_resource::ResourceRequestAllowedNotifier::Observer {
16 public:
17 // Must be called before the Translate feature can be used.
18 static void Initialize();
20 // Must be called to shut down the Translate feature.
21 static void Shutdown(bool cleanup_pending_fetcher);
23 // Initializes the TranslateService in a way that it can be initialized
24 // multiple times in a unit test suite (once for each test). Should be paired
25 // with ShutdownForTesting at the end of the test.
26 static void InitializeForTesting();
28 // Shuts down the TranslateService at the end of a test in a way that the next
29 // test can initialize and use the service.
30 static void ShutdownForTesting();
32 // Let the caller decide if and when we should fetch the language list from
33 // the translate server. This is a NOOP if switches::kDisableTranslate is set
34 // or if prefs::kEnableTranslate is set to false.
35 static void FetchLanguageListFromTranslateServer(PrefService* prefs);
37 // Returns true if the new translate bubble is enabled.
38 static bool IsTranslateBubbleEnabled();
40 // Returns the language to translate to. The language returned is the
41 // first language found in the following list that is supported by the
42 // translation service:
43 // the UI language
44 // the accept-language list
45 // If no language is found then an empty string is returned.
46 static std::string GetTargetLanguage(PrefService* prefs);
48 // Returns true if the URL can be translated.
49 static bool IsTranslatableURL(const GURL& url);
51 private:
52 TranslateService();
53 ~TranslateService();
55 // ResourceRequestAllowedNotifier::Observer methods.
56 void OnResourceRequestsAllowed() override;
58 // Helper class to know if it's allowed to make network resource requests.
59 web_resource::ResourceRequestAllowedNotifier
60 resource_request_allowed_notifier_;
63 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_SERVICE_H_