Generate all extension schema namespaces as "api" and instead vary the generated bundle names.
At the moment the 3 modules that use extension API schemas, those in
extensions/common/api, chrome/common/extensions/api, and extensions/shell/api,
are generated with different C++ namespaces: "core_api", "api", and
"shell::api" respectively.
This is a pointless distinction to make since as far as JS is concerned they
must all go on the window.chrome object, therefore namespace conflicts are
impossible. It just ends up adding code noise.
The only problem it solves is that all bundle compiles are generated to the
same name, "GeneratedSchemas" and "GeneratedFunctionRegistry". This patch
solves that a different way, by adding a JSON schema compiler option to give
those generated classes a prefix such that they are "GeneratedSchemas",
"ChromeGeneratedSchemas", and "ShellGeneratedSchemas" respectively.
This lets us to a global substitution from "core_api" to just "api".
[email protected], [email protected]
[email protected]
Review URL: https://codereview.chromium.org/1226353004
Cr-Commit-Position: refs/heads/master@{#340119}
diff --git a/chrome/browser/extensions/chrome_extensions_browser_client.cc b/chrome/browser/extensions/chrome_extensions_browser_client.cc
index d6d27c2..1dc12991 100644
--- a/chrome/browser/extensions/chrome_extensions_browser_client.cc
+++ b/chrome/browser/extensions/chrome_extensions_browser_client.cc
@@ -128,7 +128,7 @@
}
bool ChromeExtensionsBrowserClient::CanExtensionCrossIncognito(
- const extensions::Extension* extension,
+ const Extension* extension,
content::BrowserContext* context) const {
return IsGuestSession(context)
|| util::CanCrossIncognito(extension, context);
@@ -243,23 +243,20 @@
void ChromeExtensionsBrowserClient::RegisterExtensionFunctions(
ExtensionFunctionRegistry* registry) const {
// Preferences.
- registry->RegisterFunction<extensions::GetPreferenceFunction>();
- registry->RegisterFunction<extensions::SetPreferenceFunction>();
- registry->RegisterFunction<extensions::ClearPreferenceFunction>();
+ registry->RegisterFunction<GetPreferenceFunction>();
+ registry->RegisterFunction<SetPreferenceFunction>();
+ registry->RegisterFunction<ClearPreferenceFunction>();
// Direct Preference Access for Component Extensions.
- registry->RegisterFunction<
- extensions::chromedirectsetting::GetDirectSettingFunction>();
- registry->RegisterFunction<
- extensions::chromedirectsetting::SetDirectSettingFunction>();
- registry->RegisterFunction<
- extensions::chromedirectsetting::ClearDirectSettingFunction>();
+ registry->RegisterFunction<chromedirectsetting::GetDirectSettingFunction>();
+ registry->RegisterFunction<chromedirectsetting::SetDirectSettingFunction>();
+ registry->RegisterFunction<chromedirectsetting::ClearDirectSettingFunction>();
// Generated APIs from lower-level modules.
- extensions::core_api::GeneratedFunctionRegistry::RegisterAll(registry);
+ api::GeneratedFunctionRegistry::RegisterAll(registry);
// Generated APIs from Chrome.
- extensions::api::GeneratedFunctionRegistry::RegisterAll(registry);
+ api::ChromeGeneratedFunctionRegistry::RegisterAll(registry);
}
void ChromeExtensionsBrowserClient::RegisterMojoServices(
@@ -269,11 +266,10 @@
RegisterChromeServicesForFrame(render_frame_host, extension);
}
-scoped_ptr<extensions::RuntimeAPIDelegate>
+scoped_ptr<RuntimeAPIDelegate>
ChromeExtensionsBrowserClient::CreateRuntimeAPIDelegate(
content::BrowserContext* context) const {
- return scoped_ptr<extensions::RuntimeAPIDelegate>(
- new ChromeRuntimeAPIDelegate(context));
+ return scoped_ptr<RuntimeAPIDelegate>(new ChromeRuntimeAPIDelegate(context));
}
const ComponentExtensionResourceManager*
@@ -332,7 +328,7 @@
void ChromeExtensionsBrowserClient::ReportError(
content::BrowserContext* context,
scoped_ptr<ExtensionError> error) {
- extensions::ErrorConsole::Get(context)->ReportError(error.Pass());
+ ErrorConsole::Get(context)->ReportError(error.Pass());
}
void ChromeExtensionsBrowserClient::CleanUpWebView(int embedder_process_id,