{"action":"created","comment":{"url":"https://api.github.com/repos/ampproject/amphtml/pulls/comments/66682820","id":66682820,"diff_hunk":"@@ -0,0 +1,161 @@\n+/**\n+ * Copyright 2016 The AMP HTML Authors. All Rights Reserved.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *      http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS-IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+import {Layout} from '../../../src/layout';\n+import {setStyles} from '../../../src/style';\n+import {user} from '../../../src/log';\n+import {platform} from '../../../src/platform';\n+import {viewerFor} from '../../../src/viewer';\n+import {CSS} from '../../../build/amp-app-banner-0.1.css';\n+import {urlReplacementsFor} from '../../../src/url-replacements';\n+import {xhrFor} from '../../../src/xhr';\n+\n+const TAG = 'amp-app-banner';\n+\n+class AmpAppBanner extends AMP.BaseElement {\n+\n+  /** @override */\n+  preconnectCallback(onLayout) {\n+    if (platform.isIos()) {\n+      this.preconnect.url('https://itunes.apple.com', onLayout);\n+    } else if (platform.isAndroid()) {\n+      this.preconnect.url('https://play.google.com', onLayout);\n+    }\n+  }\n+\n+  /** @override */\n+  isLayoutSupported(layout) {\n+    return layout == Layout.CONTAINER;\n+  }\n+\n+  /** @override */\n+  buildCallback() {\n+    if (!platform.isIos() && !platform.isAndroid()) {\n+      setStyles(this.element, {\n+        'display': 'none',\n+      });\n+      return;\n+    }\n+\n+    /** @private @const {!Viewer} */\n+    const viewer = viewerFor(this.getWin());\n+\n+    /** @private @const {!Xhr} */\n+    this.xhr_ = xhrFor(this.getWin());\n+\n+    /** @const @private {!Element} */\n+    this.installLink_ = this.element.querySelector('a[install-link]');\n+    user.assert(this.installLink_, '<a install-link> is required inside %s: %s',\n+        TAG, this.element);\n+\n+    /** @const @private {!Element} */\n+    this.openLink_ = this.element.querySelector('a[open-link]');\n+    user.assert(this.openLink_, '<a open-link> is required inside %s: %s',\n+        TAG, this.element);\n+\n+    if (platform.isIos()) {\n+      const meta = this.getWin().document.head.querySelector(\n+          'meta[name=apple-itunes-app]');\n+      user.assert(meta,\n+          '<meta name=apple-itunes-app> in document header is required: %s',\n+          this.element);\n+\n+      // If non-embedded document and on Safari iOS just use the native app\n+      // banner Safari supports if the meta tag is already setup.\n+      if (!viewer.isEmbedded() && platform.isSafari()) {\n+        setStyles(this.element, {\n+          'display': 'none',\n+        });\n+        return;\n+      }\n+      this.parseIosMetaContent_(meta.getAttribute('content'));\n+    }\n+\n+    // TODO: Provide a way to dismiss the banner and persist it.\n+  }\n+\n+  /** @override */\n+  layoutCallback() {\n+    if (!platform.isAndroid()) {\n+      return Promise.resolve();\n+    }\n+\n+    const manifestLink = this.getWin().document.head.querySelector(\n+        'link[rel=manifest],link[rel=amp-manifest]');\n+    user.assert(manifestLink,\n+        '<link rel=manifest> in the document head is required: %s',\n+        this.element);\n+\n+    return this.xhr_.fetchJson(manifestLink.getAttribute('href'))\n+        .then(response => {\n+          this.parseManifest_(response);\n+        }).catch(unusedError => {\n+          // TODO: What do we do when we fail to fetch manifest.","path":"extensions/amp-app-banner/0.1/amp-app-banner.js","position":null,"original_position":106,"commit_id":"dfb8d3327a75ffd756efb158aa87f8239b8947a8","original_commit_id":"7782ef84f443ecf2ba6a34595ff3c8066a473d96","user":{"login":"mkhatib","id":2647,"avatar_url":"https://avatars.githubusercontent.com/u/2647?v=3","gravatar_id":"","url":"https://api.github.com/users/mkhatib","html_url":"https://github.com/mkhatib","followers_url":"https://api.github.com/users/mkhatib/followers","following_url":"https://api.github.com/users/mkhatib/following{/other_user}","gists_url":"https://api.github.com/users/mkhatib/gists{/gist_id}","starred_url":"https://api.github.com/users/mkhatib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkhatib/subscriptions","organizations_url":"https://api.github.com/users/mkhatib/orgs","repos_url":"https://api.github.com/users/mkhatib/repos","events_url":"https://api.github.com/users/mkhatib/events{/privacy}","received_events_url":"https://api.github.com/users/mkhatib/received_events","type":"User","site_admin":false},"body":"Not sure what do you mean by a pure fallback to native banner? Native banner on iOS is not fixed.","created_at":"2016-06-10T21:21:12Z","updated_at":"2016-06-10T21:21:12Z","html_url":"https://github.com/ampproject/amphtml/pull/3447#discussion_r66682820","pull_request_url":"https://api.github.com/repos/ampproject/amphtml/pulls/3447","_links":{"self":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/comments/66682820"},"html":{"href":"https://github.com/ampproject/amphtml/pull/3447#discussion_r66682820"},"pull_request":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/3447"}}},"pull_request":{"url":"https://api.github.com/repos/ampproject/amphtml/pulls/3447","id":72593422,"html_url":"https://github.com/ampproject/amphtml/pull/3447","diff_url":"https://github.com/ampproject/amphtml/pull/3447.diff","patch_url":"https://github.com/ampproject/amphtml/pull/3447.patch","issue_url":"https://api.github.com/repos/ampproject/amphtml/issues/3447","number":3447,"state":"open","locked":false,"title":"WIP(@mkhatib): Add amp-app-banner","user":{"login":"mkhatib","id":2647,"avatar_url":"https://avatars.githubusercontent.com/u/2647?v=3","gravatar_id":"","url":"https://api.github.com/users/mkhatib","html_url":"https://github.com/mkhatib","followers_url":"https://api.github.com/users/mkhatib/followers","following_url":"https://api.github.com/users/mkhatib/following{/other_user}","gists_url":"https://api.github.com/users/mkhatib/gists{/gist_id}","starred_url":"https://api.github.com/users/mkhatib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkhatib/subscriptions","organizations_url":"https://api.github.com/users/mkhatib/orgs","repos_url":"https://api.github.com/users/mkhatib/repos","events_url":"https://api.github.com/users/mkhatib/events{/privacy}","received_events_url":"https://api.github.com/users/mkhatib/received_events","type":"User","site_admin":false},"body":"Implements #800 - [Try out the demo here](http://amp-mk-2.herokuapp.com/examples.build/article.amp.max.html). Try it on iOS and Android and Desktop (shouldn't show anything on desktop).","created_at":"2016-06-04T05:11:48Z","updated_at":"2016-06-10T21:21:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1e10f7383ea440c9e57cb0b98dd927b3d382f919","assignee":{"login":"cramforce","id":89679,"avatar_url":"https://avatars.githubusercontent.com/u/89679?v=3","gravatar_id":"","url":"https://api.github.com/users/cramforce","html_url":"https://github.com/cramforce","followers_url":"https://api.github.com/users/cramforce/followers","following_url":"https://api.github.com/users/cramforce/following{/other_user}","gists_url":"https://api.github.com/users/cramforce/gists{/gist_id}","starred_url":"https://api.github.com/users/cramforce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cramforce/subscriptions","organizations_url":"https://api.github.com/users/cramforce/orgs","repos_url":"https://api.github.com/users/cramforce/repos","events_url":"https://api.github.com/users/cramforce/events{/privacy}","received_events_url":"https://api.github.com/users/cramforce/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/ampproject/amphtml/pulls/3447/commits","review_comments_url":"https://api.github.com/repos/ampproject/amphtml/pulls/3447/comments","review_comment_url":"https://api.github.com/repos/ampproject/amphtml/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ampproject/amphtml/issues/3447/comments","statuses_url":"https://api.github.com/repos/ampproject/amphtml/statuses/dfb8d3327a75ffd756efb158aa87f8239b8947a8","head":{"label":"mkhatib:amp-app-banner","ref":"amp-app-banner","sha":"dfb8d3327a75ffd756efb158aa87f8239b8947a8","user":{"login":"mkhatib","id":2647,"avatar_url":"https://avatars.githubusercontent.com/u/2647?v=3","gravatar_id":"","url":"https://api.github.com/users/mkhatib","html_url":"https://github.com/mkhatib","followers_url":"https://api.github.com/users/mkhatib/followers","following_url":"https://api.github.com/users/mkhatib/following{/other_user}","gists_url":"https://api.github.com/users/mkhatib/gists{/gist_id}","starred_url":"https://api.github.com/users/mkhatib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkhatib/subscriptions","organizations_url":"https://api.github.com/users/mkhatib/orgs","repos_url":"https://api.github.com/users/mkhatib/repos","events_url":"https://api.github.com/users/mkhatib/events{/privacy}","received_events_url":"https://api.github.com/users/mkhatib/received_events","type":"User","site_admin":false},"repo":{"id":49671997,"name":"amphtml","full_name":"mkhatib/amphtml","owner":{"login":"mkhatib","id":2647,"avatar_url":"https://avatars.githubusercontent.com/u/2647?v=3","gravatar_id":"","url":"https://api.github.com/users/mkhatib","html_url":"https://github.com/mkhatib","followers_url":"https://api.github.com/users/mkhatib/followers","following_url":"https://api.github.com/users/mkhatib/following{/other_user}","gists_url":"https://api.github.com/users/mkhatib/gists{/gist_id}","starred_url":"https://api.github.com/users/mkhatib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkhatib/subscriptions","organizations_url":"https://api.github.com/users/mkhatib/orgs","repos_url":"https://api.github.com/users/mkhatib/repos","events_url":"https://api.github.com/users/mkhatib/events{/privacy}","received_events_url":"https://api.github.com/users/mkhatib/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mkhatib/amphtml","description":"AMP HTML source code, samples, and documentation.  See below for more info.","fork":true,"url":"https://api.github.com/repos/mkhatib/amphtml","forks_url":"https://api.github.com/repos/mkhatib/amphtml/forks","keys_url":"https://api.github.com/repos/mkhatib/amphtml/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mkhatib/amphtml/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mkhatib/amphtml/teams","hooks_url":"https://api.github.com/repos/mkhatib/amphtml/hooks","issue_events_url":"https://api.github.com/repos/mkhatib/amphtml/issues/events{/number}","events_url":"https://api.github.com/repos/mkhatib/amphtml/events","assignees_url":"https://api.github.com/repos/mkhatib/amphtml/assignees{/user}","branches_url":"https://api.github.com/repos/mkhatib/amphtml/branches{/branch}","tags_url":"https://api.github.com/repos/mkhatib/amphtml/tags","blobs_url":"https://api.github.com/repos/mkhatib/amphtml/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mkhatib/amphtml/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mkhatib/amphtml/git/refs{/sha}","trees_url":"https://api.github.com/repos/mkhatib/amphtml/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mkhatib/amphtml/statuses/{sha}","languages_url":"https://api.github.com/repos/mkhatib/amphtml/languages","stargazers_url":"https://api.github.com/repos/mkhatib/amphtml/stargazers","contributors_url":"https://api.github.com/repos/mkhatib/amphtml/contributors","subscribers_url":"https://api.github.com/repos/mkhatib/amphtml/subscribers","subscription_url":"https://api.github.com/repos/mkhatib/amphtml/subscription","commits_url":"https://api.github.com/repos/mkhatib/amphtml/commits{/sha}","git_commits_url":"https://api.github.com/repos/mkhatib/amphtml/git/commits{/sha}","comments_url":"https://api.github.com/repos/mkhatib/amphtml/comments{/number}","issue_comment_url":"https://api.github.com/repos/mkhatib/amphtml/issues/comments{/number}","contents_url":"https://api.github.com/repos/mkhatib/amphtml/contents/{+path}","compare_url":"https://api.github.com/repos/mkhatib/amphtml/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mkhatib/amphtml/merges","archive_url":"https://api.github.com/repos/mkhatib/amphtml/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mkhatib/amphtml/downloads","issues_url":"https://api.github.com/repos/mkhatib/amphtml/issues{/number}","pulls_url":"https://api.github.com/repos/mkhatib/amphtml/pulls{/number}","milestones_url":"https://api.github.com/repos/mkhatib/amphtml/milestones{/number}","notifications_url":"https://api.github.com/repos/mkhatib/amphtml/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mkhatib/amphtml/labels{/name}","releases_url":"https://api.github.com/repos/mkhatib/amphtml/releases{/id}","deployments_url":"https://api.github.com/repos/mkhatib/amphtml/deployments","created_at":"2016-01-14T20:05:58Z","updated_at":"2016-01-14T20:06:00Z","pushed_at":"2016-06-10T21:19:30Z","git_url":"git://github.com/mkhatib/amphtml.git","ssh_url":"git@github.com:mkhatib/amphtml.git","clone_url":"https://github.com/mkhatib/amphtml.git","svn_url":"https://github.com/mkhatib/amphtml","homepage":"https://ampproject.org","size":60031,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ampproject:master","ref":"master","sha":"298c78d032253d6ebe315467855047679dbe093d","user":{"login":"ampproject","id":14114390,"avatar_url":"https://avatars.githubusercontent.com/u/14114390?v=3","gravatar_id":"","url":"https://api.github.com/users/ampproject","html_url":"https://github.com/ampproject","followers_url":"https://api.github.com/users/ampproject/followers","following_url":"https://api.github.com/users/ampproject/following{/other_user}","gists_url":"https://api.github.com/users/ampproject/gists{/gist_id}","starred_url":"https://api.github.com/users/ampproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ampproject/subscriptions","organizations_url":"https://api.github.com/users/ampproject/orgs","repos_url":"https://api.github.com/users/ampproject/repos","events_url":"https://api.github.com/users/ampproject/events{/privacy}","received_events_url":"https://api.github.com/users/ampproject/received_events","type":"Organization","site_admin":false},"repo":{"id":41766002,"name":"amphtml","full_name":"ampproject/amphtml","owner":{"login":"ampproject","id":14114390,"avatar_url":"https://avatars.githubusercontent.com/u/14114390?v=3","gravatar_id":"","url":"https://api.github.com/users/ampproject","html_url":"https://github.com/ampproject","followers_url":"https://api.github.com/users/ampproject/followers","following_url":"https://api.github.com/users/ampproject/following{/other_user}","gists_url":"https://api.github.com/users/ampproject/gists{/gist_id}","starred_url":"https://api.github.com/users/ampproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ampproject/subscriptions","organizations_url":"https://api.github.com/users/ampproject/orgs","repos_url":"https://api.github.com/users/ampproject/repos","events_url":"https://api.github.com/users/ampproject/events{/privacy}","received_events_url":"https://api.github.com/users/ampproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ampproject/amphtml","description":"AMP HTML source code, samples, and documentation.  See below for more info.","fork":false,"url":"https://api.github.com/repos/ampproject/amphtml","forks_url":"https://api.github.com/repos/ampproject/amphtml/forks","keys_url":"https://api.github.com/repos/ampproject/amphtml/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ampproject/amphtml/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ampproject/amphtml/teams","hooks_url":"https://api.github.com/repos/ampproject/amphtml/hooks","issue_events_url":"https://api.github.com/repos/ampproject/amphtml/issues/events{/number}","events_url":"https://api.github.com/repos/ampproject/amphtml/events","assignees_url":"https://api.github.com/repos/ampproject/amphtml/assignees{/user}","branches_url":"https://api.github.com/repos/ampproject/amphtml/branches{/branch}","tags_url":"https://api.github.com/repos/ampproject/amphtml/tags","blobs_url":"https://api.github.com/repos/ampproject/amphtml/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ampproject/amphtml/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ampproject/amphtml/git/refs{/sha}","trees_url":"https://api.github.com/repos/ampproject/amphtml/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ampproject/amphtml/statuses/{sha}","languages_url":"https://api.github.com/repos/ampproject/amphtml/languages","stargazers_url":"https://api.github.com/repos/ampproject/amphtml/stargazers","contributors_url":"https://api.github.com/repos/ampproject/amphtml/contributors","subscribers_url":"https://api.github.com/repos/ampproject/amphtml/subscribers","subscription_url":"https://api.github.com/repos/ampproject/amphtml/subscription","commits_url":"https://api.github.com/repos/ampproject/amphtml/commits{/sha}","git_commits_url":"https://api.github.com/repos/ampproject/amphtml/git/commits{/sha}","comments_url":"https://api.github.com/repos/ampproject/amphtml/comments{/number}","issue_comment_url":"https://api.github.com/repos/ampproject/amphtml/issues/comments{/number}","contents_url":"https://api.github.com/repos/ampproject/amphtml/contents/{+path}","compare_url":"https://api.github.com/repos/ampproject/amphtml/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ampproject/amphtml/merges","archive_url":"https://api.github.com/repos/ampproject/amphtml/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ampproject/amphtml/downloads","issues_url":"https://api.github.com/repos/ampproject/amphtml/issues{/number}","pulls_url":"https://api.github.com/repos/ampproject/amphtml/pulls{/number}","milestones_url":"https://api.github.com/repos/ampproject/amphtml/milestones{/number}","notifications_url":"https://api.github.com/repos/ampproject/amphtml/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ampproject/amphtml/labels{/name}","releases_url":"https://api.github.com/repos/ampproject/amphtml/releases{/id}","deployments_url":"https://api.github.com/repos/ampproject/amphtml/deployments","created_at":"2015-09-01T22:10:53Z","updated_at":"2016-06-10T20:13:45Z","pushed_at":"2016-06-10T21:19:31Z","git_url":"git://github.com/ampproject/amphtml.git","ssh_url":"git@github.com:ampproject/amphtml.git","clone_url":"https://github.com/ampproject/amphtml.git","svn_url":"https://github.com/ampproject/amphtml","homepage":"https://ampproject.org","size":85158,"stargazers_count":7641,"watchers_count":7641,"language":"JavaScript","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":1051,"mirror_url":null,"open_issues_count":483,"forks":1051,"open_issues":483,"watchers":7641,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/3447"},"html":{"href":"https://github.com/ampproject/amphtml/pull/3447"},"issue":{"href":"https://api.github.com/repos/ampproject/amphtml/issues/3447"},"comments":{"href":"https://api.github.com/repos/ampproject/amphtml/issues/3447/comments"},"review_comments":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/3447/comments"},"review_comment":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/3447/commits"},"statuses":{"href":"https://api.github.com/repos/ampproject/amphtml/statuses/dfb8d3327a75ffd756efb158aa87f8239b8947a8"}}}}
{"actor":{"display_login":"mkhatib"}}