Commit 068ace25 authored by kkhorimoto's avatar kkhorimoto Committed by Commit bot

Fix the T-Rex easter egg on iOS.

In this CL:
- Always supply a user agent to WKWebViews in web//'s creation methods.
  This allows the IS_IOS variable in offline.js to be correctly set to
  true.
- Delay initializing the game runner until after images have been
  loaded.
- Check for existence of errorPageController when activating the game.

BUG=none

Review-Url: https://codereview.chromium.org/2144933002
Cr-Commit-Position: refs/heads/master@{#406949}
parent 0503a773
......@@ -292,7 +292,13 @@ Runner.prototype = {
this.spriteDef = Runner.spriteDefinition.LDPI;
}
this.init();
if (Runner.imageSprite.complete) {
this.init();
} else {
// If the images are not yet loaded, add a listener.
Runner.imageSprite.addEventListener(Runner.events.LOAD,
this.init.bind(this));
}
},
/**
......@@ -660,7 +666,9 @@ Runner.prototype = {
if (!this.activated) {
this.loadSounds();
this.activated = true;
errorPageController.trackEasterEgg();
if (window.errorPageController) {
errorPageController.trackEasterEgg();
}
}
if (!this.tRex.jumping && !this.tRex.ducking) {
......
......@@ -33,32 +33,35 @@ WKWebView* CreateWKWebView(CGRect frame,
WKWebViewConfiguration* configuration,
BrowserState* browser_state,
BOOL use_desktop_user_agent) {
WKWebView* web_view = CreateWKWebView(frame, configuration, browser_state);
web_view.customUserAgent = base::SysUTF8ToNSString(
web::GetWebClient()->GetUserAgent(use_desktop_user_agent));
return web_view;
}
WKWebView* CreateWKWebView(CGRect frame,
WKWebViewConfiguration* configuration,
BrowserState* browser_state) {
VerifyWKWebViewCreationPreConditions(browser_state, configuration);
GetWebClient()->PreWebViewCreation();
WKWebView* result =
WKWebView* web_view =
[[WKWebView alloc] initWithFrame:frame configuration:configuration];
// Set the user agent.
web_view.customUserAgent = base::SysUTF8ToNSString(
web::GetWebClient()->GetUserAgent(use_desktop_user_agent));
// By default the web view uses a very sluggish scroll speed. Set it to a more
// reasonable value.
result.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;
web_view.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;
// Starting in iOS10, |allowsLinkPreview| defaults to YES. This should be
// disabled since the default implementation will open the link in Safari.
// TODO(crbug.com/622746): Remove once web// link preview implementation is
// created.
result.allowsLinkPreview = NO;
web_view.allowsLinkPreview = NO;
return web_view;
}
return result;
WKWebView* CreateWKWebView(CGRect frame,
WKWebViewConfiguration* configuration,
BrowserState* browser_state) {
BOOL use_desktop_user_agent = NO;
return CreateWKWebView(frame, configuration, browser_state,
use_desktop_user_agent);
}
} // namespace web
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