| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/search_geolocation_disclosure_infob
ar.h" | 5 #include "chrome/browser/ui/android/infobars/search_geolocation_disclosure_infob
ar.h" |
| 6 | 6 |
| 7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
| 8 #include "chrome/browser/android/search_geolocation_disclosure_infobar_delegate.
h" | 8 #include "chrome/browser/android/search_geolocation_disclosure_infobar_delegate.
h" |
| 9 #include "jni/SearchGeolocationDisclosureInfoBar_jni.h" | 9 #include "jni/SearchGeolocationDisclosureInfoBar_jni.h" |
| 10 | 10 |
| 11 using base::android::JavaParamRef; | 11 using base::android::JavaParamRef; |
| 12 using base::android::ScopedJavaLocalRef; | 12 using base::android::ScopedJavaLocalRef; |
| 13 | 13 |
| 14 SearchGeolocationDisclosureInfoBar::SearchGeolocationDisclosureInfoBar( | 14 SearchGeolocationDisclosureInfoBar::SearchGeolocationDisclosureInfoBar( |
| 15 std::unique_ptr<SearchGeolocationDisclosureInfoBarDelegate> delegate) | 15 std::unique_ptr<SearchGeolocationDisclosureInfoBarDelegate> delegate) |
| 16 : InfoBarAndroid(std::move(delegate)) {} | 16 : InfoBarAndroid(std::move(delegate)) {} |
| 17 | 17 |
| 18 SearchGeolocationDisclosureInfoBar::~SearchGeolocationDisclosureInfoBar() { | 18 SearchGeolocationDisclosureInfoBar::~SearchGeolocationDisclosureInfoBar() { |
| 19 } | 19 } |
| 20 | 20 |
| 21 ScopedJavaLocalRef<jobject> | 21 ScopedJavaLocalRef<jobject> |
| 22 SearchGeolocationDisclosureInfoBar::CreateRenderInfoBar(JNIEnv* env) { | 22 SearchGeolocationDisclosureInfoBar::CreateRenderInfoBar(JNIEnv* env) { |
| 23 ScopedJavaLocalRef<jstring> message_text = | 23 ScopedJavaLocalRef<jstring> message_text = |
| 24 base::android::ConvertUTF16ToJavaString( | 24 base::android::ConvertUTF16ToJavaString( |
| 25 env, GetDelegate()->GetMessageText()); | 25 env, GetDelegate()->message_text()); |
| 26 ScopedJavaLocalRef<jstring> search_url = |
| 27 base::android::ConvertUTF8ToJavaString( |
| 28 env, GetDelegate()->search_url().spec()); |
| 26 return Java_SearchGeolocationDisclosureInfoBar_show( | 29 return Java_SearchGeolocationDisclosureInfoBar_show( |
| 27 env, GetEnumeratedIconId(), message_text); | 30 env, GetEnumeratedIconId(), message_text, |
| 31 GetDelegate()->inline_link_range().start(), |
| 32 GetDelegate()->inline_link_range().end(), |
| 33 search_url); |
| 34 } |
| 35 |
| 36 void SearchGeolocationDisclosureInfoBar::OnLinkClicked( |
| 37 JNIEnv* env, |
| 38 const base::android::JavaParamRef<jobject>& obj) { |
| 39 if (!owner()) |
| 40 return; // We're closing; don't call anything, it might access the owner. |
| 41 |
| 42 RemoveSelf(); |
| 28 } | 43 } |
| 29 | 44 |
| 30 void SearchGeolocationDisclosureInfoBar::ProcessButton(int action) { | 45 void SearchGeolocationDisclosureInfoBar::ProcessButton(int action) { |
| 31 if (!owner()) | 46 if (!owner()) |
| 32 return; // We're closing; don't call anything, it might access the owner. | 47 return; // We're closing; don't call anything, it might access the owner. |
| 33 | 48 |
| 34 RemoveSelf(); | 49 RemoveSelf(); |
| 35 } | 50 } |
| 36 | 51 |
| 37 SearchGeolocationDisclosureInfoBarDelegate* | 52 SearchGeolocationDisclosureInfoBarDelegate* |
| 38 SearchGeolocationDisclosureInfoBar::GetDelegate() { | 53 SearchGeolocationDisclosureInfoBar::GetDelegate() { |
| 39 return static_cast<SearchGeolocationDisclosureInfoBarDelegate*>(delegate()); | 54 return static_cast<SearchGeolocationDisclosureInfoBarDelegate*>(delegate()); |
| 40 } | 55 } |
| OLD | NEW |