| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 .GetImageNamed(IDR_APP_DEFAULT_ICON) | 113 .GetImageNamed(IDR_APP_DEFAULT_ICON) |
| 114 .ToSkBitmap()); | 114 .ToSkBitmap()); |
| 115 } else { | 115 } else { |
| 116 icon_url = webui::GetBitmapDataUrl(*app_data.icon.bitmap()); | 116 icon_url = webui::GetBitmapDataUrl(*app_data.icon.bitmap()); |
| 117 } | 117 } |
| 118 app_info->SetString("iconUrl", icon_url); | 118 app_info->SetString("iconUrl", icon_url); |
| 119 | 119 |
| 120 apps_list.Append(app_info.release()); | 120 apps_list.Append(app_info.release()); |
| 121 } | 121 } |
| 122 | 122 |
| 123 web_ui()->CallJavascriptFunction(EnableNewKioskUI() ? | 123 web_ui()->CallJavascriptFunctionUnsafe( |
| 124 kKioskSetAppsNewAPI : kKioskSetAppsOldAPI, | 124 EnableNewKioskUI() ? kKioskSetAppsNewAPI : kKioskSetAppsOldAPI, |
| 125 apps_list); | 125 apps_list); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void KioskAppMenuHandler::HandleInitializeKioskApps( | 128 void KioskAppMenuHandler::HandleInitializeKioskApps( |
| 129 const base::ListValue* args) { | 129 const base::ListValue* args) { |
| 130 is_webui_initialized_ = true; | 130 is_webui_initialized_ = true; |
| 131 SendKioskApps(); | 131 SendKioskApps(); |
| 132 UpdateState(NetworkError::ERROR_REASON_UPDATE); | 132 UpdateState(NetworkError::ERROR_REASON_UPDATE); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void KioskAppMenuHandler::HandleKioskAppsLoaded( | 135 void KioskAppMenuHandler::HandleKioskAppsLoaded( |
| 136 const base::ListValue* args) { | 136 const base::ListValue* args) { |
| 137 content::NotificationService::current()->Notify( | 137 content::NotificationService::current()->Notify( |
| 138 chrome::NOTIFICATION_KIOSK_APPS_LOADED, | 138 chrome::NOTIFICATION_KIOSK_APPS_LOADED, |
| 139 content::NotificationService::AllSources(), | 139 content::NotificationService::AllSources(), |
| 140 content::NotificationService::NoDetails()); | 140 content::NotificationService::NoDetails()); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void KioskAppMenuHandler::HandleCheckKioskAppLaunchError( | 143 void KioskAppMenuHandler::HandleCheckKioskAppLaunchError( |
| 144 const base::ListValue* args) { | 144 const base::ListValue* args) { |
| 145 KioskAppLaunchError::Error error = KioskAppLaunchError::Get(); | 145 KioskAppLaunchError::Error error = KioskAppLaunchError::Get(); |
| 146 if (error == KioskAppLaunchError::NONE) | 146 if (error == KioskAppLaunchError::NONE) |
| 147 return; | 147 return; |
| 148 KioskAppLaunchError::Clear(); | 148 KioskAppLaunchError::Clear(); |
| 149 | 149 |
| 150 const std::string error_message = KioskAppLaunchError::GetErrorMessage(error); | 150 const std::string error_message = KioskAppLaunchError::GetErrorMessage(error); |
| 151 bool new_kiosk_ui = EnableNewKioskUI(); | 151 bool new_kiosk_ui = EnableNewKioskUI(); |
| 152 web_ui()->CallJavascriptFunction(new_kiosk_ui ? | 152 web_ui()->CallJavascriptFunctionUnsafe( |
| 153 kKioskShowErrorNewAPI : kKioskShowErrorOldAPI, | 153 new_kiosk_ui ? kKioskShowErrorNewAPI : kKioskShowErrorOldAPI, |
| 154 base::StringValue(error_message)); | 154 base::StringValue(error_message)); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void KioskAppMenuHandler::OnKioskAppsSettingsChanged() { | 157 void KioskAppMenuHandler::OnKioskAppsSettingsChanged() { |
| 158 SendKioskApps(); | 158 SendKioskApps(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void KioskAppMenuHandler::OnKioskAppDataChanged(const std::string& app_id) { | 161 void KioskAppMenuHandler::OnKioskAppDataChanged(const std::string& app_id) { |
| 162 SendKioskApps(); | 162 SendKioskApps(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void KioskAppMenuHandler::OnKioskAppDataLoadFailure(const std::string& app_id) { | 165 void KioskAppMenuHandler::OnKioskAppDataLoadFailure(const std::string& app_id) { |
| 166 SendKioskApps(); | 166 SendKioskApps(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void KioskAppMenuHandler::UpdateState(NetworkError::ErrorReason reason) { | 169 void KioskAppMenuHandler::UpdateState(NetworkError::ErrorReason reason) { |
| 170 if (network_state_informer_->state() == NetworkStateInformer::ONLINE) | 170 if (network_state_informer_->state() == NetworkStateInformer::ONLINE) |
| 171 KioskAppManager::Get()->RetryFailedAppDataFetch(); | 171 KioskAppManager::Get()->RetryFailedAppDataFetch(); |
| 172 } | 172 } |
| 173 | 173 |
| 174 } // namespace chromeos | 174 } // namespace chromeos |
| OLD | NEW |