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.
4
5#ifndef COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_CLIENT_H_
6#define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_CLIENT_H_
7
8#include <string>
9
10#include "base/memory/ref_counted.h"
11#include "base/memory/scoped_ptr.h"
12#include "components/translate/core/browser/translate_prefs.h"
13#include "components/translate/core/browser/translate_step.h"
14#include "components/translate/core/common/translate_errors.h"
15
16class GURL;
17class PrefService;
18
19namespace infobars {
20class InfoBar;
21}
22
23namespace translate {
24
25class TranslateAcceptLanguages;
26class TranslateDriver;
27class TranslateInfoBarDelegate;
28
29// A client interface that needs to be supplied to TranslateManager by the
30// embedder.
31//
32// Each client instance is associated with a given context within which a
33// TranslateManager is used (e.g. a single tab).
34class TranslateClient {
35 public:
36  // Gets the TranslateDriver associated with the client.
37  virtual TranslateDriver* GetTranslateDriver() = 0;
38
39  // Returns the associated PrefService.
40  virtual PrefService* GetPrefs() = 0;
41
42  // Returns the associated TranslatePrefs.
43  virtual scoped_ptr<TranslatePrefs> GetTranslatePrefs() = 0;
44
45  // Returns the associated TranslateAcceptLanguages.
46  virtual TranslateAcceptLanguages* GetTranslateAcceptLanguages() = 0;
47
48  // Returns the resource ID of the icon to be shown for the Translate infobars.
49  virtual int GetInfobarIconID() const = 0;
50
51  // Returns a translate infobar that owns |delegate|.
52  virtual scoped_ptr<infobars::InfoBar> CreateInfoBar(
53      scoped_ptr<TranslateInfoBarDelegate> delegate) const = 0;
54
55  // Called when the embedder should present UI to the user corresponding to the
56  // user's current |step|.
57  virtual void ShowTranslateUI(translate::TranslateStep step,
58                               const std::string source_language,
59                               const std::string target_language,
60                               TranslateErrors::Type error_type,
61                               bool triggered_from_menu) = 0;
62
63  // Returns true if the URL can be translated.
64  virtual bool IsTranslatableURL(const GURL& url) = 0;
65
66  // Presents |report_url|, a URL containing information relating to reporting
67  // a language detection error, to the user to allow them to report language
68  // detection errors as desired.
69  virtual void ShowReportLanguageDetectionErrorUI(const GURL& report_url) = 0;
70};
71
72}  // namespace translate
73
74#endif  // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_CLIENT_H_
75