summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjamiewalch <jamiewalch@chromium.org>2015-06-17 16:25:34 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-17 23:27:03 +0000
commit6275de5043c03bb01065b38e3fc4b5c245562f15 (patch)
treeb6578e74843e585934b3608ab479b5b02cd1f946
parent10fabd01b91cbc82f1e25ef1e332ec9246d68860 (diff)
downloadchromium_src-6275de5043c03bb01065b38e3fc4b5c245562f15.zip
chromium_src-6275de5043c03bb01065b38e3fc4b5c245562f15.tar.gz
chromium_src-6275de5043c03bb01065b38e3fc4b5c245562f15.tar.bz2
Add support for custom license templates.
This allows products that are built from the Chromium source to include third-party license attribution, even if they cannot link directly to chrome://credits. Chrome apps such as Chromoting, for example, fall into this category, for example. BUG=499478 Review URL: https://codereview.chromium.org/1178323002 Cr-Commit-Position: refs/heads/master@{#334957}
-rw-r--r--remoting/app_remoting_webapp_build.gypi1
-rw-r--r--remoting/app_remoting_webapp_files.gypi1
-rw-r--r--remoting/remoting_client.gypi28
-rw-r--r--remoting/remoting_webapp.gypi1
-rw-r--r--remoting/remoting_webapp_files.gypi10
-rw-r--r--remoting/webapp/BUILD.gn25
-rw-r--r--remoting/webapp/app_remoting/js/application_context_menu.js17
-rw-r--r--remoting/webapp/base/html/credits.css67
-rw-r--r--remoting/webapp/base/html/credits.tmpl16
-rw-r--r--remoting/webapp/base/html/credits_entry.tmpl9
-rw-r--r--remoting/webapp/base/html/main.css2
-rw-r--r--remoting/webapp/base/js/credits.js19
-rw-r--r--remoting/webapp/build_template.gni2
-rw-r--r--remoting/webapp/crd/html/toolbar.html1
-rw-r--r--remoting/webapp/crd/html/ui_header.html1
-rw-r--r--remoting/webapp/crd/html/window_frame.html2
-rw-r--r--remoting/webapp/crd/js/feedback.js32
-rw-r--r--remoting/webapp/files.gni11
-rwxr-xr-xtools/licenses.py49
19 files changed, 265 insertions, 29 deletions
diff --git a/remoting/app_remoting_webapp_build.gypi b/remoting/app_remoting_webapp_build.gypi
index bc6ffa6..9117e4f 100644
--- a/remoting/app_remoting_webapp_build.gypi
+++ b/remoting/app_remoting_webapp_build.gypi
@@ -46,6 +46,7 @@
'<(SHARED_INTERMEDIATE_DIR)/>(_target_name)/message_window.html',
'<(SHARED_INTERMEDIATE_DIR)/>(_target_name)/wcs_sandbox.html',
'<(SHARED_INTERMEDIATE_DIR)/>(_target_name)/feedback_consent.html',
+ '<(SHARED_INTERMEDIATE_DIR)/remoting/credits.html',
],
'ar_webapp_files': [
'<@(ar_app_specific_files)',
diff --git a/remoting/app_remoting_webapp_files.gypi b/remoting/app_remoting_webapp_files.gypi
index fc5686d..4d976d4 100644
--- a/remoting/app_remoting_webapp_files.gypi
+++ b/remoting/app_remoting_webapp_files.gypi
@@ -94,6 +94,7 @@
'<@(remoting_webapp_wcs_sandbox_html_js_files)',
# Referenced from the manifest.
'<@(ar_background_js_files)',
+ 'webapp/base/js/credits.js',
],
# Files that contain localizable strings.
diff --git a/remoting/remoting_client.gypi b/remoting/remoting_client.gypi
index bef823d..d3d23fc 100644
--- a/remoting/remoting_client.gypi
+++ b/remoting/remoting_client.gypi
@@ -125,10 +125,38 @@
}, # end of target 'remoting_webapp_html'
{
+ # GN version: //remoting/webapp:credits
+ 'target_name': 'remoting_credits',
+ 'type': 'none',
+ 'actions': [
+ {
+ 'action_name': 'Build remoting credits',
+ 'inputs': [
+ '../tools/licenses.py',
+ 'webapp/base/html/credits.tmpl',
+ 'webapp/base/html/credits_entry.tmpl',
+ ],
+ 'outputs': [
+ '<(SHARED_INTERMEDIATE_DIR)/remoting/credits.html',
+ ],
+ 'hard_dependency': 1,
+ 'action': ['python',
+ '../tools/licenses.py',
+ 'credits',
+ '<(SHARED_INTERMEDIATE_DIR)/remoting/credits.html',
+ '--file-template', 'webapp/base/html/credits.tmpl',
+ '--entry-template', 'webapp/base/html/credits_entry.tmpl',
+
+ ],
+ },
+ ],
+ },
+ {
# GN version: //remoting/webapp:webapp
'target_name': 'remoting_webapp',
'type': 'none',
'dependencies': [
+ 'remoting_credits',
'remoting_webapp_v1',
],
'conditions': [
diff --git a/remoting/remoting_webapp.gypi b/remoting/remoting_webapp.gypi
index 9d5a72a..ca56648 100644
--- a/remoting/remoting_webapp.gypi
+++ b/remoting/remoting_webapp.gypi
@@ -11,6 +11,7 @@
'main_html_file%': '<(SHARED_INTERMEDIATE_DIR)/remoting/main.html',
'generated_html_files': [
'<(SHARED_INTERMEDIATE_DIR)/remoting/background.html',
+ '<(SHARED_INTERMEDIATE_DIR)/remoting/credits.html',
'<(SHARED_INTERMEDIATE_DIR)/remoting/message_window.html',
'<(SHARED_INTERMEDIATE_DIR)/remoting/wcs_sandbox.html',
],
diff --git a/remoting/remoting_webapp_files.gypi b/remoting/remoting_webapp_files.gypi
index 3657d33..abae977 100644
--- a/remoting/remoting_webapp_files.gypi
+++ b/remoting/remoting_webapp_files.gypi
@@ -444,6 +444,14 @@
],
#
+ # All the JavaScript files required by credits.html
+ #
+
+ 'remoting_webapp_credits_html_all_js_files': [
+ 'webapp/base/js/credits.js',
+ ],
+
+ #
# Complete webapp JS and resource files.
#
@@ -461,6 +469,7 @@
'remoting_webapp_crd_js_files': [
'<@(remoting_webapp_shared_js_files)',
'<@(remoting_webapp_crd_main_html_all_js_files)',
+ '<@(remoting_webapp_credits_html_all_js_files)',
],
'remoting_webapp_info_files': [
@@ -492,6 +501,7 @@
'resources/reload.webp',
'resources/tick.webp',
'webapp/base/html/connection_stats.css',
+ 'webapp/base/html/credits.css',
'webapp/base/html/main.css',
'webapp/base/html/message_window.css',
'webapp/base/resources/open_sans.css',
diff --git a/remoting/webapp/BUILD.gn b/remoting/webapp/BUILD.gn
index e3e7966..43b26a3 100644
--- a/remoting/webapp/BUILD.gn
+++ b/remoting/webapp/BUILD.gn
@@ -11,6 +11,7 @@ group("webapp") {
deps = [
":webapp_v1",
":ar_sample_app",
+ ":credits",
]
if (enable_nacl) {
@@ -45,3 +46,27 @@ app_remoting_webapp("ar_sample_app") {
app_capabilities = [ "GOOGLE_DRIVE" ]
manifest_key = "remotingdevbuild"
}
+
+# GYP version: remoting/remoting_client:remoting_credits
+action("credits") {
+ about_credits_file = "$target_gen_dir/credits.html"
+ script = "//tools/licenses.py"
+
+ inputs = [
+ "base/html/credits.tmpl",
+ "base/html/credits_entry.tmpl",
+ ]
+
+ outputs = [
+ about_credits_file,
+ ]
+
+ args = [
+ "credits",
+ rebase_path(about_credits_file, root_build_dir),
+ "--file-template",
+ rebase_path("base/html/credits.tmpl", root_build_dir),
+ "--entry-template",
+ rebase_path("base/html/credits_entry.tmpl", root_build_dir),
+ ]
+}
diff --git a/remoting/webapp/app_remoting/js/application_context_menu.js b/remoting/webapp/app_remoting/js/application_context_menu.js
index 8d15824..26051a0 100644
--- a/remoting/webapp/app_remoting/js/application_context_menu.js
+++ b/remoting/webapp/app_remoting/js/application_context_menu.js
@@ -37,6 +37,10 @@ remoting.ApplicationContextMenu = function(adapter, plugin, clientSession,
remoting.ApplicationContextMenu.kShowStatsId,
l10n.getTranslationOrError(/*i18n-content*/'SHOW_STATS'),
true);
+ this.adapter_.create(
+ remoting.ApplicationContextMenu.kShowCreditsId,
+ l10n.getTranslationOrError(/*i18n-content*/'CREDITS'),
+ true);
// TODO(kelvinp):Unhook this event on shutdown.
this.adapter_.addListener(this.onClicked_.bind(this));
@@ -118,6 +122,16 @@ remoting.ApplicationContextMenu.prototype.onClicked_ = function(info) {
case remoting.ApplicationContextMenu.kShowStatsId:
this.stats_.show(info.checked);
break;
+
+ case remoting.ApplicationContextMenu.kShowCreditsId:
+ chrome.app.window.create(
+ 'credits.html',
+ {
+ 'width': 800,
+ 'height': 600,
+ 'id' : 'remoting-credits'
+ });
+ break;
}
};
@@ -127,3 +141,6 @@ remoting.ApplicationContextMenu.kSendFeedbackId = 'send-feedback';
/** @type {string} */
remoting.ApplicationContextMenu.kShowStatsId = 'show-stats';
+
+/** @type {string} */
+remoting.ApplicationContextMenu.kShowCreditsId = 'show-credits';
diff --git a/remoting/webapp/base/html/credits.css b/remoting/webapp/base/html/credits.css
new file mode 100644
index 0000000..c61b09d
--- /dev/null
+++ b/remoting/webapp/base/html/credits.css
@@ -0,0 +1,67 @@
+/* Copyright (c) 2012 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.
+ */
+
+body {
+ overflow: auto;
+}
+
+.page-title {
+ font-size: 164%;
+ font-weight: bold;
+}
+
+.entries {
+ margin: 8px;
+}
+
+.product {
+ background-color: #c3d9ff;
+ border-radius: 5px;
+ margin-top: 16px;
+ overflow: auto;
+ padding: 2px;
+}
+
+.product .title {
+ float: left;
+ font-size: 110%;
+ font-weight: bold;
+ margin: 3px;
+}
+
+.product .homepage {
+ float: right;
+ margin: 3px;
+ text-align: right;
+}
+
+.product .homepage::after {
+ content: " - ";
+}
+
+.product .toggle-licence {
+ float: right;
+ margin: 3px;
+ text-align: right;
+}
+
+.licence {
+ background-color: #e8eef7;
+ border-radius: 3px;
+ clear: both;
+ padding: 16px;
+}
+
+.toggle-licence.hide-licence ~ .licence {
+ display: none;
+};
+
+.licence h3 {
+ margin-top: 0;
+}
+
+.licence pre {
+ white-space: pre-wrap;
+}
diff --git a/remoting/webapp/base/html/credits.tmpl b/remoting/webapp/base/html/credits.tmpl
new file mode 100644
index 0000000..836ebc6
--- /dev/null
+++ b/remoting/webapp/base/html/credits.tmpl
@@ -0,0 +1,16 @@
+<!doctype html>
+<html class="full-height">
+ <head>
+ <meta charset="utf-8">
+ <title>Credits</title>
+ <link rel="stylesheet" href="main.css">
+ <link rel="stylesheet" href="credits.css">
+ <script src="credits.js"></script>
+ </head>
+ <body class="full-height">
+ <div class="entries">
+ <div class="page-title">Credits</div>
+ {{entries}}
+ </div>
+ </body>
+</html>
diff --git a/remoting/webapp/base/html/credits_entry.tmpl b/remoting/webapp/base/html/credits_entry.tmpl
new file mode 100644
index 0000000..f30eb19
--- /dev/null
+++ b/remoting/webapp/base/html/credits_entry.tmpl
@@ -0,0 +1,9 @@
+<div class="product">
+<span class="title">{{name}}</span>
+<a class="toggle-licence hide-licence" href="#">show license</a>
+<span class="homepage"><a href="{{url}}" target="_blank">homepage</a></span>
+<div class="licence">
+<pre>{{license}}</pre>
+</div>
+</div>
+
diff --git a/remoting/webapp/base/html/main.css b/remoting/webapp/base/html/main.css
index c089e1f..172e0a4 100644
--- a/remoting/webapp/base/html/main.css
+++ b/remoting/webapp/base/html/main.css
@@ -4,7 +4,7 @@
*/
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p,
-blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em,
+blockquote, a, abbr, acronym, address, big, cite, code, del, dfn, em,
font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl,
dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody,
tfoot, thead, tr, th, td, button {
diff --git a/remoting/webapp/base/js/credits.js b/remoting/webapp/base/js/credits.js
new file mode 100644
index 0000000..cab5653
--- /dev/null
+++ b/remoting/webapp/base/js/credits.js
@@ -0,0 +1,19 @@
+// Copyright 2015 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.
+
+(function() {
+
+'use strict';
+
+/** @param {Event} event */
+function onClick(event) {
+ var element = /** @type {HTMLElement} */ (event.target);
+ if (element.classList.contains('toggle-licence')) {
+ element.classList.toggle('hide-licence');
+ }
+}
+
+document.addEventListener('click', onClick, false);
+
+})();
diff --git a/remoting/webapp/build_template.gni b/remoting/webapp/build_template.gni
index 0eff3e6..8c97084 100644
--- a/remoting/webapp/build_template.gni
+++ b/remoting/webapp/build_template.gni
@@ -186,6 +186,7 @@ template("desktop_remoting_webapp") {
message_window_html_output,
wcs_sandbox_html_output,
main_html_output,
+ "$target_gen_dir/credits.html",
]
# Create a file that contains a list of all the resource files needed
@@ -324,6 +325,7 @@ template("app_remoting_webapp") {
message_window_html_output,
wcs_sandbox_html_output,
main_html_output,
+ "$target_gen_dir/credits.html",
]
ar_webapp_files =
diff --git a/remoting/webapp/crd/html/toolbar.html b/remoting/webapp/crd/html/toolbar.html
index ed2a1fa..0a94896 100644
--- a/remoting/webapp/crd/html/toolbar.html
+++ b/remoting/webapp/crd/html/toolbar.html
@@ -64,6 +64,7 @@ found in the LICENSE file.
<ul class="right-align">
<li class="menu-help" i18n-content="HELP"></li>
<li class="menu-feedback" i18n-content="ACTIONBAR_FEEDBACK"></li>
+ <li class="menu-credits" i18n-content="CREDITS"></li>
</ul>
</span>
diff --git a/remoting/webapp/crd/html/ui_header.html b/remoting/webapp/crd/html/ui_header.html
index 86eb68f..45595ab 100644
--- a/remoting/webapp/crd/html/ui_header.html
+++ b/remoting/webapp/crd/html/ui_header.html
@@ -22,6 +22,7 @@ found in the LICENSE file.
<ul class="right-align">
<li class="menu-help" i18n-content="HELP"></li>
<li class="menu-feedback" i18n-content="ACTIONBAR_FEEDBACK"></li>
+ <li class="menu-credits" i18n-content="CREDITS"></li>
</ul>
</span>
</div>
diff --git a/remoting/webapp/crd/html/window_frame.html b/remoting/webapp/crd/html/window_frame.html
index 4cddc95..1729abb 100644
--- a/remoting/webapp/crd/html/window_frame.html
+++ b/remoting/webapp/crd/html/window_frame.html
@@ -35,6 +35,8 @@ found in the LICENSE file.
i18n-content="HELP"></li>
<li class="menu-feedback"
i18n-content="ACTIONBAR_FEEDBACK"></li>
+ <li class="menu-credits"
+ i18n-content="CREDITS"></li>
</ul>
</span>
<span i18n-title="DISCONNECT_MYSELF_BUTTON"
diff --git a/remoting/webapp/crd/js/feedback.js b/remoting/webapp/crd/js/feedback.js
index fe71cde..52a2c7a 100644
--- a/remoting/webapp/crd/js/feedback.js
+++ b/remoting/webapp/crd/js/feedback.js
@@ -6,6 +6,8 @@
var remoting = remoting || {};
+(function(){
+
/**
* Attach appropriate event handlers and show or hide the feedback button based
* on whether or not the current version of Chrome recognizes Chrome Remote
@@ -15,30 +17,44 @@ var remoting = remoting || {};
* items.
*/
remoting.manageHelpAndFeedback = function(container) {
- var showHelp = function() {
- window.open('https://support.google.com/chrome/answer/1649523');
- };
var helpButton = container.querySelector('.menu-help');
base.debug.assert(helpButton != null);
helpButton.addEventListener('click', showHelp, false);
+
+ var creditsButton = container.querySelector('.menu-credits');
+ base.debug.assert(creditsButton != null);
+ creditsButton.addEventListener('click', showCredits, false);
+
var feedbackButton = container.querySelector('.menu-feedback');
base.debug.assert(feedbackButton != null);
var chromeVersion = parseInt(
window.navigator.appVersion.match(/Chrome\/(\d+)\./)[1], 10);
if (chromeVersion >= 35) {
- feedbackButton.addEventListener('click',
- remoting.sendFeedback_,
- false);
+ feedbackButton.addEventListener('click', sendFeedback, false);
} else {
feedbackButton.hidden = true;
}
};
+function showHelp() {
+ window.open('https://support.google.com/chrome/answer/1649523');
+};
+
+function showCredits() {
+ chrome.app.window.create(
+ 'credits.html',
+ {
+ 'width': 800,
+ 'height': 600,
+ 'id' : 'remoting-credits'
+ });
+};
+
/**
* Pass the current version of Chrome Remote Desktop to the Google Feedback
* extension and instruct it to show the feedback dialog.
*/
-remoting.sendFeedback_ = function() {
+function sendFeedback() {
var message = {
requestFeedback: true,
feedbackInfo: {
@@ -51,3 +67,5 @@ remoting.sendFeedback_ = function() {
var kFeedbackExtensionId = 'gfdkimpbcpahaombhbimeihdjnejgicl';
chrome.runtime.sendMessage(kFeedbackExtensionId, message, function() {});
};
+
+})();
diff --git a/remoting/webapp/files.gni b/remoting/webapp/files.gni
index 7e77289..39bc081 100644
--- a/remoting/webapp/files.gni
+++ b/remoting/webapp/files.gni
@@ -434,12 +434,19 @@ remoting_webapp_message_window_html_all_js_files =
remoting_webapp_message_window_html_js_files + [ "base/js/base.js" ]
#
+# All the JavaScript files required by credits.html
+#
+
+remoting_webapp_credits_html_all_js_files = [ "base/js/credits.js" ]
+
+#
# DesktopRemoting webapp JS and resource files.
#
# All the JavaScript files that are shared by webapps.
remoting_webapp_shared_js_files = remoting_webapp_shared_main_html_js_files +
remoting_webapp_background_html_js_files +
+ remoting_webapp_credits_html_all_js_files +
remoting_webapp_message_window_html_js_files +
remoting_webapp_wcs_sandbox_html_js_files +
# JS files referenced in manifest.json.
@@ -478,6 +485,7 @@ remoting_webapp_resource_files = [
"../resources/reload.webp",
"../resources/tick.webp",
"base/html/connection_stats.css",
+ "base/html/credits.css",
"base/html/main.css",
"base/html/message_window.css",
"base/resources/open_sans.css",
@@ -608,7 +616,8 @@ ar_background_js_files = [
ar_all_js_files =
ar_main_js_files + ar_feedback_consent_html_js_files +
remoting_webapp_message_window_html_js_files +
- remoting_webapp_wcs_sandbox_html_js_files + ar_background_js_files
+ remoting_webapp_wcs_sandbox_html_js_files + ar_background_js_files +
+ remoting_webapp_credits_html_all_js_files
# Files that contain localizable strings.
app_remoting_webapp_localizable_files =
diff --git a/tools/licenses.py b/tools/licenses.py
index 6b8311a..1bbb3d0 100755
--- a/tools/licenses.py
+++ b/tools/licenses.py
@@ -15,6 +15,7 @@ Commands:
(You can also import this as a module.)
"""
+import argparse
import cgi
import os
import sys
@@ -422,13 +423,9 @@ def ScanThirdPartyDirs(root=None):
return len(errors) == 0
-def GenerateCredits():
+def GenerateCredits(file_template_file, entry_template_file, output_file):
"""Generate about:credits."""
- if len(sys.argv) not in (2, 3):
- print 'usage: licenses.py credits [output_file]'
- return False
-
def EvaluateTemplate(template, env, escape=True):
"""Expand a template with variables like {{foo}} using a
dictionary of expansions."""
@@ -441,8 +438,15 @@ def GenerateCredits():
root = os.path.join(os.path.dirname(__file__), '..')
third_party_dirs = FindThirdPartyDirs(PRUNE_PATHS, root)
- entry_template = open(os.path.join(root, 'chrome', 'browser', 'resources',
- 'about_credits_entry.tmpl'), 'rb').read()
+ if not file_template_file:
+ file_template_file = os.path.join(root, 'chrome', 'browser',
+ 'resources', 'about_credits.tmpl')
+ if not entry_template_file:
+ entry_template_file = os.path.join(root, 'chrome', 'browser',
+ 'resources',
+ 'about_credits_entry.tmpl')
+
+ entry_template = open(entry_template_file).read()
entries = []
for path in third_party_dirs:
try:
@@ -465,32 +469,37 @@ def GenerateCredits():
entries.sort(key=lambda entry: (entry['name'], entry['content']))
entries_contents = '\n'.join([entry['content'] for entry in entries])
- file_template = open(os.path.join(root, 'chrome', 'browser', 'resources',
- 'about_credits.tmpl'), 'rb').read()
+ file_template = open(file_template_file).read()
template_contents = "<!-- Generated by licenses.py; do not edit. -->"
template_contents += EvaluateTemplate(file_template,
{'entries': entries_contents},
escape=False)
- if len(sys.argv) == 3:
- with open(sys.argv[2], 'w') as output_file:
- output_file.write(template_contents)
- elif len(sys.argv) == 2:
+ if output_file:
+ with open(output_file, 'w') as output:
+ output.write(template_contents)
+ else:
print template_contents
return True
def main():
- command = 'help'
- if len(sys.argv) > 1:
- command = sys.argv[1]
-
- if command == 'scan':
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--file-template',
+ help='Template HTML to use for the license page.')
+ parser.add_argument('--entry-template',
+ help='Template HTML to use for each license.')
+ parser.add_argument('command', choices=['help', 'scan', 'credits'])
+ parser.add_argument('output_file', nargs='?')
+ args = parser.parse_args()
+
+ if args.command == 'scan':
if not ScanThirdPartyDirs():
return 1
- elif command == 'credits':
- if not GenerateCredits():
+ elif args.command == 'credits':
+ if not GenerateCredits(args.file_template, args.entry_template,
+ args.output_file):
return 1
else:
print __doc__