Chromium Code Reviews| 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 "extensions/browser/api/declarative/rules_registry.h" | 5 #include "extensions/browser/api/declarative/rules_registry.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 | 35 |
| 36 const char kSuccess[] = ""; | 36 const char kSuccess[] = ""; |
| 37 const char kDuplicateRuleId[] = "Duplicate rule ID: %s"; | 37 const char kDuplicateRuleId[] = "Duplicate rule ID: %s"; |
| 38 const char kErrorCannotRemoveManifestRules[] = | 38 const char kErrorCannotRemoveManifestRules[] = |
| 39 "Rules declared in the 'event_rules' manifest field cannot be removed"; | 39 "Rules declared in the 'event_rules' manifest field cannot be removed"; |
| 40 | 40 |
| 41 std::unique_ptr<base::Value> RulesToValue( | 41 std::unique_ptr<base::Value> RulesToValue( |
| 42 const std::vector<linked_ptr<api::events::Rule>>& rules) { | 42 const std::vector<linked_ptr<api::events::Rule>>& rules) { |
| 43 std::unique_ptr<base::ListValue> list(new base::ListValue()); | 43 std::unique_ptr<base::ListValue> list(new base::ListValue()); |
| 44 for (size_t i = 0; i < rules.size(); ++i) | 44 for (size_t i = 0; i < rules.size(); ++i) |
| 45 list->Append(rules[i]->ToValue().release()); | 45 list->Append(rules[i]->ToValue()); |
| 46 return std::move(list); | 46 return std::move(list); |
|
Nico
2016/06/09 16:57:35
huh, why doesn't clang issue a -Wpessimizing-move
dcheng
2016/06/09 17:09:46
C++11 still requires an explicit std::move() here,
| |
| 47 } | 47 } |
| 48 | 48 |
| 49 std::vector<linked_ptr<api::events::Rule>> RulesFromValue( | 49 std::vector<linked_ptr<api::events::Rule>> RulesFromValue( |
| 50 const base::Value* value) { | 50 const base::Value* value) { |
| 51 std::vector<linked_ptr<api::events::Rule>> rules; | 51 std::vector<linked_ptr<api::events::Rule>> rules; |
| 52 | 52 |
| 53 const base::ListValue* list = NULL; | 53 const base::ListValue* list = NULL; |
| 54 if (!value || !value->GetAsList(&list)) | 54 if (!value || !value->GetAsList(&list)) |
| 55 return rules; | 55 return rules; |
| 56 | 56 |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 427 for (i = identifiers.begin(); i != identifiers.end(); ++i) | 427 for (i = identifiers.begin(); i != identifiers.end(); ++i) |
| 428 used_rule_identifiers_[extension_id].erase(*i); | 428 used_rule_identifiers_[extension_id].erase(*i); |
| 429 } | 429 } |
| 430 | 430 |
| 431 void RulesRegistry::RemoveAllUsedRuleIdentifiers( | 431 void RulesRegistry::RemoveAllUsedRuleIdentifiers( |
| 432 const std::string& extension_id) { | 432 const std::string& extension_id) { |
| 433 used_rule_identifiers_.erase(extension_id); | 433 used_rule_identifiers_.erase(extension_id); |
| 434 } | 434 } |
| 435 | 435 |
| 436 } // namespace extensions | 436 } // namespace extensions |
| OLD | NEW |