OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/extensions/api/extension_api.h" | 5 #include "chrome/common/extensions/api/extension_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 } | 261 } |
262 | 262 |
263 bool ExtensionAPI::IsPrivileged(const std::string& full_name) { | 263 bool ExtensionAPI::IsPrivileged(const std::string& full_name) { |
264 std::string api_name; | 264 std::string api_name; |
265 std::string child_name; | 265 std::string child_name; |
266 | 266 |
267 { | 267 { |
268 std::vector<std::string> split; | 268 std::vector<std::string> split; |
269 base::SplitString(full_name, '.', &split); | 269 base::SplitString(full_name, '.', &split); |
270 std::reverse(split.begin(), split.end()); | 270 std::reverse(split.begin(), split.end()); |
271 CHECK(!split.empty()); // |full_name| was empty or only whitespace. | |
272 | 271 |
273 api_name = split.back(); | 272 api_name = split.back(); |
274 split.pop_back(); | 273 split.pop_back(); |
275 if (api_name == "experimental") { | 274 if (api_name == "experimental") { |
276 CHECK(!split.empty()); // |full_name| was "experimental" alone. | |
277 api_name += "." + split.back(); | 275 api_name += "." + split.back(); |
278 split.pop_back(); | 276 split.pop_back(); |
279 } | 277 } |
280 | 278 |
281 // This only really works properly if split.size() == 1, however: | 279 // This only really works properly if split.size() == 1, however: |
282 // - if it's empty, it's ok to leave child_name empty; presumably there's | 280 // - if it's empty, it's ok to leave child_name empty; presumably there's |
283 // no functions or events with empty names. | 281 // no functions or events with empty names. |
284 // - if it's > 1, we can just do our best. | 282 // - if it's > 1, we can just do our best. |
285 if (split.size() > 0) | 283 if (split.size() > 0) |
286 child_name = split[0]; | 284 child_name = split[0]; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 } | 457 } |
460 } | 458 } |
461 | 459 |
462 void ExtensionAPI::LoadAllSchemas() { | 460 void ExtensionAPI::LoadAllSchemas() { |
463 while (unloaded_schemas_.size()) { | 461 while (unloaded_schemas_.size()) { |
464 LoadSchema(unloaded_schemas_.begin()->second); | 462 LoadSchema(unloaded_schemas_.begin()->second); |
465 } | 463 } |
466 } | 464 } |
467 | 465 |
468 } // namespace extensions | 466 } // namespace extensions |
OLD | NEW |