| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" | 12 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" |
| 13 #include "chrome/browser/chromeos/app_mode/kiosk_app_launcher.h" | |
| 14 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 13 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 15 #include "chrome/browser/policy/browser_policy_connector.h" | 14 #include "chrome/browser/policy/browser_policy_connector.h" |
| 16 #include "chromeos/chromeos_switches.h" | 15 #include "chromeos/chromeos_switches.h" |
| 17 #include "content/public/browser/notification_details.h" | 16 #include "content/public/browser/notification_details.h" |
| 18 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 19 #include "content/public/browser/web_ui.h" | 18 #include "content/public/browser/web_ui.h" |
| 20 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 22 #include "ui/webui/web_ui_util.h" | 21 #include "ui/webui/web_ui_util.h" |
| 23 | 22 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 40 l10n_util::GetStringUTF16(IDS_KIOSK_APPS_BUTTON)); | 39 l10n_util::GetStringUTF16(IDS_KIOSK_APPS_BUTTON)); |
| 41 } | 40 } |
| 42 | 41 |
| 43 void KioskAppMenuHandler::RegisterMessages() { | 42 void KioskAppMenuHandler::RegisterMessages() { |
| 44 web_ui()->RegisterMessageCallback("initializeKioskApps", | 43 web_ui()->RegisterMessageCallback("initializeKioskApps", |
| 45 base::Bind(&KioskAppMenuHandler::HandleInitializeKioskApps, | 44 base::Bind(&KioskAppMenuHandler::HandleInitializeKioskApps, |
| 46 base::Unretained(this))); | 45 base::Unretained(this))); |
| 47 web_ui()->RegisterMessageCallback("kioskAppsLoaded", | 46 web_ui()->RegisterMessageCallback("kioskAppsLoaded", |
| 48 base::Bind(&KioskAppMenuHandler::HandleKioskAppsLoaded, | 47 base::Bind(&KioskAppMenuHandler::HandleKioskAppsLoaded, |
| 49 base::Unretained(this))); | 48 base::Unretained(this))); |
| 50 web_ui()->RegisterMessageCallback("launchKioskApp", | |
| 51 base::Bind(&KioskAppMenuHandler::HandleLaunchKioskApps, | |
| 52 base::Unretained(this))); | |
| 53 web_ui()->RegisterMessageCallback("checkKioskAppLaunchError", | 49 web_ui()->RegisterMessageCallback("checkKioskAppLaunchError", |
| 54 base::Bind(&KioskAppMenuHandler::HandleCheckKioskAppLaunchError, | 50 base::Bind(&KioskAppMenuHandler::HandleCheckKioskAppLaunchError, |
| 55 base::Unretained(this))); | 51 base::Unretained(this))); |
| 56 } | 52 } |
| 57 | 53 |
| 58 void KioskAppMenuHandler::SendKioskApps() { | 54 void KioskAppMenuHandler::SendKioskApps() { |
| 59 if (!initialized_) | 55 if (!initialized_) |
| 60 return; | 56 return; |
| 61 | 57 |
| 62 KioskAppManager::Apps apps; | 58 KioskAppManager::Apps apps; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } | 100 } |
| 105 | 101 |
| 106 void KioskAppMenuHandler::HandleKioskAppsLoaded( | 102 void KioskAppMenuHandler::HandleKioskAppsLoaded( |
| 107 const base::ListValue* args) { | 103 const base::ListValue* args) { |
| 108 content::NotificationService::current()->Notify( | 104 content::NotificationService::current()->Notify( |
| 109 chrome::NOTIFICATION_KIOSK_APPS_LOADED, | 105 chrome::NOTIFICATION_KIOSK_APPS_LOADED, |
| 110 content::NotificationService::AllSources(), | 106 content::NotificationService::AllSources(), |
| 111 content::NotificationService::NoDetails()); | 107 content::NotificationService::NoDetails()); |
| 112 } | 108 } |
| 113 | 109 |
| 114 void KioskAppMenuHandler::HandleLaunchKioskApps(const base::ListValue* args) { | |
| 115 std::string app_id; | |
| 116 CHECK(args->GetString(0, &app_id)); | |
| 117 | |
| 118 KioskAppManager::App app_data; | |
| 119 CHECK(KioskAppManager::Get()->GetApp(app_id, &app_data)); | |
| 120 | |
| 121 ExistingUserController::current_controller()->PrepareKioskAppLaunch(); | |
| 122 | |
| 123 // KioskAppLauncher deletes itself when done. | |
| 124 (new KioskAppLauncher(KioskAppManager::Get(), app_id))->Start(); | |
| 125 } | |
| 126 | |
| 127 void KioskAppMenuHandler::HandleCheckKioskAppLaunchError( | 110 void KioskAppMenuHandler::HandleCheckKioskAppLaunchError( |
| 128 const base::ListValue* args) { | 111 const base::ListValue* args) { |
| 129 KioskAppLaunchError::Error error = KioskAppLaunchError::Get(); | 112 KioskAppLaunchError::Error error = KioskAppLaunchError::Get(); |
| 130 if (error == KioskAppLaunchError::NONE) | 113 if (error == KioskAppLaunchError::NONE) |
| 131 return; | 114 return; |
| 132 KioskAppLaunchError::Clear(); | 115 KioskAppLaunchError::Clear(); |
| 133 | 116 |
| 134 const std::string error_message = KioskAppLaunchError::GetErrorMessage(error); | 117 const std::string error_message = KioskAppLaunchError::GetErrorMessage(error); |
| 135 web_ui()->CallJavascriptFunction("login.AppsMenuButton.showError", | 118 web_ui()->CallJavascriptFunction("login.AppsMenuButton.showError", |
| 136 base::StringValue(error_message)); | 119 base::StringValue(error_message)); |
| 137 } | 120 } |
| 138 | 121 |
| 139 void KioskAppMenuHandler::OnKioskAppsSettingsChanged() { | 122 void KioskAppMenuHandler::OnKioskAppsSettingsChanged() { |
| 140 SendKioskApps(); | 123 SendKioskApps(); |
| 141 } | 124 } |
| 142 | 125 |
| 143 void KioskAppMenuHandler::OnKioskAppDataChanged(const std::string& app_id) { | 126 void KioskAppMenuHandler::OnKioskAppDataChanged(const std::string& app_id) { |
| 144 SendKioskApps(); | 127 SendKioskApps(); |
| 145 } | 128 } |
| 146 | 129 |
| 147 } // namespace chromeos | 130 } // namespace chromeos |
| OLD | NEW |