diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-01 02:31:56 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-01 02:31:56 +0000 |
commit | 11158e2d4794c6f91f4276a5160b685d2229bbc4 (patch) | |
tree | 8f2c391c422a7d7d65dad38090e47350e9f2d671 /content/browser/resources/media/util.js | |
parent | f5a263d76dd8280a860fc084df63be5f669223ce (diff) | |
download | chromium_src-11158e2d4794c6f91f4276a5160b685d2229bbc4.zip chromium_src-11158e2d4794c6f91f4276a5160b685d2229bbc4.tar.gz chromium_src-11158e2d4794c6f91f4276a5160b685d2229bbc4.tar.bz2 |
Move chrome://media-internals to content. This allows us to hide implementation details from the public API.
BUG=169170
Review URL: https://codereview.chromium.org/12153002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180040 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/resources/media/util.js')
-rw-r--r-- | content/browser/resources/media/util.js | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/content/browser/resources/media/util.js b/content/browser/resources/media/util.js new file mode 100644 index 0000000..c61ae0e --- /dev/null +++ b/content/browser/resources/media/util.js @@ -0,0 +1,74 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +cr.define('media', function() { + 'use strict'; + + /** + * The width and height of a bar drawn on a file canvas in pixels. + */ + var BAR_WIDTH = 500; + var BAR_HEIGHT = 16; + + /** + * Draws a 1px white horizontal line across |context|. + */ + function drawLine(context, top) { + context.moveTo(0, top); + context.lineTo(BAR_WIDTH, top); + context.strokeStyle = '#fff'; + context.stroke(); + } + + /** + * Creates an HTMLElement of type |type| with textContent |content|. + * @param {string} type The type of element to create. + * @param {string} content The content to place in the element. + * @return {HTMLElement} A newly initialized element. + */ + function makeElement(type, content) { + var element = document.createElement(type); + element.textContent = content; + return element; + } + + /** + * Creates a new <li> containing a <details> with a <summary> and sets + * properties to reference them. + * @return {Object} The new <li>. + */ + function createDetailsLi() { + var li = document.createElement('li'); + li.details = document.createElement('details'); + li.summary = document.createElement('summary'); + li.appendChild(li.details); + li.details.appendChild(li.summary); + return li + } + + /** + * Appends each key-value pair in a dictionary to a row in a table. + * @param {Object} dict The dictionary to append. + * @param {HTMLElement} table The <table> element to append to. + */ + function appendDictionaryToTable(dict, table) { + table.textContent = ''; + for (var key in dict) { + var tr = document.createElement('tr'); + tr.appendChild(makeElement('td', key + ':')); + tr.appendChild(makeElement('td', dict[key])); + table.appendChild(tr); + } + return table; + } + + return { + BAR_WIDTH: BAR_WIDTH, + BAR_HEIGHT: BAR_HEIGHT, + drawLine: drawLine, + makeElement: makeElement, + createDetailsLi: createDetailsLi, + appendDictionaryToTable: appendDictionaryToTable + }; +}); |