| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/browser/ui/android/infobars/translate_infobar.h" | 5 #include "chrome/browser/ui/android/infobars/translate_infobar.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_weak_ref.h" | 9 #include "base/android/jni_weak_ref.h" |
| 10 #include "chrome/browser/translate/chrome_translate_client.h" | 10 #include "chrome/browser/translate/chrome_translate_client.h" |
| 11 #include "components/translate/core/browser/translate_infobar_delegate.h" | 11 #include "components/translate/core/browser/translate_infobar_delegate.h" |
| 12 #include "jni/TranslateInfoBarDelegate_jni.h" | 12 #include "jni/TranslateInfoBarDelegate_jni.h" |
| 13 | 13 |
| 14 // ChromeTranslateClient | 14 // ChromeTranslateClient |
| 15 // ---------------------------------------------------------- | 15 // ---------------------------------------------------------- |
| 16 | 16 |
| 17 scoped_ptr<infobars::InfoBar> ChromeTranslateClient::CreateInfoBar( | 17 scoped_ptr<infobars::InfoBar> ChromeTranslateClient::CreateInfoBar( |
| 18 scoped_ptr<translate::TranslateInfoBarDelegate> delegate) const { | 18 scoped_ptr<translate::TranslateInfoBarDelegate> delegate) const { |
| 19 return scoped_ptr<infobars::InfoBar>(new TranslateInfoBar(delegate.Pass())); | 19 return make_scoped_ptr(new TranslateInfoBar(delegate.Pass())); |
| 20 } | 20 } |
| 21 | 21 |
| 22 | 22 |
| 23 // TranslateInfoBar ----------------------------------------------------------- | 23 // TranslateInfoBar ----------------------------------------------------------- |
| 24 | 24 |
| 25 TranslateInfoBar::TranslateInfoBar( | 25 TranslateInfoBar::TranslateInfoBar( |
| 26 scoped_ptr<translate::TranslateInfoBarDelegate> delegate) | 26 scoped_ptr<translate::TranslateInfoBarDelegate> delegate) |
| 27 : InfoBarAndroid(delegate.PassAs<infobars::InfoBarDelegate>()), | 27 : InfoBarAndroid(delegate.Pass()), java_translate_delegate_() { |
| 28 java_translate_delegate_() { | |
| 29 } | 28 } |
| 30 | 29 |
| 31 TranslateInfoBar::~TranslateInfoBar() { | 30 TranslateInfoBar::~TranslateInfoBar() { |
| 32 } | 31 } |
| 33 | 32 |
| 34 ScopedJavaLocalRef<jobject> TranslateInfoBar::CreateRenderInfoBar(JNIEnv* env) { | 33 ScopedJavaLocalRef<jobject> TranslateInfoBar::CreateRenderInfoBar(JNIEnv* env) { |
| 35 java_translate_delegate_.Reset(Java_TranslateInfoBarDelegate_create(env)); | 34 java_translate_delegate_.Reset(Java_TranslateInfoBarDelegate_create(env)); |
| 36 translate::TranslateInfoBarDelegate* delegate = GetDelegate(); | 35 translate::TranslateInfoBarDelegate* delegate = GetDelegate(); |
| 37 std::vector<base::string16> languages; | 36 std::vector<base::string16> languages; |
| 38 languages.reserve(delegate->num_languages()); | 37 languages.reserve(delegate->num_languages()); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 translate::TranslateInfoBarDelegate* TranslateInfoBar::GetDelegate() { | 127 translate::TranslateInfoBarDelegate* TranslateInfoBar::GetDelegate() { |
| 129 return delegate()->AsTranslateInfoBarDelegate(); | 128 return delegate()->AsTranslateInfoBarDelegate(); |
| 130 } | 129 } |
| 131 | 130 |
| 132 | 131 |
| 133 // Native JNI methods --------------------------------------------------------- | 132 // Native JNI methods --------------------------------------------------------- |
| 134 | 133 |
| 135 bool RegisterTranslateInfoBarDelegate(JNIEnv* env) { | 134 bool RegisterTranslateInfoBarDelegate(JNIEnv* env) { |
| 136 return RegisterNativesImpl(env); | 135 return RegisterNativesImpl(env); |
| 137 } | 136 } |
| OLD | NEW |