Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / chromeos / app_mode / kiosk_app_launch_error.cc
blob0a01a207157c37c9bd9822a39ec9afc10216dc84
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/chromeos/app_mode/kiosk_app_launch_error.h"
7 #include "base/prefs/scoped_user_pref_update.h"
8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
10 #include "chrome/grit/generated_resources.h"
11 #include "ui/base/l10n/l10n_util.h"
13 namespace chromeos {
15 namespace {
17 // Key under "kiosk" dictionary to store last launch error.
18 const char kKeyLaunchError[] = "launch_error";
20 } // namespace
22 // static
23 std::string KioskAppLaunchError::GetErrorMessage(Error error) {
24 switch (error) {
25 case NONE:
26 return std::string();
28 case HAS_PENDING_LAUNCH:
29 case NOT_KIOSK_ENABLED:
30 case UNABLE_TO_RETRIEVE_HASH:
31 case POLICY_LOAD_FAILED:
32 return l10n_util::GetStringUTF8(IDS_KIOSK_APP_FAILED_TO_LAUNCH);
34 case CRYPTOHOMED_NOT_RUNNING:
35 case ALREADY_MOUNTED:
36 case UNABLE_TO_MOUNT:
37 case UNABLE_TO_REMOVE:
38 return l10n_util::GetStringUTF8(IDS_KIOSK_APP_ERROR_UNABLE_TO_MOUNT);
40 case UNABLE_TO_INSTALL:
41 return l10n_util::GetStringUTF8(IDS_KIOSK_APP_ERROR_UNABLE_TO_INSTALL);
43 case USER_CANCEL:
44 return l10n_util::GetStringUTF8(IDS_KIOSK_APP_ERROR_USER_CANCEL);
46 case UNABLE_TO_DOWNLOAD:
47 return l10n_util::GetStringUTF8(IDS_KIOSK_APP_ERROR_UNABLE_TO_DOWNLOAD);
49 case UNABLE_TO_LAUNCH:
50 return l10n_util::GetStringUTF8(IDS_KIOSK_APP_ERROR_UNABLE_TO_LAUNCH);
53 NOTREACHED() << "Unknown kiosk app launch error, error=" << error;
54 return l10n_util::GetStringUTF8(IDS_KIOSK_APP_FAILED_TO_LAUNCH);
57 // static
58 void KioskAppLaunchError::Save(KioskAppLaunchError::Error error) {
59 PrefService* local_state = g_browser_process->local_state();
60 DictionaryPrefUpdate dict_update(local_state,
61 KioskAppManager::kKioskDictionaryName);
62 dict_update->SetInteger(kKeyLaunchError, error);
65 // static
66 KioskAppLaunchError::Error KioskAppLaunchError::Get() {
67 PrefService* local_state = g_browser_process->local_state();
68 const base::DictionaryValue* dict =
69 local_state->GetDictionary(KioskAppManager::kKioskDictionaryName);
71 int error;
72 if (dict->GetInteger(kKeyLaunchError, &error))
73 return static_cast<KioskAppLaunchError::Error>(error);
75 return KioskAppLaunchError::NONE;
78 // static
79 void KioskAppLaunchError::Clear() {
80 PrefService* local_state = g_browser_process->local_state();
81 DictionaryPrefUpdate dict_update(local_state,
82 KioskAppManager::kKioskDictionaryName);
83 dict_update->Remove(kKeyLaunchError, NULL);
86 } // namespace chromeos