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 <stddef.h> | 7 #include <stddef.h> |
| 8 |
8 #include <utility> | 9 #include <utility> |
9 | 10 |
10 #include "base/android/jni_android.h" | 11 #include "base/android/jni_android.h" |
11 #include "base/android/jni_array.h" | 12 #include "base/android/jni_array.h" |
12 #include "base/android/jni_string.h" | 13 #include "base/android/jni_string.h" |
13 #include "base/android/jni_weak_ref.h" | 14 #include "base/android/jni_weak_ref.h" |
| 15 #include "base/memory/ptr_util.h" |
14 #include "chrome/browser/translate/chrome_translate_client.h" | 16 #include "chrome/browser/translate/chrome_translate_client.h" |
15 #include "components/translate/core/browser/translate_infobar_delegate.h" | 17 #include "components/translate/core/browser/translate_infobar_delegate.h" |
16 #include "jni/TranslateInfoBar_jni.h" | 18 #include "jni/TranslateInfoBar_jni.h" |
17 | 19 |
18 // ChromeTranslateClient | 20 // ChromeTranslateClient |
19 // ---------------------------------------------------------- | 21 // ---------------------------------------------------------- |
20 | 22 |
21 scoped_ptr<infobars::InfoBar> ChromeTranslateClient::CreateInfoBar( | 23 std::unique_ptr<infobars::InfoBar> ChromeTranslateClient::CreateInfoBar( |
22 scoped_ptr<translate::TranslateInfoBarDelegate> delegate) const { | 24 std::unique_ptr<translate::TranslateInfoBarDelegate> delegate) const { |
23 return make_scoped_ptr(new TranslateInfoBar(std::move(delegate))); | 25 return base::WrapUnique(new TranslateInfoBar(std::move(delegate))); |
24 } | 26 } |
25 | 27 |
26 | 28 |
27 // TranslateInfoBar ----------------------------------------------------------- | 29 // TranslateInfoBar ----------------------------------------------------------- |
28 | 30 |
29 TranslateInfoBar::TranslateInfoBar( | 31 TranslateInfoBar::TranslateInfoBar( |
30 scoped_ptr<translate::TranslateInfoBarDelegate> delegate) | 32 std::unique_ptr<translate::TranslateInfoBarDelegate> delegate) |
31 : InfoBarAndroid(std::move(delegate)) {} | 33 : InfoBarAndroid(std::move(delegate)) {} |
32 | 34 |
33 TranslateInfoBar::~TranslateInfoBar() { | 35 TranslateInfoBar::~TranslateInfoBar() { |
34 } | 36 } |
35 | 37 |
36 ScopedJavaLocalRef<jobject> TranslateInfoBar::CreateRenderInfoBar(JNIEnv* env) { | 38 ScopedJavaLocalRef<jobject> TranslateInfoBar::CreateRenderInfoBar(JNIEnv* env) { |
37 translate::TranslateInfoBarDelegate* delegate = GetDelegate(); | 39 translate::TranslateInfoBarDelegate* delegate = GetDelegate(); |
38 std::vector<base::string16> languages; | 40 std::vector<base::string16> languages; |
39 std::vector<std::string> codes; | 41 std::vector<std::string> codes; |
40 languages.reserve(delegate->num_languages()); | 42 languages.reserve(delegate->num_languages()); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 translate::TranslateInfoBarDelegate* TranslateInfoBar::GetDelegate() { | 150 translate::TranslateInfoBarDelegate* TranslateInfoBar::GetDelegate() { |
149 return delegate()->AsTranslateInfoBarDelegate(); | 151 return delegate()->AsTranslateInfoBarDelegate(); |
150 } | 152 } |
151 | 153 |
152 | 154 |
153 // Native JNI methods --------------------------------------------------------- | 155 // Native JNI methods --------------------------------------------------------- |
154 | 156 |
155 bool RegisterTranslateInfoBarDelegate(JNIEnv* env) { | 157 bool RegisterTranslateInfoBarDelegate(JNIEnv* env) { |
156 return RegisterNativesImpl(env); | 158 return RegisterNativesImpl(env); |
157 } | 159 } |
OLD | NEW |