Commit d64a4dd2 authored by estade's avatar estade Committed by Commit bot

remove CountryAdapterAndroid

it's not necessary now that we're using the libaddressinput widget.

BUG=399146

Review URL: https://codereview.chromium.org/588333002

Cr-Commit-Position: refs/heads/master@{#296069}
parent 45d667c5
// Copyright 2014 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.
package org.chromium.chrome.browser.autofill;
import android.database.DataSetObserver;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
import org.chromium.base.JNINamespace;
import org.chromium.chrome.R;
/**
* Android wrapper for CountryComboboxModel.
*
* Only useable from the UI layer. Used in the Android settings UI.
* See chrome/browser/ui/android/autofill/country_adapter_android.h for more details.
*/
@JNINamespace("autofill")
public class CountryAdapter implements SpinnerAdapter {
/**
* The items to show in the spinner.
*
* Even indices are display names, odd indices are country codes.
*/
private String[] mItems;
private LayoutInflater mInflater;
private final long mCountryAdapterAndroid;
public CountryAdapter(LayoutInflater inflater) {
mInflater = inflater;
mCountryAdapterAndroid = nativeInit();
mItems = nativeGetItems(mCountryAdapterAndroid);
}
@Override
public int getCount() {
return mItems.length / 2;
}
@Override
public Object getItem(int position) {
return mItems[position * 2 + 1];
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public int getItemViewType(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView textView = null;
if (convertView instanceof TextView) {
textView = (TextView) convertView;
}
if (textView == null) {
textView = (TextView) mInflater.inflate(R.layout.country_text, parent, false);
}
textView.setText(mItems[position * 2]);
return textView;
}
@Override
public boolean hasStableIds() {
return true;
}
@Override
public int getViewTypeCount() {
return 1;
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public void registerDataSetObserver(DataSetObserver observer) {}
@Override
public void unregisterDataSetObserver(DataSetObserver observer) {}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
TextView textView = null;
if (convertView instanceof TextView) {
textView = (TextView) convertView;
}
if (textView == null) {
textView = (TextView) mInflater.inflate(R.layout.country_item, parent, false);
}
textView.setText(mItems[position * 2]);
return textView;
}
/**
* Gets the index in the model for the given country code.
*/
public int getIndexForCountryCode(String countryCode) {
for (int i = 0; i < getCount(); i++) {
if (countryCode.equals(getItem(i))) {
return i;
}
}
return 0;
}
private native long nativeInit();
private native String[] nativeGetItems(long nativeCountryAdapterAndroid);
}
......@@ -56,7 +56,6 @@
#include "chrome/browser/ui/android/autofill/autofill_dialog_result.h"
#include "chrome/browser/ui/android/autofill/autofill_logger_android.h"
#include "chrome/browser/ui/android/autofill/autofill_popup_view_android.h"
#include "chrome/browser/ui/android/autofill/country_adapter_android.h"
#include "chrome/browser/ui/android/chrome_http_auth_handler.h"
#include "chrome/browser/ui/android/context_menu_helper.h"
#include "chrome/browser/ui/android/infobars/auto_login_infobar_delegate_android.h"
......@@ -134,7 +133,6 @@ static base::android::RegistrationMethod kChromeRegisteredMethods[] = {
{ "ConfirmInfoBarDelegate", RegisterConfirmInfoBarDelegate },
{ "ContentViewUtil", RegisterContentViewUtil },
{ "ContextMenuHelper", RegisterContextMenuHelper },
{ "CountryAdapterAndroid", autofill::CountryAdapterAndroid::Register },
{ "DataReductionProxyInfoBarDelegate", DataReductionProxyInfoBar::Register },
{ "DataReductionProxySettings", DataReductionProxySettingsAndroid::Register },
{ "DevToolsServer", RegisterDevToolsServer },
......
// Copyright 2014 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/autofill/country_adapter_android.h"
#include "base/android/jni_array.h"
#include "base/android/jni_string.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "components/autofill/core/browser/autofill_country.h"
#include "jni/CountryAdapter_jni.h"
namespace autofill {
CountryAdapterAndroid::CountryAdapterAndroid(JNIEnv* env, jobject obj)
: weak_java_obj_(env, obj) {
country_combobox_model_.SetCountries(
*PersonalDataManagerFactory::GetForProfile(
ProfileManager::GetActiveUserProfile()),
base::Callback<bool(const std::string&)>());
}
CountryAdapterAndroid::~CountryAdapterAndroid() {}
ScopedJavaLocalRef<jobjectArray> CountryAdapterAndroid::GetItems(
JNIEnv* env,
jobject unused_obj) {
std::vector<base::string16> country_names_and_codes;
country_names_and_codes.reserve(
2 * country_combobox_model_.countries().size());
for (size_t i = 0; i < country_combobox_model_.countries().size(); ++i) {
country_names_and_codes.push_back(
country_combobox_model_.countries()[i]->name());
country_names_and_codes.push_back(base::ASCIIToUTF16(
country_combobox_model_.countries()[i]->country_code()));
}
return base::android::ToJavaArrayOfStrings(env, country_names_and_codes);
}
// static
bool CountryAdapterAndroid::Register(JNIEnv* env) {
return RegisterNativesImpl(env);
}
static jlong Init(JNIEnv* env, jobject obj) {
CountryAdapterAndroid* country_adapter_android =
new CountryAdapterAndroid(env, obj);
return reinterpret_cast<intptr_t>(country_adapter_android);
}
} // namespace autofill
// Copyright 2014 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.
#ifndef CHROME_BROWSER_UI_ANDROID_AUTOFILL_COUNTRY_ADAPTER_ANDROID_H_
#define CHROME_BROWSER_UI_ANDROID_AUTOFILL_COUNTRY_ADAPTER_ANDROID_H_
#include "base/android/jni_weak_ref.h"
#include "base/android/scoped_java_ref.h"
#include "chrome/browser/ui/autofill/country_combobox_model.h"
namespace autofill {
// A bridge class for showing a list of countries in the Android settings UI.
class CountryAdapterAndroid {
public:
CountryAdapterAndroid(JNIEnv* env, jobject obj);
// Gets all the country codes and names. Every even index is a country name,
// and the following odd index is the associated country code.
base::android::ScopedJavaLocalRef<jobjectArray>
GetItems(JNIEnv* env, jobject unused_obj);
// Registers the JNI bindings for this class.
static bool Register(JNIEnv* env);
private:
~CountryAdapterAndroid();
// Pointer to the java counterpart.
JavaObjectWeakGlobalRef weak_java_obj_;
CountryComboboxModel country_combobox_model_;
};
} // namespace autofill
#endif // CHROME_BROWSER_UI_ANDROID_AUTOFILL_COUNTRY_ADAPTER_ANDROID_H_
......@@ -2699,7 +2699,6 @@
'android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogResult.java',
'android/java/src/org/chromium/chrome/browser/autofill/AutofillLogger.java',
'android/java/src/org/chromium/chrome/browser/autofill/AutofillPopupBridge.java',
'android/java/src/org/chromium/chrome/browser/autofill/CountryAdapter.java',
'android/java/src/org/chromium/chrome/browser/autofill/PersonalDataManager.java',
'android/java/src/org/chromium/chrome/browser/BookmarksBridge.java',
'android/java/src/org/chromium/chrome/browser/BrowserVersion.java',
......
......@@ -16,8 +16,6 @@
'browser/ui/android/autofill/autofill_logger_android.h',
'browser/ui/android/autofill/autofill_popup_view_android.cc',
'browser/ui/android/autofill/autofill_popup_view_android.h',
'browser/ui/android/autofill/country_adapter_android.cc',
'browser/ui/android/autofill/country_adapter_android.h',
'browser/ui/android/content_settings/popup_blocked_infobar_delegate.cc',
'browser/ui/android/content_settings/popup_blocked_infobar_delegate.h',
'browser/ui/android/infobars/auto_login_infobar_delegate_android.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment