Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / android / infobars / infobar_android.cc
blob137eb7469bc87493e0afabe8db2469e7024d41ca
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/android/infobars/infobar_android.h"
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h"
9 #include "base/strings/string_util.h"
10 #include "chrome/browser/android/resource_mapper.h"
11 #include "chrome/browser/infobars/infobar_service.h"
12 #include "components/infobars/core/infobar.h"
13 #include "components/infobars/core/infobar_delegate.h"
14 #include "jni/InfoBar_jni.h"
17 // InfoBarAndroid -------------------------------------------------------------
19 InfoBarAndroid::InfoBarAndroid(scoped_ptr<infobars::InfoBarDelegate> delegate)
20 : infobars::InfoBar(delegate.Pass()) {
23 InfoBarAndroid::~InfoBarAndroid() {
26 void InfoBarAndroid::ReassignJavaInfoBar(InfoBarAndroid* replacement) {
27 DCHECK(replacement);
28 if (!java_info_bar_.is_null()) {
29 replacement->set_java_infobar(java_info_bar_);
30 java_info_bar_.Reset();
34 void InfoBarAndroid::set_java_infobar(
35 const base::android::JavaRef<jobject>& java_info_bar) {
36 DCHECK(java_info_bar_.is_null());
37 java_info_bar_.Reset(java_info_bar);
40 bool InfoBarAndroid::HasSetJavaInfoBar() const {
41 return !java_info_bar_.is_null();
44 void InfoBarAndroid::OnButtonClicked(JNIEnv* env,
45 jobject obj,
46 jint action,
47 jstring action_value) {
48 std::string value = base::android::ConvertJavaStringToUTF8(env, action_value);
49 ProcessButton(action, value);
52 void InfoBarAndroid::OnCloseButtonClicked(JNIEnv* env, jobject obj) {
53 if (!owner())
54 return; // We're closing; don't call anything, it might access the owner.
55 delegate()->InfoBarDismissed();
56 RemoveSelf();
59 void InfoBarAndroid::CloseJavaInfoBar() {
60 if (!java_info_bar_.is_null()) {
61 JNIEnv* env = base::android::AttachCurrentThread();
62 Java_InfoBar_closeInfoBar(env, java_info_bar_.obj());
66 int InfoBarAndroid::GetEnumeratedIconId() {
67 return ResourceMapper::MapFromChromiumId(delegate()->GetIconID());
71 // Native JNI methods ---------------------------------------------------------
73 bool RegisterNativeInfoBar(JNIEnv* env) {
74 return RegisterNativesImpl(env);