mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-16 16:16:40 +03:00
dc8b007d56
This is a port of the internal changes: cr/321495405, cr/321592702, and cr/321594488. Change-Id: If6a4c4266ed10a70b01442974dbd19329bb5122e
53 lines
1.2 KiB
JavaScript
53 lines
1.2 KiB
JavaScript
/*! @license
|
|
* Shaka Player
|
|
* Copyright 2016 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
goog.provide('shaka.polyfill.IndexedDB');
|
|
|
|
goog.require('goog.asserts');
|
|
goog.require('shaka.log');
|
|
goog.require('shaka.polyfill');
|
|
goog.require('shaka.util.Platform');
|
|
|
|
|
|
/**
|
|
* @summary A polyfill to patch IndexedDB bugs.
|
|
*/
|
|
shaka.polyfill.IndexedDB = class {
|
|
/**
|
|
* Install the polyfill if needed.
|
|
*/
|
|
static install() {
|
|
shaka.log.debug('IndexedDB.install');
|
|
|
|
let disableIDB = false;
|
|
if (shaka.util.Platform.isChromecast()) {
|
|
shaka.log.debug('Removing IndexedDB from ChromeCast');
|
|
disableIDB = true;
|
|
} else {
|
|
try {
|
|
// This is necessary to avoid Closure compiler over optimize this
|
|
// block and remove it if it looks like a noop
|
|
if (window.indexedDB) {
|
|
disableIDB = false;
|
|
}
|
|
} catch (e) {
|
|
shaka.log.debug(
|
|
'Removing IndexedDB due to an exception when accessing it');
|
|
disableIDB = true;
|
|
}
|
|
}
|
|
|
|
if (disableIDB) {
|
|
delete window.indexedDB;
|
|
goog.asserts.assert(
|
|
!window.indexedDB, 'Failed to override window.indexedDB');
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
shaka.polyfill.register(shaka.polyfill.IndexedDB.install);
|