| 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 22 matching lines...) Expand all Loading... |
| 33 scoped_ptr<base::ListValue> list(new base::ListValue()); | 33 scoped_ptr<base::ListValue> list(new base::ListValue()); |
| 34 for (size_t i = 0; i < rules.size(); ++i) | 34 for (size_t i = 0; i < rules.size(); ++i) |
| 35 list->Append(rules[i]->ToValue().release()); | 35 list->Append(rules[i]->ToValue().release()); |
| 36 return list.PassAs<base::Value>(); | 36 return list.PassAs<base::Value>(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 std::vector<linked_ptr<extensions::RulesRegistry::Rule> > RulesFromValue( | 39 std::vector<linked_ptr<extensions::RulesRegistry::Rule> > RulesFromValue( |
| 40 const base::Value* value) { | 40 const base::Value* value) { |
| 41 std::vector<linked_ptr<extensions::RulesRegistry::Rule> > rules; | 41 std::vector<linked_ptr<extensions::RulesRegistry::Rule> > rules; |
| 42 | 42 |
| 43 const base::ListValue* list = NULL; | 43 const base::ListValue* list = nullptr; |
| 44 if (!value || !value->GetAsList(&list)) | 44 if (!value || !value->GetAsList(&list)) |
| 45 return rules; | 45 return rules; |
| 46 | 46 |
| 47 rules.reserve(list->GetSize()); | 47 rules.reserve(list->GetSize()); |
| 48 for (size_t i = 0; i < list->GetSize(); ++i) { | 48 for (size_t i = 0; i < list->GetSize(); ++i) { |
| 49 const base::DictionaryValue* dict = NULL; | 49 const base::DictionaryValue* dict = nullptr; |
| 50 if (!list->GetDictionary(i, &dict)) | 50 if (!list->GetDictionary(i, &dict)) |
| 51 continue; | 51 continue; |
| 52 linked_ptr<extensions::RulesRegistry::Rule> rule( | 52 linked_ptr<extensions::RulesRegistry::Rule> rule( |
| 53 new extensions::RulesRegistry::Rule()); | 53 new extensions::RulesRegistry::Rule()); |
| 54 if (extensions::RulesRegistry::Rule::Populate(*dict, rule.get())) | 54 if (extensions::RulesRegistry::Rule::Populate(*dict, rule.get())) |
| 55 rules.push_back(rule); | 55 rules.push_back(rule); |
| 56 } | 56 } |
| 57 | 57 |
| 58 return rules; | 58 return rules; |
| 59 } | 59 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 73 const std::string& event_name, | 73 const std::string& event_name, |
| 74 content::BrowserThread::ID owner_thread, | 74 content::BrowserThread::ID owner_thread, |
| 75 RulesCacheDelegate* cache_delegate, | 75 RulesCacheDelegate* cache_delegate, |
| 76 const WebViewKey& webview_key) | 76 const WebViewKey& webview_key) |
| 77 : browser_context_(browser_context), | 77 : browser_context_(browser_context), |
| 78 owner_thread_(owner_thread), | 78 owner_thread_(owner_thread), |
| 79 event_name_(event_name), | 79 event_name_(event_name), |
| 80 webview_key_(webview_key), | 80 webview_key_(webview_key), |
| 81 ready_(/*signaled=*/!cache_delegate), // Immediately ready if no cache | 81 ready_(/*signaled=*/!cache_delegate), // Immediately ready if no cache |
| 82 // delegate to wait for. | 82 // delegate to wait for. |
| 83 weak_ptr_factory_(browser_context_ ? this : NULL), | 83 weak_ptr_factory_(browser_context_ ? this : nullptr), |
| 84 last_generated_rule_identifier_id_(0) { | 84 last_generated_rule_identifier_id_(0) { |
| 85 if (cache_delegate) { | 85 if (cache_delegate) { |
| 86 cache_delegate_ = cache_delegate->GetWeakPtr(); | 86 cache_delegate_ = cache_delegate->GetWeakPtr(); |
| 87 cache_delegate->Init(this); | 87 cache_delegate->Init(this); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| 91 std::string RulesRegistry::AddRulesNoFill( | 91 std::string RulesRegistry::AddRulesNoFill( |
| 92 const std::string& extension_id, | 92 const std::string& extension_id, |
| 93 const std::vector<linked_ptr<Rule> >& rules) { | 93 const std::vector<linked_ptr<Rule> >& rules) { |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 for (i = identifiers.begin(); i != identifiers.end(); ++i) | 368 for (i = identifiers.begin(); i != identifiers.end(); ++i) |
| 369 used_rule_identifiers_[extension_id].erase(*i); | 369 used_rule_identifiers_[extension_id].erase(*i); |
| 370 } | 370 } |
| 371 | 371 |
| 372 void RulesRegistry::RemoveAllUsedRuleIdentifiers( | 372 void RulesRegistry::RemoveAllUsedRuleIdentifiers( |
| 373 const std::string& extension_id) { | 373 const std::string& extension_id) { |
| 374 used_rule_identifiers_.erase(extension_id); | 374 used_rule_identifiers_.erase(extension_id); |
| 375 } | 375 } |
| 376 | 376 |
| 377 } // namespace extensions | 377 } // namespace extensions |
| OLD | NEW |