| 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/extensions/chromeos/kiosk_apps_handler.h" | 5 #include "chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 GURL webstore_base_url = | 82 GURL webstore_base_url = |
| 83 GURL(extension_urls::GetWebstoreItemDetailURLPrefix()); | 83 GURL(extension_urls::GetWebstoreItemDetailURLPrefix()); |
| 84 | 84 |
| 85 if (webstore_url.scheme() != webstore_base_url.scheme() || | 85 if (webstore_url.scheme() != webstore_base_url.scheme() || |
| 86 webstore_url.host() != webstore_base_url.host() || | 86 webstore_url.host() != webstore_base_url.host() || |
| 87 !base::StartsWith(webstore_url.path(), webstore_base_url.path(), | 87 !base::StartsWith(webstore_url.path(), webstore_base_url.path(), |
| 88 base::CompareCase::SENSITIVE)) { | 88 base::CompareCase::SENSITIVE)) { |
| 89 return false; | 89 return false; |
| 90 } | 90 } |
| 91 | 91 |
| 92 const std::string path = webstore_url.path(); | 92 const base::StringPiece path = webstore_url.path(); |
| 93 const size_t last_slash = path.rfind('/'); | 93 const size_t last_slash = path.rfind('/'); |
| 94 if (last_slash == std::string::npos) | 94 if (last_slash == std::string::npos) |
| 95 return false; | 95 return false; |
| 96 | 96 |
| 97 const std::string candidate_id = path.substr(last_slash + 1); | 97 const std::string candidate_id = path.substr(last_slash + 1).as_string(); |
| 98 if (!crx_file::id_util::IdIsValid(candidate_id)) | 98 if (!crx_file::id_util::IdIsValid(candidate_id)) |
| 99 return false; | 99 return false; |
| 100 | 100 |
| 101 *app_id = candidate_id; | 101 *app_id = candidate_id; |
| 102 return true; | 102 return true; |
| 103 } | 103 } |
| 104 | 104 |
| 105 } // namespace | 105 } // namespace |
| 106 | 106 |
| 107 KioskAppsHandler::KioskAppsHandler(OwnerSettingsServiceChromeOS* service) | 107 KioskAppsHandler::KioskAppsHandler(OwnerSettingsServiceChromeOS* service) |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 | 358 |
| 359 void KioskAppsHandler::ShowError(const std::string& app_id) { | 359 void KioskAppsHandler::ShowError(const std::string& app_id) { |
| 360 base::StringValue app_id_value(app_id); | 360 base::StringValue app_id_value(app_id); |
| 361 web_ui()->CallJavascriptFunctionUnsafe( | 361 web_ui()->CallJavascriptFunctionUnsafe( |
| 362 "extensions.KioskAppsOverlay.showError", app_id_value); | 362 "extensions.KioskAppsOverlay.showError", app_id_value); |
| 363 | 363 |
| 364 kiosk_app_manager_->RemoveApp(app_id, owner_settings_service_); | 364 kiosk_app_manager_->RemoveApp(app_id, owner_settings_service_); |
| 365 } | 365 } |
| 366 | 366 |
| 367 } // namespace chromeos | 367 } // namespace chromeos |
| OLD | NEW |