SettingsAFCreator::SettingsAFCreator(Evas_Object* parent, bool profile_exists)
: m_scroller(nullptr)
+ , m_box(nullptr)
, m_editErrorcode(update_error_none)
, m_saveErrorcode(save_error_none)
, m_editFieldItemClass(nullptr)
, m_profile_exists(profile_exists)
{
init(parent);
- loadProfile();
};
SettingsAFCreator::~SettingsAFCreator()
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
Ewk_Autofill_Profile* profile = nullptr;
- if (m_profile_exists)
- profile = ewk_context_form_autofill_profile_get(m_ewkContext, 1);
+ if (m_profile_exists) {
+ void* item_data(nullptr);
+ Eina_List* list(nullptr);
+ Eina_List* entire_item_list(
+ ewk_context_form_autofill_profile_get_all(ewk_context_default_get()));
+
+ EINA_LIST_FOREACH(entire_item_list, list, item_data) {
+ if (item_data) {
+ profile = static_cast<Ewk_Autofill_Profile*>(item_data);
+ break;
+ }
+ }
+ }
createNewAutoFillFormItem(profile);
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
if (!profile)
- m_item = std::shared_ptr<AutoFillFormItem>(new AutoFillFormItem(nullptr));
+ m_item = std::make_shared<AutoFillFormItem>(nullptr);
else {
- AutoFillFormItemData* item_data = new AutoFillFormItemData;
+ auto item_data = new AutoFillFormItemData;
if (!item_data) {
BROWSER_LOGE("Malloc failed to get item_data");
return;
item_data->activation = false;
item_data->compose_mode = profile_edit;
- m_item = std::shared_ptr<AutoFillFormItem>(new AutoFillFormItem(item_data));
+ m_item = std::make_shared<AutoFillFormItem>(item_data);
delete item_data;
item_data = nullptr;
return;
bool SettingsAFCreator::populateLayout(Evas_Object* parent)
{
+ loadProfile();
+
m_entryLimitSize.max_char_count = 0;
m_entryLimitSize.max_byte_count = AUTO_FILL_FORM_ENTRY_MAX_COUNT;
m_edjFilePath = EDJE_DIR;
std::string full_name_str = std::string(full_name);
full_name_str = _trim(full_name_str);
full_name = full_name_str.c_str();
+ SPSC.setProfileName(full_name);
if (full_name && strlen(full_name) && !isEntryHasOnlySpace(full_name))
m_item->setName(full_name);
void addItems();
protected:
std::map<unsigned, ItemData> m_buttonsMap;
- Evas_Object *m_scroller;
- Evas_Object *m_box;
+ Evas_Object* m_scroller;
+ Evas_Object* m_box;
profileEditErrorcode m_editErrorcode;
profileSaveErrorcode m_saveErrorcode;
SettingsAFProfile::SettingsAFProfile(Evas_Object* parent)
: m_profile(nullptr)
+ , m_itemData(nullptr)
+ , m_profileName(std::string())
{
init(parent);
+ SPSC.setProfileName.connect([this](std::string name){m_profileName = name;});
};
SettingsAFProfile::~SettingsAFProfile()
void SettingsAFProfile::updateButtonMap()
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- // TODO Fix profile name update after profile saving
ItemData profileName;
- m_profile = ewk_context_form_autofill_profile_get(ewk_context_default_get(), 1);
+ void* item_data(nullptr);
+ Eina_List* list(nullptr);
+ Eina_List* entire_item_list(
+ ewk_context_form_autofill_profile_get_all(ewk_context_default_get()));
+
+ // ID for the item is not always 1 so we need to return the first existing one
+ EINA_LIST_FOREACH(entire_item_list, list, item_data) {
+ if (item_data) {
+ m_profile = static_cast<Ewk_Autofill_Profile*>(item_data);
+ break;
+ }
+ }
if (!m_profile)
profileName.buttonText = _(Translations::SettingsAutoFillProfileSetMyProfile.c_str());
- else
+ else if (m_profileName.empty())
profileName.buttonText = ewk_autofill_profile_data_get(m_profile, EWK_PROFILE_NAME);
- m_buttonsMap[0] = profileName;
+ else
+ profileName.buttonText = m_profileName;
+ m_itemData = std::make_shared<ItemData>(profileName);
}
bool SettingsAFProfile::populateList(Evas_Object* genlist)
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- updateButtonMap();
m_naviframe->setLeftButtonVisible(false);
m_naviframe->setRightButtonVisible(false);
m_naviframe->setPrevButtonVisible(true);
m_naviframe->setTitle(_(Translations::SettingsAutoFillProfileTitle.c_str()));
- elm_genlist_clear(genlist);
- appendGenlist(genlist, m_setting_item_class, &m_buttonsMap[0], _select_profile_cb);
+ appendGenlist(genlist, m_setting_item_class, m_itemData.get(), _select_profile_cb);
return true;
}
virtual void updateButtonMap();
static void _select_profile_cb(void* data, Evas_Object*, void*);
protected:
- std::map<unsigned, ItemData> m_buttonsMap;
Ewk_Autofill_Profile* m_profile;
+ std::shared_ptr<ItemData> m_itemData;
+ std::string m_profileName;
};
}
B_SIG<void (int)> setSearchEngineSubText;
B_SIG<void (int)> setContentDestination;
B_SIG<void ()> showTextPopup;
+ B_SIG<void (std::string)> setProfileName;
private:
SettingsPrettySignalConnector(){};