Chromium Code Reviews| Index: chrome/browser/ui/android/infobars/search_geolocation_disclosure_infobar.cc |
| diff --git a/chrome/browser/ui/android/infobars/search_geolocation_disclosure_infobar.cc b/chrome/browser/ui/android/infobars/search_geolocation_disclosure_infobar.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d0478deb3d695098cbb742756abe54a3f64a552b |
| --- /dev/null |
| +++ b/chrome/browser/ui/android/infobars/search_geolocation_disclosure_infobar.cc |
| @@ -0,0 +1,42 @@ |
| +// Copyright 2016 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. |
| + |
| +#include "chrome/browser/ui/android/infobars/search_geolocation_disclosure_infobar.h" |
| + |
| +#include "base/android/jni_string.h" |
| +#include "chrome/browser/android/search_geolocation_disclosure_infobar_delegate.h" |
| +#include "jni/SearchGeolocationDisclosureInfoBar_jni.h" |
| + |
| +using base::android::JavaParamRef; |
| +using base::android::ScopedJavaLocalRef; |
| + |
| +SearchGeolocationDisclosureInfoBar::SearchGeolocationDisclosureInfoBar( |
| + std::unique_ptr<SearchGeolocationDisclosureInfoBarDelegate> delegate) |
| + : InfoBarAndroid(std::move(delegate)) {} |
| + |
| +SearchGeolocationDisclosureInfoBar::~SearchGeolocationDisclosureInfoBar() { |
| +} |
| + |
| +ScopedJavaLocalRef<jobject> |
| +SearchGeolocationDisclosureInfoBar::CreateRenderInfoBar(JNIEnv* env) { |
| + SearchGeolocationDisclosureInfoBarDelegate* search_delegate = |
| + delegate()->AsSearchGeolocationDisclosureInfoBarDelegate(); |
|
Peter Kasting
2016/11/08 01:17:51
Nit: Use GetDelegate()
benwells
2016/11/08 02:53:40
Done.
|
| + ScopedJavaLocalRef<jstring> message_text = |
| + base::android::ConvertUTF16ToJavaString( |
| + env, search_delegate->GetMessageText()); |
| + return Java_SearchGeolocationDisclosureInfoBar_show( |
| + env, GetEnumeratedIconId(), message_text); |
| +} |
| + |
| +void SearchGeolocationDisclosureInfoBar::ProcessButton(int action) { |
| + if (!owner()) |
| + return; // We're closing; don't call anything, it might access the owner. |
| + |
| + RemoveSelf(); |
| +} |
| + |
| +SearchGeolocationDisclosureInfoBarDelegate* |
| +SearchGeolocationDisclosureInfoBar::GetDelegate() { |
| + return delegate()->AsSearchGeolocationDisclosureInfoBarDelegate(); |
|
Peter Kasting
2016/11/08 01:17:51
Don't add this virtual downcast method; you know t
benwells
2016/11/08 02:53:40
Cool, glad to hear that's the way its done :)
|
| +} |