Enable new mojo JS bindings in extensions blessed context.
This CL:
- Adds support to load extensions JS sources from gzipped resources, since the
JS file for new mojo JS bindings is gzipped. The alternative is to change the
JS file to uncompressed, which would increase Chrome size quite significantly.
For example, adding ~132KB to resources.pak for Linux official build.
- Converts mimeHandlerPrivate to use new Mojo JS bindings.
BUG=699569, 718047
Change-Id: If485020558f607a1d2e81296476c60a20e7dd21b
Reviewed-on: https://chromium-review.googlesource.com/767649
Commit-Queue: Yuzhu Shen <[email protected]>
Reviewed-by: Devlin <[email protected]>
Reviewed-by: Ilya Sherman <[email protected]>
Reviewed-by: Ken Rockot <[email protected]>
Cr-Commit-Position: refs/heads/master@{#516811}
diff --git a/extensions/renderer/resource_bundle_source_map.h b/extensions/renderer/resource_bundle_source_map.h
index cdf497b..1baa80b 100644
--- a/extensions/renderer/resource_bundle_source_map.h
+++ b/extensions/renderer/resource_bundle_source_map.h
@@ -27,11 +27,27 @@
const std::string& name) const override;
bool Contains(const std::string& name) const override;
- void RegisterSource(const char* const name, int resource_id);
+ void RegisterSource(const char* const name,
+ int resource_id,
+ bool gzipped = false);
private:
+ struct ResourceInfo {
+ ResourceInfo();
+ ResourceInfo(int in_id, bool in_gzipped);
+ ResourceInfo(ResourceInfo&& other);
+ ~ResourceInfo();
+
+ ResourceInfo& operator=(ResourceInfo&& other);
+
+ int id = 0;
+ bool gzipped = false;
+ // Used to cache the uncompressed contents if |gzipped| is true.
+ mutable std::unique_ptr<std::string> cached;
+ };
+
const ui::ResourceBundle* resource_bundle_;
- std::map<std::string, int> resource_id_map_;
+ std::map<std::string, ResourceInfo> resource_map_;
DISALLOW_COPY_AND_ASSIGN(ResourceBundleSourceMap);
};