diff options
author | wjmaclean <wjmaclean@chromium.org> | 2014-09-10 10:32:22 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-10 17:36:12 +0000 |
commit | 97b60ee352ca47814774ffe9a4bebfc6d44b3e05 (patch) | |
tree | a67c2fda61dcd67253fa46fcf2258e211d398474 | |
parent | 05d507c5ff8d67311e264c2ee9c9edc4729346b1 (diff) | |
download | chromium_src-97b60ee352ca47814774ffe9a4bebfc6d44b3e05.zip chromium_src-97b60ee352ca47814774ffe9a4bebfc6d44b3e05.tar.gz chromium_src-97b60ee352ca47814774ffe9a4bebfc6d44b3e05.tar.bz2 |
Move declarative api files to extensions/browser/api/declarative.
This cl also includes some small changes to remove
chrome/extensions dependencies in these files, e.g.
it gets IsIncognitoEnabled() from ExtensionPrefs()
instead of util::IsIncognitoEnabled().
BUG=352293
Review URL: https://codereview.chromium.org/550403003
Cr-Commit-Position: refs/heads/master@{#294186}
34 files changed, 126 insertions, 90 deletions
diff --git a/chrome/browser/extensions/api/chrome_extensions_api_client.cc b/chrome/browser/extensions/api/chrome_extensions_api_client.cc index 0eeb963..c4d7de5 100644 --- a/chrome/browser/extensions/api/chrome_extensions_api_client.cc +++ b/chrome/browser/extensions/api/chrome_extensions_api_client.cc @@ -5,6 +5,7 @@ #include "chrome/browser/extensions/api/chrome_extensions_api_client.h" #include "base/files/file_path.h" +#include "chrome/browser/extensions/api/declarative/rules_registry_service.h" #include "chrome/browser/extensions/api/storage/sync_value_store_cache.h" #include "chrome/browser/guest_view/app_view/chrome_app_view_guest_delegate.h" #include "chrome/browser/guest_view/extension_options/extension_options_guest.h" @@ -71,4 +72,12 @@ void ChromeExtensionsAPIClient::RegisterGuestViewTypes() { ExtensionOptionsGuest::Register(); } +scoped_refptr<RulesRegistry> ChromeExtensionsAPIClient::GetRulesRegistry( + content::BrowserContext* browser_context, + const RulesRegistry::WebViewKey& webview_key, + const std::string& event_name) { + return RulesRegistryService::Get(browser_context)-> + GetRulesRegistry(webview_key, event_name); +} + } // namespace extensions diff --git a/chrome/browser/extensions/api/chrome_extensions_api_client.h b/chrome/browser/extensions/api/chrome_extensions_api_client.h index 0240199..c72f211 100644 --- a/chrome/browser/extensions/api/chrome_extensions_api_client.h +++ b/chrome/browser/extensions/api/chrome_extensions_api_client.h @@ -33,6 +33,10 @@ class ChromeExtensionsAPIClient : public ExtensionsAPIClient { CreateWebViewPermissionHelperDelegate( WebViewPermissionHelper* web_view_permission_helper) const OVERRIDE; virtual void RegisterGuestViewTypes() OVERRIDE; + virtual scoped_refptr<RulesRegistry> GetRulesRegistry( + content::BrowserContext* browser_context, + const RulesRegistry::WebViewKey& webview_key, + const std::string& event_name) OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsAPIClient); diff --git a/chrome/browser/extensions/api/declarative/rules_registry_service.cc b/chrome/browser/extensions/api/declarative/rules_registry_service.cc index 208c9d3..2a9bab1 100644 --- a/chrome/browser/extensions/api/declarative/rules_registry_service.cc +++ b/chrome/browser/extensions/api/declarative/rules_registry_service.cc @@ -8,8 +8,6 @@ #include "base/lazy_instance.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/extensions/api/declarative/rules_cache_delegate.h" #include "chrome/browser/extensions/api/declarative_content/content_rules_registry.h" #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.h" #include "chrome/browser/extensions/api/web_request/web_request_api.h" @@ -17,7 +15,9 @@ #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_source.h" +#include "content/public/browser/notification_types.h" #include "content/public/browser/render_process_host.h" +#include "extensions/browser/api/declarative/rules_cache_delegate.h" #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" #include "extensions/browser/extension_registry.h" #include "extensions/common/extension.h" diff --git a/chrome/browser/extensions/api/declarative/rules_registry_service.h b/chrome/browser/extensions/api/declarative/rules_registry_service.h index 401d180..5bde741 100644 --- a/chrome/browser/extensions/api/declarative/rules_registry_service.h +++ b/chrome/browser/extensions/api/declarative/rules_registry_service.h @@ -13,9 +13,9 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_vector.h" #include "base/scoped_observer.h" -#include "chrome/browser/extensions/api/declarative/rules_registry.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" +#include "extensions/browser/api/declarative/rules_registry.h" #include "extensions/browser/browser_context_keyed_api_factory.h" #include "extensions/browser/extension_registry_observer.h" @@ -27,7 +27,6 @@ class NotificationSource; namespace extensions { class ContentRulesRegistry; class ExtensionRegistry; -class RulesRegistry; class RulesRegistryStorageDelegate; } @@ -77,9 +76,8 @@ class RulesRegistryService : public BrowserContextKeyedAPI, // Returns the RulesRegistry for |event_name| and |webview_key| or NULL if no // such registry has been registered. Default rules registries (such as the // WebRequest rules registry) will be created on first access. - scoped_refptr<RulesRegistry> GetRulesRegistry( - const WebViewKey& webview_key, - const std::string& event_name); + scoped_refptr<RulesRegistry> GetRulesRegistry(const WebViewKey& webview_key, + const std::string& event_name); // Accessors for each type of rules registry. ContentRulesRegistry* content_rules_registry() const { diff --git a/chrome/browser/extensions/api/declarative/rules_registry_service_unittest.cc b/chrome/browser/extensions/api/declarative/rules_registry_service_unittest.cc index c69df71..c6421f0 100644 --- a/chrome/browser/extensions/api/declarative/rules_registry_service_unittest.cc +++ b/chrome/browser/extensions/api/declarative/rules_registry_service_unittest.cc @@ -6,9 +6,9 @@ #include "base/bind.h" #include "base/message_loop/message_loop.h" -#include "chrome/browser/extensions/api/declarative/test_rules_registry.h" #include "chrome/test/base/testing_profile.h" #include "content/public/test/test_browser_thread.h" +#include "extensions/browser/api/declarative/test_rules_registry.h" #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/extensions/api/declarative/rules_registry_unittest.cc b/chrome/browser/extensions/api/declarative/rules_registry_unittest.cc index 88c5c0f..5e4616b 100644 --- a/chrome/browser/extensions/api/declarative/rules_registry_unittest.cc +++ b/chrome/browser/extensions/api/declarative/rules_registry_unittest.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/declarative/rules_registry.h" +#include "extensions/browser/api/declarative/rules_registry.h" #include <algorithm> #include "base/message_loop/message_loop.h" -#include "chrome/browser/extensions/api/declarative/test_rules_registry.h" #include "content/public/test/test_browser_thread.h" +#include "extensions/browser/api/declarative/test_rules_registry.h" #include "testing/gtest/include/gtest/gtest.h" namespace { diff --git a/chrome/browser/extensions/api/declarative/rules_registry_with_cache_unittest.cc b/chrome/browser/extensions/api/declarative/rules_registry_with_cache_unittest.cc index dff53b7..6aa8a1c 100644 --- a/chrome/browser/extensions/api/declarative/rules_registry_with_cache_unittest.cc +++ b/chrome/browser/extensions/api/declarative/rules_registry_with_cache_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/declarative/rules_registry.h" +#include "extensions/browser/api/declarative/rules_registry.h" // Here we test the TestRulesRegistry which is the simplest possible // implementation of RulesRegistryWithCache as a proxy for @@ -10,8 +10,6 @@ #include "base/command_line.h" #include "base/run_loop.h" -#include "chrome/browser/extensions/api/declarative/rules_cache_delegate.h" -#include "chrome/browser/extensions/api/declarative/test_rules_registry.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/test_extension_environment.h" #include "chrome/browser/extensions/test_extension_system.h" @@ -19,6 +17,8 @@ #include "chrome/common/extensions/features/feature_channel.h" #include "chrome/test/base/testing_profile.h" #include "content/public/test/test_browser_thread_bundle.h" +#include "extensions/browser/api/declarative/rules_cache_delegate.h" +#include "extensions/browser/api/declarative/test_rules_registry.h" #include "extensions/browser/extension_prefs.h" #include "extensions/browser/value_store/testing_value_store.h" #include "extensions/common/extension.h" diff --git a/chrome/browser/extensions/api/declarative_content/content_action.h b/chrome/browser/extensions/api/declarative_content/content_action.h index 04ddd66..ab111af 100644 --- a/chrome/browser/extensions/api/declarative_content/content_action.h +++ b/chrome/browser/extensions/api/declarative_content/content_action.h @@ -9,8 +9,8 @@ #include <vector> #include "base/memory/ref_counted.h" -#include "chrome/browser/extensions/api/declarative/declarative_rule.h" #include "chrome/browser/extensions/declarative_user_script_master.h" +#include "extensions/browser/api/declarative/declarative_rule.h" namespace base { class Time; diff --git a/chrome/browser/extensions/api/declarative_content/content_condition.h b/chrome/browser/extensions/api/declarative_content/content_condition.h index b189746..8151001 100644 --- a/chrome/browser/extensions/api/declarative_content/content_condition.h +++ b/chrome/browser/extensions/api/declarative_content/content_condition.h @@ -14,8 +14,8 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/values.h" -#include "chrome/browser/extensions/api/declarative/declarative_rule.h" #include "components/url_matcher/url_matcher.h" +#include "extensions/browser/api/declarative/declarative_rule.h" namespace extensions { diff --git a/chrome/browser/extensions/api/declarative_content/content_rules_registry.h b/chrome/browser/extensions/api/declarative_content/content_rules_registry.h index 3aa5eac..d3b6290 100644 --- a/chrome/browser/extensions/api/declarative_content/content_rules_registry.h +++ b/chrome/browser/extensions/api/declarative_content/content_rules_registry.h @@ -14,13 +14,13 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/time/time.h" -#include "chrome/browser/extensions/api/declarative/declarative_rule.h" -#include "chrome/browser/extensions/api/declarative/rules_registry.h" #include "chrome/browser/extensions/api/declarative_content/content_action.h" #include "chrome/browser/extensions/api/declarative_content/content_condition.h" #include "components/url_matcher/url_matcher.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" +#include "extensions/browser/api/declarative/declarative_rule.h" +#include "extensions/browser/api/declarative/rules_registry.h" #include "extensions/browser/info_map.h" class ContentPermissions; diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_action.h b/chrome/browser/extensions/api/declarative_webrequest/webrequest_action.h index 2cb2f0b..a7539c4 100644 --- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_action.h +++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_action.h @@ -12,10 +12,10 @@ #include "base/compiler_specific.h" #include "base/memory/linked_ptr.h" #include "base/memory/ref_counted.h" -#include "chrome/browser/extensions/api/declarative/declarative_rule.h" #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h" -#include "chrome/common/extensions/api/events.h" +#include "extensions/browser/api/declarative/declarative_rule.h" #include "extensions/browser/api/declarative_webrequest/request_stage.h" +#include "extensions/common/api/events.h" #include "url/gurl.h" class WebRequestPermission; diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition.h b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition.h index 5dc1508..5a5d1e8 100644 --- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition.h +++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition.h @@ -12,9 +12,9 @@ #include "base/basictypes.h" #include "base/memory/linked_ptr.h" -#include "chrome/browser/extensions/api/declarative/declarative_rule.h" #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute.h" #include "components/url_matcher/url_matcher.h" +#include "extensions/browser/api/declarative/declarative_rule.h" #include "net/http/http_response_headers.h" namespace extensions { diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute.h b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute.h index fdac979..9fc7ee3 100644 --- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute.h +++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute.h @@ -11,9 +11,9 @@ #include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "chrome/common/extensions/api/events.h" #include "content/public/common/resource_type.h" #include "extensions/browser/api/declarative_webrequest/request_stage.h" +#include "extensions/common/api/events.h" namespace base { class Value; diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.h b/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.h index eae79f6..7404446 100644 --- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.h +++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.h @@ -16,11 +16,11 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/time/time.h" -#include "chrome/browser/extensions/api/declarative/declarative_rule.h" -#include "chrome/browser/extensions/api/declarative/rules_registry.h" #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_action.h" #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condition.h" #include "components/url_matcher/url_matcher.h" +#include "extensions/browser/api/declarative/declarative_rule.h" +#include "extensions/browser/api/declarative/rules_registry.h" #include "extensions/browser/api/declarative_webrequest/request_stage.h" #include "extensions/browser/info_map.h" diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi index 57f47ea..7c1fb86 100644 --- a/chrome/chrome_browser_extensions.gypi +++ b/chrome/chrome_browser_extensions.gypi @@ -172,17 +172,8 @@ 'browser/extensions/api/debugger/debugger_api.h', 'browser/extensions/api/debugger/debugger_api_constants.cc', 'browser/extensions/api/debugger/debugger_api_constants.h', - 'browser/extensions/api/declarative/declarative_api.cc', - 'browser/extensions/api/declarative/declarative_api.h', - 'browser/extensions/api/declarative/declarative_rule.h', - 'browser/extensions/api/declarative/rules_cache_delegate.cc', - 'browser/extensions/api/declarative/rules_cache_delegate.h', - 'browser/extensions/api/declarative/rules_registry.cc', - 'browser/extensions/api/declarative/rules_registry.h', 'browser/extensions/api/declarative/rules_registry_service.cc', 'browser/extensions/api/declarative/rules_registry_service.h', - 'browser/extensions/api/declarative/test_rules_registry.cc', - 'browser/extensions/api/declarative/test_rules_registry.h', 'browser/extensions/api/declarative_content/content_action.cc', 'browser/extensions/api/declarative_content/content_action.h', 'browser/extensions/api/declarative_content/content_condition.cc', diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index 9b0f9c0..5f25edb3 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi @@ -836,7 +836,6 @@ 'browser/extensions/api/content_settings/content_settings_unittest.cc', 'browser/extensions/api/cookies/cookies_unittest.cc', 'browser/extensions/api/copresence/copresence_api_unittest.cc', - 'browser/extensions/api/declarative/declarative_rule_unittest.cc', 'browser/extensions/api/declarative/rules_registry_service_unittest.cc', 'browser/extensions/api/declarative/rules_registry_unittest.cc', 'browser/extensions/api/declarative/rules_registry_with_cache_unittest.cc', diff --git a/chrome/common/extensions/api/schemas.gypi b/chrome/common/extensions/api/schemas.gypi index 3dcdc0b..4cbd9cb 100644 --- a/chrome/common/extensions/api/schemas.gypi +++ b/chrome/common/extensions/api/schemas.gypi @@ -43,7 +43,6 @@ 'easy_unlock_private.idl', 'echo_private.json', 'enterprise_platform_keys_private.json', - 'events.json', 'experience_sampling_private.json', 'extension_options_internal.idl', 'feedback_private.idl', diff --git a/extensions/BUILD.gn b/extensions/BUILD.gn index 13e7a50..21477fd 100644 --- a/extensions/BUILD.gn +++ b/extensions/BUILD.gn @@ -165,6 +165,7 @@ test("unittests") { sources = [ "browser/admin_policy_unittest.cc", "browser/api/api_resource_manager_unittest.cc", + "browser/api/declarative/declarative_rule_unittest.cc", "browser/api/declarative/deduping_factory_unittest.cc", "browser/api/sockets_tcp/sockets_tcp_api_unittest.cc", "browser/api/storage/settings_quota_unittest.cc", diff --git a/extensions/browser/BUILD.gn b/extensions/browser/BUILD.gn index 764e40b..84c5c0c 100644 --- a/extensions/browser/BUILD.gn +++ b/extensions/browser/BUILD.gn @@ -89,6 +89,16 @@ source_set("browser") { "api/cast_channel/logger.h", "api/cast_channel/logger_util.cc", "api/cast_channel/logger_util.h", + "api/declarative/declarative_api.cc", + "api/declarative/declarative_api.h", + "api/declarative/declarative_rule.h", + "api/declarative/deduping_factory.h", + "api/declarative/rules_cache_delegate.cc", + "api/declarative/rules_cache_delegate.h", + "api/declarative/rules_registry.cc", + "api/declarative/rules_registry.h", + "api/declarative/test_rules_registry.cc", + "api/declarative/test_rules_registry.h", "api/declarative_webrequest/request_stage.cc", "api/declarative_webrequest/request_stage.h", "api/declarative_webrequest/webrequest_constants.cc", diff --git a/chrome/browser/extensions/api/declarative/declarative_api.cc b/extensions/browser/api/declarative/declarative_api.cc index 89bc089..5794f38 100644 --- a/chrome/browser/extensions/api/declarative/declarative_api.cc +++ b/extensions/browser/api/declarative/declarative_api.cc @@ -2,28 +2,29 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/declarative/declarative_api.h" +#include "extensions/browser/api/declarative/declarative_api.h" #include "base/bind.h" #include "base/bind_helpers.h" #include "base/task_runner_util.h" #include "base/values.h" -#include "chrome/browser/extensions/api/declarative/rules_registry_service.h" -#include "chrome/common/extensions/api/events.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" +#include "content/public/browser/web_contents.h" +#include "extensions/browser/api/extensions_api_client.h" #include "extensions/browser/extension_system.h" #include "extensions/browser/guest_view/web_view/web_view_constants.h" #include "extensions/browser/guest_view/web_view/web_view_guest.h" +#include "extensions/common/api/events.h" #include "extensions/common/extension_api.h" #include "extensions/common/permissions/permissions_data.h" -using extensions::api::events::Rule; +using extensions::core_api::events::Rule; -namespace AddRules = extensions::api::events::Event::AddRules; -namespace GetRules = extensions::api::events::Event::GetRules; -namespace RemoveRules = extensions::api::events::Event::RemoveRules; +namespace AddRules = extensions::core_api::events::Event::AddRules; +namespace GetRules = extensions::core_api::events::Event::GetRules; +namespace RemoveRules = extensions::core_api::events::Event::RemoveRules; namespace extensions { @@ -89,12 +90,14 @@ bool RulesFunction::RunAsync() { event_name = GetWebRequestEventName(event_name); // If we are not operating on a particular <webview>, then the key is (0, 0). - RulesRegistryService::WebViewKey key( + RulesRegistry::WebViewKey key( webview_instance_id ? embedder_process_id : 0, webview_instance_id); - RulesRegistryService* rules_registry_service = - RulesRegistryService::Get(browser_context()); - rules_registry_ = rules_registry_service->GetRulesRegistry(key, event_name); + // The following call will return a NULL pointer for apps_shell, but should + // never be called there anyways. + rules_registry_ = ExtensionsAPIClient::Get()->GetRulesRegistry( + browser_context(), key, event_name); + DCHECK(rules_registry_.get()); // Raw access to this function is not available to extensions, therefore // there should never be a request for a nonexisting rules registry. EXTENSION_FUNCTION_VALIDATE(rules_registry_.get()); diff --git a/chrome/browser/extensions/api/declarative/declarative_api.h b/extensions/browser/api/declarative/declarative_api.h index 502e2fa..72180dd 100644 --- a/chrome/browser/extensions/api/declarative/declarative_api.h +++ b/extensions/browser/api/declarative/declarative_api.h @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_API_H_ -#define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_API_H_ +#ifndef EXTENSIONS_BROWSER_API_DECLARATIVE_DECLARATIVE_API_H_ +#define EXTENSIONS_BROWSER_API_DECLARATIVE_DECLARATIVE_API_H_ #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" -#include "chrome/browser/extensions/api/declarative/rules_registry.h" -#include "chrome/browser/extensions/chrome_extension_function.h" +#include "extensions/browser/api/declarative/rules_registry.h" +#include "extensions/browser/extension_function.h" namespace extensions { -class RulesFunction : public ChromeAsyncExtensionFunction { +class RulesFunction : public AsyncExtensionFunction { public: RulesFunction(); @@ -66,4 +66,4 @@ class EventsEventGetRulesFunction : public RulesFunction { } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_API_H_ +#endif // EXTENSIONS_BROWSER_API_DECLARATIVE_DECLARATIVE_API_H_ diff --git a/chrome/browser/extensions/api/declarative/declarative_rule.h b/extensions/browser/api/declarative/declarative_rule.h index 3d286f0..b612f27 100644 --- a/chrome/browser/extensions/api/declarative/declarative_rule.h +++ b/extensions/browser/api/declarative/declarative_rule.h @@ -7,8 +7,8 @@ // templated on the Condition and Action types that define the behavior of a // particular declarative event. -#ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_RULE_H__ -#define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_RULE_H__ +#ifndef EXTENSIONS_BROWSER_API_DECLARATIVE_DECLARATIVE_RULE_H__ +#define EXTENSIONS_BROWSER_API_DECLARATIVE_DECLARATIVE_RULE_H__ #include <limits> #include <set> @@ -20,8 +20,8 @@ #include "base/memory/scoped_vector.h" #include "base/stl_util.h" #include "base/time/time.h" -#include "chrome/common/extensions/api/events.h" #include "components/url_matcher/url_matcher.h" +#include "extensions/common/api/events.h" #include "extensions/common/extension.h" namespace base { @@ -203,7 +203,7 @@ class DeclarativeRule { typedef int Priority; typedef DeclarativeConditionSet<ConditionT> ConditionSet; typedef DeclarativeActionSet<ActionT> ActionSet; - typedef extensions::api::events::Rule JsonRule; + typedef extensions::core_api::events::Rule JsonRule; typedef std::vector<std::string> Tags; // Checks whether the set of |conditions| and |actions| are consistent. @@ -514,4 +514,4 @@ int DeclarativeRule<ConditionT, ActionT>::GetMinimumPriority() const { } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_RULE_H__ +#endif // EXTENSIONS_BROWSER_API_DECLARATIVE_DECLARATIVE_RULE_H__ diff --git a/chrome/browser/extensions/api/declarative/declarative_rule_unittest.cc b/extensions/browser/api/declarative/declarative_rule_unittest.cc index 8eeda27..552145d 100644 --- a/chrome/browser/extensions/api/declarative/declarative_rule_unittest.cc +++ b/extensions/browser/api/declarative/declarative_rule_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/declarative/declarative_rule.h" +#include "extensions/browser/api/declarative/declarative_rule.h" #include "base/bind.h" #include "base/message_loop/message_loop.h" diff --git a/chrome/browser/extensions/api/declarative/rules_cache_delegate.cc b/extensions/browser/api/declarative/rules_cache_delegate.cc index 6a70d8e..03a4b49 100644 --- a/chrome/browser/extensions/api/declarative/rules_cache_delegate.cc +++ b/extensions/browser/api/declarative/rules_cache_delegate.cc @@ -2,15 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/declarative/rules_cache_delegate.h" +#include "extensions/browser/api/declarative/rules_cache_delegate.h" -#include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/extensions/api/declarative/rules_registry.h" -#include "chrome/browser/extensions/extension_service.h" -#include "chrome/browser/extensions/extension_util.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_source.h" +#include "extensions/browser/api/declarative/rules_registry.h" #include "extensions/browser/extension_prefs.h" #include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_system.h" @@ -127,16 +124,17 @@ void RulesCacheDelegate::CheckIfReady() { } void RulesCacheDelegate::ReadRulesForInstalledExtensions() { - ExtensionSystem& system = *ExtensionSystem::Get(browser_context_); - ExtensionService* extension_service = system.extension_service(); - DCHECK(extension_service); + bool is_ready = ExtensionSystem::Get(browser_context_)->ready().is_signaled(); // In an OTR context, we start on top of a normal context already, so the // extension service should be ready. - DCHECK(!browser_context_->IsOffTheRecord() || extension_service->is_ready()); - if (extension_service->is_ready()) { - const ExtensionSet* extensions = extension_service->extensions(); - for (ExtensionSet::const_iterator i = extensions->begin(); - i != extensions->end(); + DCHECK(!browser_context_->IsOffTheRecord() || is_ready); + if (is_ready) { + const ExtensionSet& extensions = + ExtensionRegistry::Get(browser_context_)->enabled_extensions(); + const ExtensionPrefs* extension_prefs = + ExtensionPrefs::Get(browser_context_); + for (ExtensionSet::const_iterator i = extensions.begin(); + i != extensions.end(); ++i) { bool needs_apis_storing_rules = (*i)->permissions_data()->HasAPIPermission( @@ -145,7 +143,7 @@ void RulesCacheDelegate::ReadRulesForInstalledExtensions() { APIPermission::kDeclarativeWebRequest); bool respects_off_the_record = !(browser_context_->IsOffTheRecord()) || - util::IsIncognitoEnabled((*i)->id(), browser_context_); + extension_prefs->IsIncognitoEnabled((*i)->id()); if (needs_apis_storing_rules && respects_off_the_record) ReadFromStorage((*i)->id()); } diff --git a/chrome/browser/extensions/api/declarative/rules_cache_delegate.h b/extensions/browser/api/declarative/rules_cache_delegate.h index 89bc33f..560eac2 100644 --- a/chrome/browser/extensions/api/declarative/rules_cache_delegate.h +++ b/extensions/browser/api/declarative/rules_cache_delegate.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_CACHE_DELEGATE_H__ -#define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_CACHE_DELEGATE_H__ +#ifndef EXTENSIONS_BROWSER_API_DECLARATIVE_RULES_CACHE_DELEGATE_H__ +#define EXTENSIONS_BROWSER_API_DECLARATIVE_RULES_CACHE_DELEGATE_H__ #include <set> #include <string> @@ -109,4 +109,4 @@ class RulesCacheDelegate { } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_CACHE_DELEGATE_H__ +#endif // EXTENSIONS_BROWSER_API_DECLARATIVE_RULES_CACHE_DELEGATE_H__ diff --git a/chrome/browser/extensions/api/declarative/rules_registry.cc b/extensions/browser/api/declarative/rules_registry.cc index 20fa42af..2c1c5d3 100644 --- a/chrome/browser/extensions/api/declarative/rules_registry.cc +++ b/extensions/browser/api/declarative/rules_registry.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/declarative/rules_registry.h" +#include "extensions/browser/api/declarative/rules_registry.h" #include <utility> @@ -14,13 +14,10 @@ #include "base/strings/stringprintf.h" #include "base/time/time.h" #include "base/values.h" -#include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/extensions/api/declarative/rules_cache_delegate.h" -#include "chrome/browser/extensions/extension_service.h" -#include "chrome/browser/extensions/extension_util.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_source.h" +#include "extensions/browser/api/declarative/rules_cache_delegate.h" #include "extensions/browser/extension_prefs.h" #include "extensions/browser/extension_system.h" #include "extensions/browser/state_store.h" diff --git a/chrome/browser/extensions/api/declarative/rules_registry.h b/extensions/browser/api/declarative/rules_registry.h index 14c7e21..fa0e745 100644 --- a/chrome/browser/extensions/api/declarative/rules_registry.h +++ b/extensions/browser/api/declarative/rules_registry.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ -#define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ +#ifndef EXTENSIONS_BROWSER_API_DECLARATIVE_RULES_REGISTRY_H__ +#define EXTENSIONS_BROWSER_API_DECLARATIVE_RULES_REGISTRY_H__ #include <map> #include <set> @@ -15,10 +15,10 @@ #include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" -#include "chrome/common/extensions/api/events.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" +#include "extensions/common/api/events.h" #include "extensions/common/one_shot_event.h" namespace content { @@ -39,7 +39,7 @@ class RulesCacheDelegate; // in the RulesCacheDelegate object. class RulesRegistry : public base::RefCountedThreadSafe<RulesRegistry> { public: - typedef extensions::api::events::Rule Rule; + typedef extensions::core_api::events::Rule Rule; struct WebViewKey { int embedder_process_id; int webview_instance_id; @@ -293,4 +293,4 @@ class RulesRegistry : public base::RefCountedThreadSafe<RulesRegistry> { } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ +#endif // EXTENSIONS_BROWSER_API_DECLARATIVE_RULES_REGISTRY_H__ diff --git a/chrome/browser/extensions/api/declarative/test_rules_registry.cc b/extensions/browser/api/declarative/test_rules_registry.cc index ce22ddc..030a22a 100644 --- a/chrome/browser/extensions/api/declarative/test_rules_registry.cc +++ b/extensions/browser/api/declarative/test_rules_registry.cc @@ -4,7 +4,7 @@ #include <string> -#include "chrome/browser/extensions/api/declarative/test_rules_registry.h" +#include "extensions/browser/api/declarative/test_rules_registry.h" namespace extensions { diff --git a/chrome/browser/extensions/api/declarative/test_rules_registry.h b/extensions/browser/api/declarative/test_rules_registry.h index 7e0b691..ebeaf52 100644 --- a/chrome/browser/extensions/api/declarative/test_rules_registry.h +++ b/extensions/browser/api/declarative/test_rules_registry.h @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_TEST_RULES_REGISTRY_H__ -#define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_TEST_RULES_REGISTRY_H__ +#ifndef EXTENSIONS_BROWSER_API_DECLARATIVE_TEST_RULES_REGISTRY_H__ +#define EXTENSIONS_BROWSER_API_DECLARATIVE_TEST_RULES_REGISTRY_H__ -#include "chrome/browser/extensions/api/declarative/rules_registry.h" +#include "extensions/browser/api/declarative/rules_registry.h" namespace extensions { @@ -49,4 +49,4 @@ class TestRulesRegistry : public RulesRegistry { } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_TEST_RULES_REGISTRY_H__ +#endif // EXTENSIONS_BROWSER_API_DECLARATIVE_TEST_RULES_REGISTRY_H__ diff --git a/extensions/browser/api/extensions_api_client.cc b/extensions/browser/api/extensions_api_client.cc index 0fb3a79..2f809ef 100644 --- a/extensions/browser/api/extensions_api_client.cc +++ b/extensions/browser/api/extensions_api_client.cc @@ -48,4 +48,11 @@ WebViewPermissionHelperDelegate* ExtensionsAPIClient:: return NULL; } +scoped_refptr<RulesRegistry> ExtensionsAPIClient::GetRulesRegistry( + content::BrowserContext* browser_context, + const RulesRegistry::WebViewKey& webview_key, + const std::string& event_name) { + return scoped_refptr<RulesRegistry>(); +} + } // namespace extensions diff --git a/extensions/browser/api/extensions_api_client.h b/extensions/browser/api/extensions_api_client.h index 5cd3cee..62f187d 100644 --- a/extensions/browser/api/extensions_api_client.h +++ b/extensions/browser/api/extensions_api_client.h @@ -9,6 +9,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" +#include "extensions/browser/api/declarative/rules_registry.h" #include "extensions/browser/api/storage/settings_namespace.h" class GURL; @@ -77,6 +78,13 @@ class ExtensionsAPIClient { virtual void RegisterGuestViewTypes() {} + // TODO(wjmaclean): Remove this as soon as rules_registry_service.* moves to + // extensions/browser/api/declarative/. + virtual scoped_refptr<RulesRegistry> GetRulesRegistry( + content::BrowserContext* browser_context, + const RulesRegistry::WebViewKey& webview_key, + const std::string& event_name); + // NOTE: If this interface gains too many methods (perhaps more than 20) it // should be split into one interface per API. }; diff --git a/chrome/common/extensions/api/events.json b/extensions/common/api/events.json index b09dba7..e62ea09 100644 --- a/chrome/common/extensions/api/events.json +++ b/extensions/common/api/events.json @@ -7,7 +7,7 @@ "namespace": "events", "description": "The <code>chrome.events</code> namespace contains common types used by APIs dispatching events to notify you when something interesting happens.", "compiler_options": { - "implemented_in": "chrome/browser/extensions/api/declarative/declarative_api.h" + "implemented_in": "extensions/browser/api/declarative/declarative_api.h" }, "types": [ { diff --git a/extensions/common/api/schemas.gypi b/extensions/common/api/schemas.gypi index 18b43cc..7648532 100644 --- a/extensions/common/api/schemas.gypi +++ b/extensions/common/api/schemas.gypi @@ -23,6 +23,7 @@ 'bluetooth_socket.idl', 'cast_channel.idl', 'dns.idl', + 'events.json', 'extensions_manifest_types.json', 'extension_types.json', 'guest_view_internal.json', diff --git a/extensions/extensions.gyp b/extensions/extensions.gyp index e888dc7..4ea4161 100644 --- a/extensions/extensions.gyp +++ b/extensions/extensions.gyp @@ -357,6 +357,16 @@ 'browser/api/cast_channel/logger_util.cc', 'browser/api/cast_channel/logger_util.h', 'browser/api/declarative/deduping_factory.h', + 'browser/api/declarative/declarative_api.cc', + 'browser/api/declarative/declarative_api.h', + 'browser/api/declarative/declarative_rule.h', + 'browser/api/declarative/rules_cache_delegate.cc', + 'browser/api/declarative/rules_cache_delegate.h', + 'browser/api/declarative/rules_registry.cc', + 'browser/api/declarative/rules_registry.h', + 'browser/api/declarative/rules_registry_service_interface_.h', + 'browser/api/declarative/test_rules_registry.cc', + 'browser/api/declarative/test_rules_registry.h', 'browser/api/declarative_webrequest/request_stage.cc', 'browser/api/declarative_webrequest/request_stage.h', 'browser/api/declarative_webrequest/webrequest_constants.cc', @@ -1022,6 +1032,7 @@ 'browser/api/cast_channel/cast_channel_api_unittest.cc', 'browser/api/cast_channel/cast_socket_unittest.cc', 'browser/api/cast_channel/logger_unittest.cc', + 'browser/api/declarative/declarative_rule_unittest.cc', 'browser/api/declarative/deduping_factory_unittest.cc', 'browser/api/power/power_api_unittest.cc', 'browser/api/sockets_tcp/sockets_tcp_api_unittest.cc', |