This source file includes following definitions.
- GetErrorMessage
- Save
- Get
- Clear
#include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
#include "base/prefs/scoped_user_pref_update.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
namespace chromeos {
namespace {
const char kKeyLaunchError[] = "launch_error";
}
std::string KioskAppLaunchError::GetErrorMessage(Error error) {
switch (error) {
case NONE:
return std::string();
case HAS_PENDING_LAUNCH:
case NOT_KIOSK_ENABLED:
case UNABLE_TO_RETRIEVE_HASH:
case POLICY_LOAD_FAILED:
return l10n_util::GetStringUTF8(IDS_KIOSK_APP_FAILED_TO_LAUNCH);
case CRYPTOHOMED_NOT_RUNNING:
case ALREADY_MOUNTED:
case UNABLE_TO_MOUNT:
case UNABLE_TO_REMOVE:
return l10n_util::GetStringUTF8(IDS_KIOSK_APP_ERROR_UNABLE_TO_MOUNT);
case UNABLE_TO_INSTALL:
return l10n_util::GetStringUTF8(IDS_KIOSK_APP_ERROR_UNABLE_TO_INSTALL);
case USER_CANCEL:
return l10n_util::GetStringUTF8(IDS_KIOSK_APP_ERROR_USER_CANCEL);
}
NOTREACHED() << "Unknown kiosk app launch error, error=" << error;
return l10n_util::GetStringUTF8(IDS_KIOSK_APP_FAILED_TO_LAUNCH);
}
void KioskAppLaunchError::Save(KioskAppLaunchError::Error error) {
PrefService* local_state = g_browser_process->local_state();
DictionaryPrefUpdate dict_update(local_state,
KioskAppManager::kKioskDictionaryName);
dict_update->SetInteger(kKeyLaunchError, error);
}
KioskAppLaunchError::Error KioskAppLaunchError::Get() {
PrefService* local_state = g_browser_process->local_state();
const base::DictionaryValue* dict =
local_state->GetDictionary(KioskAppManager::kKioskDictionaryName);
int error;
if (dict->GetInteger(kKeyLaunchError, &error))
return static_cast<KioskAppLaunchError::Error>(error);
return KioskAppLaunchError::NONE;
}
void KioskAppLaunchError::Clear() {
PrefService* local_state = g_browser_process->local_state();
DictionaryPrefUpdate dict_update(local_state,
KioskAppManager::kKioskDictionaryName);
dict_update->Remove(kKeyLaunchError, NULL);
}
}