Commit bcd0fb5e authored by Colin Blundell's avatar Colin Blundell Committed by Commit Bot

Bundle //ios/web resources in web shell

Upcoming work that will embed Service Manager in //ios/web will add
usage of //ios/web/resources; I will test this embedding via an EG
test that exercises web_shell and thus will need web_shell to bundle
these resources.

Bug: 731588
Change-Id: I1767d02ab13f6960811d80f516cc807f6ad486a1
Reviewed-on: https://chromium-review.googlesource.com/544310Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#481887}
parent 56ec40a9
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import("//build/config/ios/rules.gni") import("//build/config/ios/rules.gni")
import("//ios/build/config.gni") import("//ios/build/config.gni")
import("//tools/grit/repack.gni")
ios_app_bundle("ios_web_shell") { ios_app_bundle("ios_web_shell") {
info_plist = "Info.plist" info_plist = "Info.plist"
...@@ -34,6 +35,18 @@ bundle_data("shell_bundle_data") { ...@@ -34,6 +35,18 @@ bundle_data("shell_bundle_data") {
] ]
} }
repack("packed_resources") {
visibility = [ ":shell" ]
sources = [
"$root_gen_dir/ios/web/ios_web_resources.pak",
]
deps = [
"//ios/web:resources",
]
output = "$target_gen_dir/web_shell_resources.pak"
copy_data_to_bundle = true
}
source_set("shell") { source_set("shell") {
sources = [ sources = [
"app_delegate.h", "app_delegate.h",
...@@ -56,6 +69,7 @@ source_set("shell") { ...@@ -56,6 +69,7 @@ source_set("shell") {
] ]
deps = [ deps = [
":packed_resources",
":shell_bundle_data", ":shell_bundle_data",
"//base", "//base",
"//ios/net", "//ios/net",
......
...@@ -24,6 +24,10 @@ class ShellWebClient : public WebClient { ...@@ -24,6 +24,10 @@ class ShellWebClient : public WebClient {
std::unique_ptr<WebMainParts> CreateWebMainParts() override; std::unique_ptr<WebMainParts> CreateWebMainParts() override;
std::string GetProduct() const override; std::string GetProduct() const override;
std::string GetUserAgent(UserAgentType type) const override; std::string GetUserAgent(UserAgentType type) const override;
base::StringPiece GetDataResource(
int resource_id,
ui::ScaleFactor scale_factor) const override;
base::RefCountedMemory* GetDataResourceBytes(int resource_id) const override;
void AllowCertificateError( void AllowCertificateError(
WebState* web_state, WebState* web_state,
int cert_error, int cert_error,
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "ios/web/public/user_agent.h" #include "ios/web/public/user_agent.h"
#include "ios/web/shell/shell_web_main_parts.h" #include "ios/web/shell/shell_web_main_parts.h"
#include "ui/base/resource/resource_bundle.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
...@@ -41,6 +42,18 @@ std::string ShellWebClient::GetUserAgent(UserAgentType type) const { ...@@ -41,6 +42,18 @@ std::string ShellWebClient::GetUserAgent(UserAgentType type) const {
return web::BuildUserAgentFromProduct(product); return web::BuildUserAgentFromProduct(product);
} }
base::StringPiece ShellWebClient::GetDataResource(
int resource_id,
ui::ScaleFactor scale_factor) const {
return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
resource_id, scale_factor);
}
base::RefCountedMemory* ShellWebClient::GetDataResourceBytes(
int resource_id) const {
return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id);
}
void ShellWebClient::AllowCertificateError( void ShellWebClient::AllowCertificateError(
WebState*, WebState*,
int /*cert_error*/, int /*cert_error*/,
......
...@@ -22,6 +22,7 @@ class ShellWebMainParts : public WebMainParts { ...@@ -22,6 +22,7 @@ class ShellWebMainParts : public WebMainParts {
ShellBrowserState* browser_state() const { return browser_state_.get(); } ShellBrowserState* browser_state() const { return browser_state_.get(); }
// WebMainParts implementation. // WebMainParts implementation.
void PreMainMessageLoopStart() override;
void PreMainMessageLoopRun() override; void PreMainMessageLoopRun() override;
private: private:
......
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
#include "ios/web/shell/shell_web_main_parts.h" #include "ios/web/shell/shell_web_main_parts.h"
#include "base/path_service.h"
#include "ios/web/shell/shell_browser_state.h" #include "ios/web/shell/shell_browser_state.h"
#include "ui/base/resource/resource_bundle.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
...@@ -18,6 +20,13 @@ ShellWebMainParts::ShellWebMainParts() { ...@@ -18,6 +20,13 @@ ShellWebMainParts::ShellWebMainParts() {
ShellWebMainParts::~ShellWebMainParts() { ShellWebMainParts::~ShellWebMainParts() {
} }
void ShellWebMainParts::PreMainMessageLoopStart() {
base::FilePath pak_path;
PathService::Get(base::DIR_MODULE, &pak_path);
ui::ResourceBundle::InitSharedInstanceWithPakPath(
pak_path.AppendASCII("web_shell_resources.pak"));
}
void ShellWebMainParts::PreMainMessageLoopRun() { void ShellWebMainParts::PreMainMessageLoopRun() {
browser_state_.reset(new ShellBrowserState); browser_state_.reset(new ShellBrowserState);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment