-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate consent state enum file (#15567)
* seperate file * import * add consent.js * dep-check-fix * fix test
- Loading branch information
Showing
10 changed files
with
80 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* Copyright 2018 The AMP HTML Authors. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS-IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { | ||
CONSENT_POLICY_STATE, // eslint-disable-line no-unused-vars | ||
} from './consent-state'; | ||
import {Services} from './services'; | ||
|
||
/** | ||
* Returns a promise that resolve when all consent state the policy wait | ||
* for resolve. Or if consent service is not available. | ||
* @param {!./service/ampdoc-impl.AmpDoc} ampdoc | ||
* @param {string} policyId | ||
* @return {!Promise<?CONSENT_POLICY_STATE>} | ||
*/ | ||
export function getConsentPolicyState(ampdoc, policyId) { | ||
return Services.consentPolicyServiceForDocOrNull(ampdoc) | ||
.then(consentPolicy => { | ||
if (!consentPolicy) { | ||
return null; | ||
} | ||
return consentPolicy.whenPolicyResolved( | ||
/** @type {string} */ (policyId)); | ||
}); | ||
} | ||
|
||
/** | ||
* Returns a promise that resolves to a sharedData retrieved from consent | ||
* remote endpoint. | ||
* @param {!./service/ampdoc-impl.AmpDoc} ampdoc | ||
* @param {string} policyId | ||
* @return {!Promise<?Object>} | ||
*/ | ||
export function getConsentPolicySharedData(ampdoc, policyId) { | ||
return Services.consentPolicyServiceForDocOrNull(ampdoc) | ||
.then(consentPolicy => { | ||
if (!consentPolicy) { | ||
return null; | ||
} | ||
return consentPolicy.getMergedSharedData( | ||
/** @type {string} */ (policyId)); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters