Skip to content

Commit

Permalink
Extract ViewerInterface. (#24155)
Browse files Browse the repository at this point in the history
  • Loading branch information
lannka authored Aug 23, 2019
1 parent a85aa2f commit c2be02a
Show file tree
Hide file tree
Showing 43 changed files with 511 additions and 367 deletions.
2 changes: 2 additions & 0 deletions build-system/tasks/presubmit-checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ const forbiddenTerms = {
'src/error.js',
'src/utils/xhr-utils.js',
'src/service/viewer-impl.js',
'src/service/viewer-interface.js',
'src/service/viewer-cid-api.js',
'src/inabox/inabox-viewer.js',
'src/service/cid-impl.js',
Expand Down Expand Up @@ -555,6 +556,7 @@ const forbiddenTerms = {
'src/3p-frame.js',
'src/iframe-attributes.js',
'src/service/viewer-impl.js',
'src/service/viewer-interface.js',
'src/inabox/inabox-viewer.js',
],
},
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-access/0.1/amp-access-server-jwt.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class AccessServerJwtAdapter {
/** @private @const */
this.clientAdapter_ = new AccessClientAdapter(ampdoc, configJson, context);

/** @private @const {!../../../src/service/viewer-impl.Viewer} */
/** @private @const {!../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(ampdoc);

/** @const @private {!../../../src/service/xhr-impl.Xhr} */
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-access/0.1/amp-access-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class AccessServerAdapter {
/** @private @const */
this.clientAdapter_ = new AccessClientAdapter(ampdoc, configJson, context);

/** @private @const {!../../../src/service/viewer-impl.Viewer} */
/** @private @const {!../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(ampdoc);

/** @const @protected {!../../../src/service/xhr-impl.Xhr} */
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-access/0.1/amp-access.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class AccessService {
/** @private @const {!Promise<!../../../src/service/cid-impl.CidDef>} */
this.cid_ = Services.cidForDoc(ampdoc);

/** @private @const {!../../../src/service/viewer-impl.Viewer} */
/** @private @const {!../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(ampdoc);

/** @private @const {!../../../src/service/viewport/viewport-interface.ViewportInterface} */
Expand Down
8 changes: 4 additions & 4 deletions extensions/amp-access/0.1/login-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ export function getLoginUrl(ampdoc, urlOrPromise) {
*/
class ViewerLoginDialog {
/**
* @param {!../../../src/service/viewer-impl.Viewer} viewer
* @param {!../../../src/service/viewer-interface.ViewerInterface} viewer
* @param {string|!Promise<string>} urlOrPromise
*/
constructor(viewer, urlOrPromise) {
/** @const {!../../../src/service/viewer-impl.Viewer} */
/** @const {!../../../src/service/viewer-interface.ViewerInterface} */
this.viewer = viewer;

/** @const {string|!Promise<string>} */
Expand Down Expand Up @@ -122,14 +122,14 @@ class ViewerLoginDialog {
export class WebLoginDialog {
/**
* @param {!Window} win
* @param {!../../../src/service/viewer-impl.Viewer} viewer
* @param {!../../../src/service/viewer-interface.ViewerInterface} viewer
* @param {string|!Promise<string>} urlOrPromise
*/
constructor(win, viewer, urlOrPromise) {
/** @const {!Window} */
this.win = win;

/** @const {!../../../src/service/viewer-impl.Viewer} */
/** @const {!../../../src/service/viewer-interface.ViewerInterface} */
this.viewer = viewer;

/** @const {string|!Promise<string>} */
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-ad/0.1/amp-ad-xorigin-iframe-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class AmpAdXOriginIframeHandler {
/** @private {!Array<!Function>} functions to unregister listeners */
this.unlisteners_ = [];

/** @private @const {!../../../src/service/viewer-impl.Viewer} */
/** @private @const {!../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(this.baseInstance_.getAmpDoc());

/** @private @const {!../../../src/service/viewport/viewport-interface.ViewportInterface} */
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-analytics/0.1/activity-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export class Activity {
/** @private @const {!ActivityHistory} */
this.activityHistory_ = new ActivityHistory();

/** @private @const {!../../../src/service/viewer-impl.Viewer} */
/** @private @const {!../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(this.ampdoc);

/** @private @const {!../../../src/service/viewport/viewport-interface.ViewportInterface} */
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-analytics/0.1/analytics-root.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class AnalyticsRoot {

/**
* The viewer of analytics root
* @return {!../../../src/service/viewer-impl.Viewer}
* @return {!../../../src/service/viewer-interface.ViewerInterface}
*/
getViewer() {
return Services.viewerForDoc(this.ampdoc);
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-app-banner/0.1/amp-app-banner.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export class AmpIosAppBanner extends AbstractAppBanner {
constructor(element) {
super(element);

/** @private {?../../../src/service/viewer-impl.Viewer} */
/** @private {?../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = null;

/** @private {?Element} */
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-bind/0.1/bind-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export class Bind {
/** @private {?./bind-validator.BindValidator} */
this.validator_ = null;

/** @const @private {!../../../src/service/viewer-impl.Viewer} */
/** @const @private {!../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(this.ampdoc);
this.viewer_.onMessageRespond('premutate', this.premutate_.bind(this));

Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-consent/0.1/consent-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class ConsentUI {
/** @private {!../../../src/service/viewport/viewport-interface.ViewportInterface} */
this.viewport_ = Services.viewportForDoc(this.ampdoc_);

/** @private {?../../../src/service/viewer-impl.Viewer} */
/** @private {?../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(this.ampdoc_);

/** @private {!Element} */
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-experiment/1.0/variant.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class Variants {
* Allocates the current page view to an experiment variant based on the given
* experiment from the config.
* @param {!../../../src/service/ampdoc-impl.AmpDoc} ampdoc
* @param {!../../../src/service/viewer-impl.Viewer} viewer
* @param {!../../../src/service/viewer-interface.ViewerInterface} viewer
* @param {string} experimentName
* @param {!JsonObject} experimentObject
* @return {!Promise<?string>}
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-form/0.1/amp-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class AmpForm {
/** @const @private {!../../../src/service/resources-impl.ResourcesDef} */
this.resources_ = Services.resourcesForDoc(this.form_);

/** @const @private {!../../../src/service/viewer-impl.Viewer} */
/** @const @private {!../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(this.form_);

/**
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-fx-collection/0.1/amp-fx-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class AmpFxCollection {
/** @private @const {!Array<!Element>} */
this.seen_ = [];

/** @private @const {!../../../src/service/viewer-impl.Viewer} */
/** @private @const {!../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(ampdoc);

Promise.all([ampdoc.whenReady(), this.viewer_.whenFirstVisible()]).then(
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-live-list/0.1/live-list-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class LiveListManager {
/** @private @const {!Object<string, !./amp-live-list.AmpLiveList>} */
this.liveLists_ = Object.create(null);

/** @private @const {!../../../src/service/viewer-impl.Viewer} */
/** @private @const {!../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(this.ampdoc);

/** @private @const {!../../../src/service/extensions-impl.Extensions} */
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-skimlinks/0.1/amp-skimlinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class AmpSkimlinks extends AMP.BaseElement {
/** @private {?../../../src/service/document-info-impl.DocumentInfoDef} */
this.docInfo_ = null;

/** @private {?../../../src/service/viewer-impl.Viewer} */
/** @private {?../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = null;

/** @private {?./link-rewriter/link-rewriter-manager.LinkRewriterManager} */
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-social-share/0.1/amp-social-share.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AmpSocialShare extends AMP.BaseElement {
/** @private {?../../../src/service/platform-impl.Platform} */
this.platform_ = null;

/** @private {?../../../src/service/viewer-impl.Viewer} */
/** @private {?../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = null;

/** @private {?string} */
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-story/0.1/amp-story-info-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class InfoDialog {
/** @private {?Element} */
this.moreInfoLinkEl_ = null;

/** @const @private {!../../../src/service/viewer-impl.Viewer} */
/** @const @private {!../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(this.parentEl_);
}

Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-story/1.0/amp-story-info-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class InfoDialog {
/** @private {?Element} */
this.moreInfoLinkEl_ = null;

/** @const @private {!../../../src/service/viewer-impl.Viewer} */
/** @const @private {!../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(this.parentEl_);
}

Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-story/1.0/amp-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export class AmpStory extends AMP.BaseElement {
/** @private @const {!../../../src/service/platform-impl.Platform} */
this.platform_ = Services.platformFor(this.win);

/** @private @const {!../../../src/service/viewer-impl.Viewer} */
/** @private @const {!../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(this.element);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ export class GoogleSubscriptionsPlatform {
}

/**
* @param {!../../../src/service/viewer-impl.Viewer} viewer
* @param {!../../../src/service/viewer-interface.ViewerInterface} viewer
* @private
*/
resolveGoogleViewer_(viewer) {
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-subscriptions/0.1/amp-subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class SubscriptionService {
/** @private {!ViewerTracker} */
this.viewerTracker_ = new ViewerTracker(ampdoc);

/** @private @const {!../../../src/service/viewer-impl.Viewer} */
/** @private @const {!../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(ampdoc);

/** @private {?Promise} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class ViewerSubscriptionPlatform {
serviceAdapter
);

/** @const @private {!../../../src/service/viewer-impl.Viewer} */
/** @const @private {!../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(this.ampdoc_);
this.viewer_.onMessage(
'subscriptionchange',
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-subscriptions/0.1/viewer-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class ViewerTracker {
/** @private */
this.ampdoc_ = ampdoc;

/** @private @const {!../../../src/service/viewer-impl.Viewer} */
/** @private @const {!../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(ampdoc);

/** @private {?Promise} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ export class UserNotificationManager {
/** @private @const {!Object<string,!UserNotificationDeferDef>} */
this.deferRegistry_ = Object.create(null);

/** @private @const {!../../../src/service/viewer-impl.Viewer} */
/** @private @const {!../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(this.ampdoc);

/** @private @const {!Promise} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class AmpViewerAssistance {
);
});

/** @private @const {!../../../src/service/viewer-impl.Viewer} */
/** @private @const {!../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(ampdoc);

/** @private @const {!../../../src/service/action-impl.ActionService} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class AmpViewerIntegration {
}

/**
* @param {!../../../src/service/viewer-impl.Viewer} viewer
* @param {!../../../src/service/viewer-interface.ViewerInterface} viewer
* @param {!../../../src/service/ampdoc-impl.AmpDoc} ampdoc
* @param {string} origin
* @param {!Messaging} messaging
Expand Down Expand Up @@ -206,7 +206,7 @@ export class AmpViewerIntegration {

/**
* @param {!Messaging} messaging
* @param {!../../../src/service/viewer-impl.Viewer} viewer
* @param {!../../../src/service/viewer-interface.ViewerInterface} viewer
* @param {string} origin
* @return {Promise<*>|undefined}
* @private
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-viewer-integration/0.1/highlight-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class HighlightHandler {
constructor(ampdoc, highlightInfo) {
/** @private @const {!../../../src/service/ampdoc-impl.AmpDoc} */
this.ampdoc_ = ampdoc;
/** @private @const {!../../../src/service/viewer-impl.Viewer} */
/** @private @const {!../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(ampdoc);
/** @private @const {!../../../src/service/viewport/viewport-interface.ViewportInterface} */
this.viewport_ = Services.viewportForDoc(this.ampdoc_);
Expand Down
4 changes: 2 additions & 2 deletions src/chunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,9 @@ class Chunks {
}
});

/** @private @const {!Promise<!./service/viewer-impl.Viewer>} */
/** @private @const {!Promise<!./service/viewer-interface.ViewerInterface>} */
this.viewerPromise_ = Services.viewerPromiseForDoc(ampDoc);
/** @protected {?./service/viewer-impl.Viewer} */
/** @protected {?./service/viewer-interface.ViewerInterface} */
this.viewer = null;
this.viewerPromise_.then(viewer => {
this.viewer = viewer;
Expand Down
2 changes: 1 addition & 1 deletion src/service/cache-cid-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class CacheCidApi {
/** @private {!./ampdoc-impl.AmpDoc} */
this.ampdoc_ = ampdoc;

/** @private {!./viewer-impl.Viewer} */
/** @private {!./viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(this.ampdoc_);

/** @private {?Promise<?string>} */
Expand Down
4 changes: 2 additions & 2 deletions src/service/history-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -855,13 +855,13 @@ export class HistoryBindingNatural_ {
export class HistoryBindingVirtual_ {
/**
* @param {!Window} win
* @param {!./viewer-impl.Viewer} viewer
* @param {!./viewer-interface.ViewerInterface} viewer
*/
constructor(win, viewer) {
/** @const {!Window} */
this.win = win;

/** @private @const {!./viewer-impl.Viewer} */
/** @private @const {!./viewer-interface.ViewerInterface} */
this.viewer_ = viewer;

/** @private {number} */
Expand Down
2 changes: 1 addition & 1 deletion src/service/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class Navigation {
/** @private @const {!./viewport/viewport-interface.ViewportInterface} */
this.viewport_ = Services.viewportForDoc(this.ampdoc);

/** @private @const {!./viewer-impl.Viewer} */
/** @private @const {!./viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(this.ampdoc);

/** @private @const {!./history-impl.History} */
Expand Down
2 changes: 1 addition & 1 deletion src/service/performance-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class Performance {
/** @const @private {!Array<TickEventDef>} */
this.events_ = [];

/** @private {?./viewer-impl.Viewer} */
/** @private {?./viewer-interface.ViewerInterface} */
this.viewer_ = null;

/** @private {?./resources-impl.ResourcesDef} */
Expand Down
2 changes: 1 addition & 1 deletion src/service/resources-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ export class Resources {
/** @const {!Window} */
this.win = ampdoc.win;

/** @const @private {!./viewer-impl.Viewer} */
/** @const @private {!./viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(ampdoc);

/** @private {boolean} */
Expand Down
8 changes: 4 additions & 4 deletions src/service/storage-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ const MAX_VALUES_PER_ORIGIN = 8;
export class Storage {
/**
* @param {!./ampdoc-impl.AmpDoc} ampdoc
* @param {!../service/viewer-impl.Viewer} viewer
* @param {!../service/viewer-interface.ViewerInterface} viewer
* @param {!StorageBindingDef} binding
*/
constructor(ampdoc, viewer, binding) {
/** @const {!./ampdoc-impl.AmpDoc} */
this.ampdoc = ampdoc;

/** @private @const {!../service/viewer-impl.Viewer} */
/** @private @const {!../service/viewer-interface.ViewerInterface} */
this.viewer_ = viewer;

/** @private @const {!StorageBindingDef} */
Expand Down Expand Up @@ -384,10 +384,10 @@ export class LocalStorageBinding {
*/
export class ViewerStorageBinding {
/**
* @param {!../service/viewer-impl.Viewer} viewer
* @param {!../service/viewer-interface.ViewerInterface} viewer
*/
constructor(viewer) {
/** @private @const {!../service/viewer-impl.Viewer} */
/** @private @const {!../service/viewer-interface.ViewerInterface} */
this.viewer_ = viewer;
}

Expand Down
2 changes: 1 addition & 1 deletion src/service/viewer-cid-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class ViewerCidApi {
/** @private {!./ampdoc-impl.AmpDoc} */
this.ampdoc_ = ampdoc;

/** @private {!./viewer-impl.Viewer} */
/** @private {!./viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(this.ampdoc_);

const {canonicalUrl} = Services.documentInfoForDoc(this.ampdoc_);
Expand Down
Loading

0 comments on commit c2be02a

Please sign in to comment.