Commit d831ac04 authored by Stepan Khapugin's avatar Stepan Khapugin Committed by Commit Bot

Revert "[ios showcase] Removes ios/web dependency."

This reverts commit 54275e80.

Reason for revert: breaks ios_showcase_egtests downstream. Failure details: https://paste.googleplex.com/6470224534568960 - fails on all simulator bots.

Original change's description:
> [ios showcase] Removes ios/web dependency.
> 
> Showcase is intended to be a standalone UI app and as such should not reference 
> //ios/web or //ios/chrome. This CL eliminates the Showcase app creating an IOSChromeMain 
> instance and thus implicitly being an //ios/web embedder, instead directly inlining the 
> minimal parts of that startup that are needed (initializing base::CommandLine and loading resources).
>  
> As part of that change, this CL eliminates Showcase bundling //ios/web resources.
> 
> Bug: 738880
> Change-Id: I0a3d3494838cc588034feb48443d24ddf1bec03a
> Reviewed-on: https://chromium-review.googlesource.com/565453
> Commit-Queue: Sergio Collazos <sczs@chromium.org>
> Reviewed-by: Colin Blundell <blundell@chromium.org>
> Reviewed-by: Louis Romero <lpromero@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#485815}

TBR=blundell@chromium.org,lpromero@chromium.org,sczs@chromium.org

Change-Id: I8f2daeb1adeabe4622e312b5bc1d70a5591bd68e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 738880
Reviewed-on: https://chromium-review.googlesource.com/566864Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485928}
parent f62c1e72
......@@ -6,6 +6,7 @@ import("//build/config/ios/rules.gni")
import("//ios/build/chrome_build.gni")
import("//ios/build/config.gni")
import("//ios/third_party/earl_grey/ios_eg_test.gni")
import("//tools/grit/repack.gni")
ios_app_bundle("showcase") {
info_plist = "core/Info.plist"
......@@ -13,6 +14,7 @@ ios_app_bundle("showcase") {
output_name = "Showcase"
deps = [
":features",
":packed_resources",
"//ios/showcase/core:main",
# All shared libraries must have the sanitizer deps to properly link in
......@@ -47,11 +49,23 @@ group("all_tests") {
]
}
repack("packed_resources") {
sources = [
"$root_gen_dir/ios/web/ios_web_resources.pak",
]
deps = [
"//ios/web:resources",
]
output = "$target_gen_dir/showcase_resources.pak"
copy_data_to_bundle = true
}
ios_eg_test("ios_showcase_egtests") {
info_plist = "core/Info.plist"
extra_substitutions = [ "IOS_BUNDLE_ID_PREFIX=$ios_app_bundle_id_prefix" ]
deps = [
":features",
":packed_resources",
"//ios/showcase/core:main",
# Add all eg_tests targets below.
......
......@@ -4,5 +4,6 @@ include_rules = [
"+ios/clean",
"+ios/third_party/material_components_ios",
"+ios/third_party/material_roboto_font_loader_ios",
"+ios/web/public",
"+ui/base",
]
......@@ -13,9 +13,15 @@ source_set("core") {
]
deps = [
"//base",
"//ios/chrome/app/startup:startup_basic",
"//ios/showcase/common",
"//ios/third_party/material_components_ios",
"//ios/third_party/material_roboto_font_loader_ios",
# TODO(crbug.com/738880): Showcase ideally shouldn't be an embedder of
# //ios/web.
"//ios/web",
"//ios/web/public/app",
"//ui/base",
]
libs = [ "UIKit.framework" ]
......
......@@ -4,12 +4,14 @@
#import "ios/showcase/core/app_delegate.h"
#include "base/command_line.h"
#include "base/memory/ptr_util.h"
#include "base/path_service.h"
#include "ios/chrome/app/startup/ios_chrome_main.h"
#import "ios/showcase/core/showcase_model.h"
#import "ios/showcase/core/showcase_view_controller.h"
#import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h"
#import "ios/web/public/app/web_main_parts.h"
#import "ios/web/public/web_client.h"
#include "ui/base/resource/resource_bundle.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......@@ -19,6 +21,42 @@
@implementation AppDelegate
@synthesize window = _window;
namespace {
class ShowcaseWebMainParts : public web::WebMainParts {
void PreMainMessageLoopStart() override {
ResourceBundle::InitSharedInstanceWithLocale(
std::string(), nullptr, ResourceBundle::LOAD_COMMON_RESOURCES);
base::FilePath pak_path;
PathService::Get(base::DIR_MODULE, &pak_path);
ResourceBundle::GetSharedInstance().AddDataPackFromPath(
pak_path.AppendASCII("showcase_resources.pak"), ui::SCALE_FACTOR_100P);
}
};
class ShowcaseWebClient : public web::WebClient {
public:
ShowcaseWebClient() {}
~ShowcaseWebClient() override {}
// WebClient implementation.
std::unique_ptr<web::WebMainParts> CreateWebMainParts() override {
return base::MakeUnique<ShowcaseWebMainParts>();
}
base::StringPiece GetDataResource(
int resource_id,
ui::ScaleFactor scale_factor) const override {
return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
resource_id, scale_factor);
}
base::RefCountedMemory* GetDataResourceBytes(int resource_id) const override {
return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
resource_id);
}
};
}
- (void)setupUI {
ShowcaseViewController* viewController =
[[ShowcaseViewController alloc] initWithRows:[AppDelegate rowsToDisplay]];
......@@ -31,9 +69,11 @@
- (BOOL)application:(UIApplication*)application
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
base::CommandLine::Init(0, nullptr);
ResourceBundle::InitSharedInstanceWithLocale(
std::string(), nullptr, ResourceBundle::LOAD_COMMON_RESOURCES);
// TODO(crbug.com/738880): Showcase ideally shouldn't be an embedder of
// //ios/web, in which case it wouldn't have to do this. This almost
// certainly means not creating IOSChromeMain.
web::SetWebClient(new ShowcaseWebClient());
base::MakeUnique<IOSChromeMain>();
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self setupUI];
......
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