Chromium Code Reviews| 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 ExtensionSystemFactory::GetForProfile(profile())-> | 40 ProfileKeyedAPIFactory<RulesRegistryService>::GetForProfile(profile()); |
|
Devlin
2013/04/26 01:07:09
Add a convenience method in RulesRegistryService f
Patrick Riordan
2013/04/26 01:44:55
Done.
| |
| 41 rules_registry_service(); | |
| 42 rules_registry_ = rules_registry_service->GetRulesRegistry(event_name); | 41 rules_registry_ = rules_registry_service->GetRulesRegistry(event_name); |
| 43 // Raw access to this function is not available to extensions, therefore | 42 // Raw access to this function is not available to extensions, therefore |
| 44 // there should never be a request for a nonexisting rules registry. | 43 // there should never be a request for a nonexisting rules registry. |
| 45 EXTENSION_FUNCTION_VALIDATE(rules_registry_); | 44 EXTENSION_FUNCTION_VALIDATE(rules_registry_); |
| 46 | 45 |
| 47 if (content::BrowserThread::CurrentlyOn(rules_registry_->GetOwnerThread())) { | 46 if (content::BrowserThread::CurrentlyOn(rules_registry_->GetOwnerThread())) { |
| 48 bool success = RunImplOnCorrectThread(); | 47 bool success = RunImplOnCorrectThread(); |
| 49 SendResponse(success); | 48 SendResponse(success); |
| 50 } else { | 49 } else { |
| 51 scoped_refptr<base::MessageLoopProxy> message_loop_proxy = | 50 scoped_refptr<base::MessageLoopProxy> message_loop_proxy = |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 error_ = rules_registry_->GetAllRules(extension_id(), &rules); | 99 error_ = rules_registry_->GetAllRules(extension_id(), &rules); |
| 101 } | 100 } |
| 102 | 101 |
| 103 if (error_.empty()) | 102 if (error_.empty()) |
| 104 results_ = GetRules::Results::Create(rules); | 103 results_ = GetRules::Results::Create(rules); |
| 105 | 104 |
| 106 return error_.empty(); | 105 return error_.empty(); |
| 107 } | 106 } |
| 108 | 107 |
| 109 } // namespace extensions | 108 } // namespace extensions |
| OLD | NEW |