Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1304)

Unified Diff: extensions/renderer/dispatcher.cc

Issue 399363002: Add support for writing unit tests for Mojo-backed apps/extensions APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: extensions/renderer/dispatcher.cc
diff --git a/extensions/renderer/dispatcher.cc b/extensions/renderer/dispatcher.cc
index f8a6ccdffb484749583ac75d99f0565def007c3f..bb319edc2f0640655132fa87502e105a00e7060c 100644
--- a/extensions/renderer/dispatcher.cc
+++ b/extensions/renderer/dispatcher.cc
@@ -75,7 +75,9 @@
#include "extensions/renderer/user_gestures_native_handler.h"
#include "extensions/renderer/utils_native_handler.h"
#include "extensions/renderer/v8_context_native_handler.h"
+#include "grit/content_resources.h"
#include "grit/extensions_renderer_resources.h"
+#include "mojo/public/js/bindings/constants.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebURLRequest.h"
#include "third_party/WebKit/public/web/WebCustomElement.h"
@@ -463,6 +465,64 @@ void Dispatcher::ClearPortData(int port_id) {
port_to_tab_id_map_.erase(port_id);
}
+// static
+std::vector<std::pair<std::string, int> > Dispatcher::GetJsResources() {
+ std::vector<std::pair<std::string, int> > resources;
+
+ // Libraries.
+ resources.push_back(std::make_pair("entryIdManager", IDR_ENTRY_ID_MANAGER));
+ resources.push_back(std::make_pair(kEventBindings, IDR_EVENT_BINDINGS_JS));
+ resources.push_back(std::make_pair("imageUtil", IDR_IMAGE_UTIL_JS));
+ resources.push_back(std::make_pair("json_schema", IDR_JSON_SCHEMA_JS));
+ resources.push_back(std::make_pair("lastError", IDR_LAST_ERROR_JS));
+ resources.push_back(std::make_pair("messaging", IDR_MESSAGING_JS));
+ resources.push_back(
+ std::make_pair("messaging_utils", IDR_MESSAGING_UTILS_JS));
+ resources.push_back(std::make_pair(kSchemaUtils, IDR_SCHEMA_UTILS_JS));
+ resources.push_back(std::make_pair("sendRequest", IDR_SEND_REQUEST_JS));
+ resources.push_back(std::make_pair("setIcon", IDR_SET_ICON_JS));
+ resources.push_back(std::make_pair("test", IDR_TEST_CUSTOM_BINDINGS_JS));
+ resources.push_back(
+ std::make_pair("test_environment_specific_bindings",
+ IDR_BROWSER_TEST_ENVIRONMENT_SPECIFIC_BINDINGS_JS));
+ resources.push_back(std::make_pair("uncaught_exception_handler",
+ IDR_UNCAUGHT_EXCEPTION_HANDLER_JS));
+ resources.push_back(std::make_pair("unload_event", IDR_UNLOAD_EVENT_JS));
+ resources.push_back(std::make_pair("utils", IDR_UTILS_JS));
+ resources.push_back(
+ std::make_pair(mojo::kCodecModuleName, IDR_MOJO_CODEC_JS));
not at google - send to devlin 2014/07/25 00:17:57 this mojo stuff is new. will it be needed outside
Sam McNally 2014/07/25 07:38:59 They will eventually, but not yet.
+ resources.push_back(
+ std::make_pair(mojo::kConnectionModuleName, IDR_MOJO_CONNECTION_JS));
+ resources.push_back(
+ std::make_pair(mojo::kConnectorModuleName, IDR_MOJO_CONNECTOR_JS));
+ resources.push_back(
+ std::make_pair(mojo::kRouterModuleName, IDR_MOJO_ROUTER_JS));
+ resources.push_back(
+ std::make_pair(mojo::kUnicodeModuleName, IDR_MOJO_UNICODE_JS));
+
+ // Custom bindings.
+ resources.push_back(
+ std::make_pair("app.runtime", IDR_APP_RUNTIME_CUSTOM_BINDINGS_JS));
+ resources.push_back(
+ std::make_pair("contextMenus", IDR_CONTEXT_MENUS_CUSTOM_BINDINGS_JS));
+ resources.push_back(
+ std::make_pair("extension", IDR_EXTENSION_CUSTOM_BINDINGS_JS));
+ resources.push_back(std::make_pair("i18n", IDR_I18N_CUSTOM_BINDINGS_JS));
+ resources.push_back(
+ std::make_pair("permissions", IDR_PERMISSIONS_CUSTOM_BINDINGS_JS));
+ resources.push_back(
+ std::make_pair("runtime", IDR_RUNTIME_CUSTOM_BINDINGS_JS));
+ resources.push_back(std::make_pair("binding", IDR_BINDING_JS));
+
+ // Custom types sources.
+ resources.push_back(std::make_pair("StorageArea", IDR_STORAGE_AREA_JS));
+
+ // Platform app sources that are not API-specific..
+ resources.push_back(std::make_pair("platformApp", IDR_PLATFORM_APP_JS));
+
+ return resources;
+}
+
bool Dispatcher::OnControlMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(Dispatcher, message)
@@ -1058,39 +1118,13 @@ void Dispatcher::RegisterNativeHandlers(ModuleSystem* module_system,
}
void Dispatcher::PopulateSourceMap() {
- // Libraries.
- source_map_.RegisterSource("entryIdManager", IDR_ENTRY_ID_MANAGER);
- source_map_.RegisterSource(kEventBindings, IDR_EVENT_BINDINGS_JS);
- source_map_.RegisterSource("imageUtil", IDR_IMAGE_UTIL_JS);
- source_map_.RegisterSource("json_schema", IDR_JSON_SCHEMA_JS);
- source_map_.RegisterSource("lastError", IDR_LAST_ERROR_JS);
- source_map_.RegisterSource("messaging", IDR_MESSAGING_JS);
- source_map_.RegisterSource("messaging_utils", IDR_MESSAGING_UTILS_JS);
- source_map_.RegisterSource(kSchemaUtils, IDR_SCHEMA_UTILS_JS);
- source_map_.RegisterSource("sendRequest", IDR_SEND_REQUEST_JS);
- source_map_.RegisterSource("setIcon", IDR_SET_ICON_JS);
- source_map_.RegisterSource("test", IDR_TEST_CUSTOM_BINDINGS_JS);
- source_map_.RegisterSource("uncaught_exception_handler",
- IDR_UNCAUGHT_EXCEPTION_HANDLER_JS);
- source_map_.RegisterSource("unload_event", IDR_UNLOAD_EVENT_JS);
- source_map_.RegisterSource("utils", IDR_UTILS_JS);
-
- // Custom bindings.
- source_map_.RegisterSource("app.runtime", IDR_APP_RUNTIME_CUSTOM_BINDINGS_JS);
- source_map_.RegisterSource("contextMenus",
- IDR_CONTEXT_MENUS_CUSTOM_BINDINGS_JS);
- source_map_.RegisterSource("extension", IDR_EXTENSION_CUSTOM_BINDINGS_JS);
- source_map_.RegisterSource("i18n", IDR_I18N_CUSTOM_BINDINGS_JS);
- source_map_.RegisterSource("permissions", IDR_PERMISSIONS_CUSTOM_BINDINGS_JS);
- source_map_.RegisterSource("runtime", IDR_RUNTIME_CUSTOM_BINDINGS_JS);
- source_map_.RegisterSource("binding", IDR_BINDING_JS);
-
- // Custom types sources.
- source_map_.RegisterSource("StorageArea", IDR_STORAGE_AREA_JS);
-
- // Platform app sources that are not API-specific..
- source_map_.RegisterSource("platformApp", IDR_PLATFORM_APP_JS);
-
+ const std::vector<std::pair<std::string, int> > resources = GetJsResources();
+ for (std::vector<std::pair<std::string, int> >::const_iterator resource =
+ resources.begin();
+ resource != resources.end();
+ ++resource) {
+ source_map_.RegisterSource(resource->first, resource->second);
+ }
delegate_->PopulateSourceMap(&source_map_);
}

Powered by Google App Engine
This is Rietveld 408576698