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/declarative_api.h" | 5 #include "extensions/browser/api/declarative/declarative_api.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 DCHECK(rules_registry_.get()); | 149 DCHECK(rules_registry_.get()); |
150 // Raw access to this function is not available to extensions, therefore | 150 // Raw access to this function is not available to extensions, therefore |
151 // there should never be a request for a nonexisting rules registry. | 151 // there should never be a request for a nonexisting rules registry. |
152 EXTENSION_FUNCTION_VALIDATE(rules_registry_.get()); | 152 EXTENSION_FUNCTION_VALIDATE(rules_registry_.get()); |
153 | 153 |
154 if (content::BrowserThread::CurrentlyOn(rules_registry_->owner_thread())) { | 154 if (content::BrowserThread::CurrentlyOn(rules_registry_->owner_thread())) { |
155 bool success = RunAsyncOnCorrectThread(); | 155 bool success = RunAsyncOnCorrectThread(); |
156 SendResponse(success); | 156 SendResponse(success); |
157 } else { | 157 } else { |
158 scoped_refptr<base::SingleThreadTaskRunner> thread_task_runner = | 158 scoped_refptr<base::SingleThreadTaskRunner> thread_task_runner = |
159 content::BrowserThread::GetMessageLoopProxyForThread( | 159 content::BrowserThread::GetTaskRunnerForThread( |
160 rules_registry_->owner_thread()); | 160 rules_registry_->owner_thread()); |
161 base::PostTaskAndReplyWithResult( | 161 base::PostTaskAndReplyWithResult( |
162 thread_task_runner.get(), FROM_HERE, | 162 thread_task_runner.get(), FROM_HERE, |
163 base::Bind(&RulesFunction::RunAsyncOnCorrectThread, this), | 163 base::Bind(&RulesFunction::RunAsyncOnCorrectThread, this), |
164 base::Bind(&RulesFunction::SendResponse, this)); | 164 base::Bind(&RulesFunction::SendResponse, this)); |
165 } | 165 } |
166 | 166 |
167 return true; | 167 return true; |
168 } | 168 } |
169 | 169 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 219 |
220 std::unique_ptr<base::ListValue> rules_value(new base::ListValue()); | 220 std::unique_ptr<base::ListValue> rules_value(new base::ListValue()); |
221 for (const auto& rule : rules) | 221 for (const auto& rule : rules) |
222 rules_value->Append(rule->ToValue()); | 222 rules_value->Append(rule->ToValue()); |
223 SetResult(std::move(rules_value)); | 223 SetResult(std::move(rules_value)); |
224 | 224 |
225 return true; | 225 return true; |
226 } | 226 } |
227 | 227 |
228 } // namespace extensions | 228 } // namespace extensions |
OLD | NEW |