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/browser/extensions/api/declarative/declarative_api.h" | 5 #include "chrome/browser/extensions/api/declarative/declarative_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/task_runner_util.h" | 9 #include "base/task_runner_util.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 return true; | 71 return true; |
72 } | 72 } |
73 | 73 |
74 bool AddRulesFunction::RunImplOnCorrectThread() { | 74 bool AddRulesFunction::RunImplOnCorrectThread() { |
75 scoped_ptr<AddRules::Params> params(AddRules::Params::Create(*args_)); | 75 scoped_ptr<AddRules::Params> params(AddRules::Params::Create(*args_)); |
76 EXTENSION_FUNCTION_VALIDATE(params.get()); | 76 EXTENSION_FUNCTION_VALIDATE(params.get()); |
77 | 77 |
78 error_ = rules_registry_->AddRules(extension_id(), params->rules); | 78 error_ = rules_registry_->AddRules(extension_id(), params->rules); |
79 | 79 |
80 if (error_.empty()) | 80 if (error_.empty()) |
81 result_.reset(AddRules::Result::Create(params->rules)); | 81 SetResult(AddRules::Result::Create(params->rules)); |
82 | 82 |
83 return error_.empty(); | 83 return error_.empty(); |
84 } | 84 } |
85 | 85 |
86 bool RemoveRulesFunction::RunImplOnCorrectThread() { | 86 bool RemoveRulesFunction::RunImplOnCorrectThread() { |
87 scoped_ptr<RemoveRules::Params> params(RemoveRules::Params::Create(*args_)); | 87 scoped_ptr<RemoveRules::Params> params(RemoveRules::Params::Create(*args_)); |
88 EXTENSION_FUNCTION_VALIDATE(params.get()); | 88 EXTENSION_FUNCTION_VALIDATE(params.get()); |
89 | 89 |
90 if (params->rule_identifiers.get()) { | 90 if (params->rule_identifiers.get()) { |
91 error_ = rules_registry_->RemoveRules(extension_id(), | 91 error_ = rules_registry_->RemoveRules(extension_id(), |
(...skipping 12 matching lines...) Expand all Loading... |
104 std::vector<linked_ptr<Rule> > rules; | 104 std::vector<linked_ptr<Rule> > rules; |
105 if (params->rule_identifiers.get()) { | 105 if (params->rule_identifiers.get()) { |
106 error_ = rules_registry_->GetRules(extension_id(), | 106 error_ = rules_registry_->GetRules(extension_id(), |
107 *params->rule_identifiers, | 107 *params->rule_identifiers, |
108 &rules); | 108 &rules); |
109 } else { | 109 } else { |
110 error_ = rules_registry_->GetAllRules(extension_id(), &rules); | 110 error_ = rules_registry_->GetAllRules(extension_id(), &rules); |
111 } | 111 } |
112 | 112 |
113 if (error_.empty()) | 113 if (error_.empty()) |
114 result_.reset(GetRules::Result::Create(rules)); | 114 SetResult(GetRules::Result::Create(rules)); |
115 | 115 |
116 return error_.empty(); | 116 return error_.empty(); |
117 } | 117 } |
118 | 118 |
119 } // namespace extensions | 119 } // namespace extensions |
OLD | NEW |