<commit_before>/****************************************************************************
**
** Copyright (C) 2013 Jolla Ltd.
** Contact: <NAME> <<EMAIL>>
**
****************************************************************************/

#include <QVariant>
#include "qmozcontext.h"
#include "settingmanager.h"

SettingManager::SettingManager(QObject *parent)
    : QObject(parent)
{
    m_clearPrivateDataConfItem = new MGConfItem("/apps/sailfish-browser/actions/clear_private_data", this);
    m_searchEngineConfItem = new MGConfItem("/apps/sailfish-browser/settings/search_engine", this);
}

void SettingManager::initialize()
{
    clearPrivateData();
    setSearchEngine();

    connect(m_clearPrivateDataConfItem, SIGNAL(valueChanged()),
            this, SLOT(clearPrivateData()));
    connect(m_searchEngineConfItem, SIGNAL(valueChanged()),
            this, SLOT(setSearchEngine()));
}

void SettingManager::clearPrivateData()
{
    bool actionNeeded = m_clearPrivateDataConfItem->value(QVariant(false)).toBool();

    if (actionNeeded) {
        QMozContext::GetInstance()->sendObserve(QString("clear-private-data"), QString("passwords"));
        QMozContext::GetInstance()->sendObserve(QString("clear-private-data"), QString("cookies"));
        QMozContext::GetInstance()->sendObserve(QString("clear-private-data"), QString("cache"));
        m_clearPrivateDataConfItem->set(QVariant(false));
    }
}<commit_msg>[sailfish-browser] Clear browser history from Settings. Fixes JB#1193<commit_after>/****************************************************************************
**
** Copyright (C) 2013 Jolla Ltd.
** Contact: <NAME> <<EMAIL>>
**
****************************************************************************/

#include <QVariant>
#include "qmozcontext.h"
#include "settingmanager.h"
#include "dbmanager.h"

SettingManager::SettingManager(QObject *parent)
    : QObject(parent)
{
    m_clearPrivateDataConfItem = new MGConfItem("/apps/sailfish-browser/actions/clear_private_data", this);
    m_searchEngineConfItem = new MGConfItem("/apps/sailfish-browser/settings/search_engine", this);
}

void SettingManager::initialize()
{
    clearPrivateData();
    setSearchEngine();

    connect(m_clearPrivateDataConfItem, SIGNAL(valueChanged()),
            this, SLOT(clearPrivateData()));
    connect(m_searchEngineConfItem, SIGNAL(valueChanged()),
            this, SLOT(setSearchEngine()));
}

void SettingManager::clearPrivateData()
{
    bool actionNeeded = m_clearPrivateDataConfItem->value(QVariant(false)).toBool();

    if (actionNeeded) {
        QMozContext::GetInstance()->sendObserve(QString("clear-private-data"), QString("passwords"));
        QMozContext::GetInstance()->sendObserve(QString("clear-private-data"), QString("cookies"));
        QMozContext::GetInstance()->sendObserve(QString("clear-private-data"), QString("cache"));
        DBManager::instance()->clearHistory();
        m_clearPrivateDataConfItem->set(QVariant(false));
    }
}
{'fraction_non_alphanumeric': 0.2397582269979852, 'fraction_numerical': 0.004029550033579583, 'mean_word_length': 6.143884892086331, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2094845', 'n_tokens_mistral': 849, 'n_tokens_neox': 806, 'n_words': 114}