Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1776)

Side by Side Diff: chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc

Issue 2481923002: [WIP] make GURL::path() return a StringPiece (Closed)
Patch Set: thanks asan Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/devtools_ui.cc ('k') | chrome/browser/ui/webui/fileicon_source.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/devtools_ui.cc ('k') | chrome/browser/ui/webui/fileicon_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698