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

Side by Side Diff: chrome/browser/extensions/api/declarative/initializing_rules_registry.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 months 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 | Annotate | Revision Log
OLDNEW
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/browser/extensions/api/declarative/initializing_rules_registry. h" 5 #include "chrome/browser/extensions/api/declarative/initializing_rules_registry. h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 10
(...skipping 21 matching lines...) Expand all
32 return delegate_->AddRules(extension_id, rules); 32 return delegate_->AddRules(extension_id, rules);
33 } 33 }
34 34
35 std::string InitializingRulesRegistry::RemoveRules( 35 std::string InitializingRulesRegistry::RemoveRules(
36 const std::string& extension_id, 36 const std::string& extension_id,
37 const std::vector<std::string>& rule_identifiers) { 37 const std::vector<std::string>& rule_identifiers) {
38 std::string error = delegate_->RemoveRules(extension_id, rule_identifiers); 38 std::string error = delegate_->RemoveRules(extension_id, rule_identifiers);
39 if (!error.empty()) 39 if (!error.empty())
40 return error; 40 return error;
41 RemoveUsedRuleIdentifiers(extension_id, rule_identifiers); 41 RemoveUsedRuleIdentifiers(extension_id, rule_identifiers);
42 return ""; 42 return std::string();
43 } 43 }
44 44
45 std::string InitializingRulesRegistry::RemoveAllRules( 45 std::string InitializingRulesRegistry::RemoveAllRules(
46 const std::string& extension_id) { 46 const std::string& extension_id) {
47 std::string error = delegate_->RemoveAllRules(extension_id); 47 std::string error = delegate_->RemoveAllRules(extension_id);
48 if (!error.empty()) 48 if (!error.empty())
49 return error; 49 return error;
50 RemoveAllUsedRuleIdentifiers(extension_id); 50 RemoveAllUsedRuleIdentifiers(extension_id);
51 return ""; 51 return std::string();
52 } 52 }
53 53
54 std::string InitializingRulesRegistry::GetRules( 54 std::string InitializingRulesRegistry::GetRules(
55 const std::string& extension_id, 55 const std::string& extension_id,
56 const std::vector<std::string>& rule_identifiers, 56 const std::vector<std::string>& rule_identifiers,
57 std::vector<linked_ptr<RulesRegistry::Rule> >* out) { 57 std::vector<linked_ptr<RulesRegistry::Rule> >* out) {
58 return delegate_->GetRules(extension_id, rule_identifiers, out); 58 return delegate_->GetRules(extension_id, rule_identifiers, out);
59 } 59 }
60 60
61 std::string InitializingRulesRegistry::GetAllRules( 61 std::string InitializingRulesRegistry::GetAllRules(
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // Now we generate IDs in case they were not specificed in the rules. This 115 // Now we generate IDs in case they were not specificed in the rules. This
116 // cannot fail so we do not need to keep track of a rollback log. 116 // cannot fail so we do not need to keep track of a rollback log.
117 for (std::vector<linked_ptr<RulesRegistry::Rule> >::const_iterator i = 117 for (std::vector<linked_ptr<RulesRegistry::Rule> >::const_iterator i =
118 rules.begin(); i != rules.end(); ++i) { 118 rules.begin(); i != rules.end(); ++i) {
119 RulesRegistry::Rule* rule = i->get(); 119 RulesRegistry::Rule* rule = i->get();
120 if (!rule->id.get()) { 120 if (!rule->id.get()) {
121 rule->id.reset(new std::string(GenerateUniqueId(extension_id))); 121 rule->id.reset(new std::string(GenerateUniqueId(extension_id)));
122 used_rule_identifiers_[extension_id].insert(*(rule->id)); 122 used_rule_identifiers_[extension_id].insert(*(rule->id));
123 } 123 }
124 } 124 }
125 return ""; 125 return std::string();
126 } 126 }
127 127
128 void InitializingRulesRegistry::FillInOptionalPriorities( 128 void InitializingRulesRegistry::FillInOptionalPriorities(
129 const std::vector<linked_ptr<RulesRegistry::Rule> >& rules) { 129 const std::vector<linked_ptr<RulesRegistry::Rule> >& rules) {
130 std::vector<linked_ptr<RulesRegistry::Rule> >::const_iterator i; 130 std::vector<linked_ptr<RulesRegistry::Rule> >::const_iterator i;
131 for (i = rules.begin(); i != rules.end(); ++i) { 131 for (i = rules.begin(); i != rules.end(); ++i) {
132 if (!(*i)->priority.get()) 132 if (!(*i)->priority.get())
133 (*i)->priority.reset(new int(DEFAULT_PRIORITY)); 133 (*i)->priority.reset(new int(DEFAULT_PRIORITY));
134 } 134 }
135 } 135 }
136 136
137 void InitializingRulesRegistry::RemoveUsedRuleIdentifiers( 137 void InitializingRulesRegistry::RemoveUsedRuleIdentifiers(
138 const std::string& extension_id, 138 const std::string& extension_id,
139 const std::vector<std::string>& identifiers) { 139 const std::vector<std::string>& identifiers) {
140 std::vector<std::string>::const_iterator i; 140 std::vector<std::string>::const_iterator i;
141 for (i = identifiers.begin(); i != identifiers.end(); ++i) 141 for (i = identifiers.begin(); i != identifiers.end(); ++i)
142 used_rule_identifiers_[extension_id].erase(*i); 142 used_rule_identifiers_[extension_id].erase(*i);
143 } 143 }
144 144
145 void InitializingRulesRegistry::RemoveAllUsedRuleIdentifiers( 145 void InitializingRulesRegistry::RemoveAllUsedRuleIdentifiers(
146 const std::string& extension_id) { 146 const std::string& extension_id) {
147 used_rule_identifiers_.erase(extension_id); 147 used_rule_identifiers_.erase(extension_id);
148 } 148 }
149 149
150 } // namespace extensions 150 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698