| 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 19 matching lines...) Expand all Loading... |
| 30 std::string event_name; | 30 std::string event_name; |
| 31 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &event_name)); | 31 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &event_name)); |
| 32 return extension_->HasAPIPermission(event_name); | 32 return extension_->HasAPIPermission(event_name); |
| 33 } | 33 } |
| 34 | 34 |
| 35 bool RulesFunction::RunImpl() { | 35 bool RulesFunction::RunImpl() { |
| 36 std::string event_name; | 36 std::string event_name; |
| 37 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &event_name)); | 37 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &event_name)); |
| 38 | 38 |
| 39 RulesRegistryService* rules_registry_service = | 39 RulesRegistryService* rules_registry_service = |
| 40 RulesRegistryService::Get(profile()); | 40 ExtensionSystemFactory::GetForProfile(profile())-> |
| 41 rules_registry_service(); |
| 41 rules_registry_ = rules_registry_service->GetRulesRegistry(event_name); | 42 rules_registry_ = rules_registry_service->GetRulesRegistry(event_name); |
| 42 // Raw access to this function is not available to extensions, therefore | 43 // Raw access to this function is not available to extensions, therefore |
| 43 // there should never be a request for a nonexisting rules registry. | 44 // there should never be a request for a nonexisting rules registry. |
| 44 EXTENSION_FUNCTION_VALIDATE(rules_registry_); | 45 EXTENSION_FUNCTION_VALIDATE(rules_registry_); |
| 45 | 46 |
| 46 if (content::BrowserThread::CurrentlyOn(rules_registry_->owner_thread())) { | 47 if (content::BrowserThread::CurrentlyOn(rules_registry_->owner_thread())) { |
| 47 bool success = RunImplOnCorrectThread(); | 48 bool success = RunImplOnCorrectThread(); |
| 48 SendResponse(success); | 49 SendResponse(success); |
| 49 } else { | 50 } else { |
| 50 scoped_refptr<base::MessageLoopProxy> message_loop_proxy = | 51 scoped_refptr<base::MessageLoopProxy> message_loop_proxy = |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 error_ = rules_registry_->GetAllRules(extension_id(), &rules); | 100 error_ = rules_registry_->GetAllRules(extension_id(), &rules); |
| 100 } | 101 } |
| 101 | 102 |
| 102 if (error_.empty()) | 103 if (error_.empty()) |
| 103 results_ = GetRules::Results::Create(rules); | 104 results_ = GetRules::Results::Create(rules); |
| 104 | 105 |
| 105 return error_.empty(); | 106 return error_.empty(); |
| 106 } | 107 } |
| 107 | 108 |
| 108 } // namespace extensions | 109 } // namespace extensions |
| OLD | NEW |