summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/android/infobars/translate_infobar.h
blob: 548b10a91438424d1ae04236f82a5c86bbdb7a3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_ANDROID_INFOBARS_TRANSLATE_INFOBAR_H_
#define CHROME_BROWSER_UI_ANDROID_INFOBARS_TRANSLATE_INFOBAR_H_

#include "base/android/scoped_java_ref.h"
#include "base/basictypes.h"
#include "chrome/browser/translate/translate_infobar_delegate.h"
#include "chrome/browser/ui/android/infobars/infobar_android.h"

class TranslateInfoBar : public InfoBarAndroid {
 public:
  explicit TranslateInfoBar(scoped_ptr<TranslateInfoBarDelegate> delegate);
  virtual ~TranslateInfoBar();

  // JNI methods specific to translate.
  void ApplyTranslateOptions(JNIEnv* env,
                             jobject obj,
                             int source_language_index,
                             int target_language_index,
                             bool always_translate,
                             bool never_translate_language,
                             bool never_translate_site);

 private:
  // InfoBarAndroid:
  virtual base::android::ScopedJavaLocalRef<jobject> CreateRenderInfoBar(
      JNIEnv* env) OVERRIDE;
  virtual void ProcessButton(int action,
                             const std::string& action_value) OVERRIDE;
  virtual void PassJavaInfoBar(InfoBarAndroid* source) OVERRIDE;

  void TransferOwnership(TranslateInfoBar* destination,
                         TranslateInfoBarDelegate::Type new_type);
  void SetJavaDelegate(jobject delegate);
  bool ShouldDisplayNeverTranslateInfoBarOnCancel();

  TranslateInfoBarDelegate* GetDelegate();

  base::android::ScopedJavaGlobalRef<jobject> java_translate_delegate_;

  DISALLOW_COPY_AND_ASSIGN(TranslateInfoBar);
};

// Registers the native methods through JNI.
bool RegisterTranslateInfoBarDelegate(JNIEnv* env);

#endif  // CHROME_BROWSER_UI_ANDROID_INFOBARS_TRANSLATE_INFOBAR_H_