summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/ntp/apps.js
diff options
context:
space:
mode:
authorandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-30 02:03:49 +0000
committerandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-30 02:03:49 +0000
commit10abd198e989f003f5f2fcaad735bf3566a5f8ba (patch)
treec123193e87d254fc8a63526bcce584ea39569f87 /chrome/browser/resources/ntp/apps.js
parentff7321db2060aa69b63b2090b0e5eb92d2df704e (diff)
downloadchromium_src-10abd198e989f003f5f2fcaad735bf3566a5f8ba.zip
chromium_src-10abd198e989f003f5f2fcaad735bf3566a5f8ba.tar.gz
chromium_src-10abd198e989f003f5f2fcaad735bf3566a5f8ba.tar.bz2
o Add user customizable launch type for apps by adding options in each apps context menu.
o Updated some comments that were using the outdated NOTIFY_PREF_CHANGED notification. o Make LAUNCH_PINNED the default type returned by ExtensionPrefs if it does not already exist. o Some minor refactoring within the code to reduce duplication. BUG=54731 TEST=NONE patch from issue 3419010 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=60997 Reverted: http://crrev.com/61000 Review URL: http://codereview.chromium.org/3453029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61021 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources/ntp/apps.js')
-rw-r--r--chrome/browser/resources/ntp/apps.js51
1 files changed, 50 insertions, 1 deletions
diff --git a/chrome/browser/resources/ntp/apps.js b/chrome/browser/resources/ntp/apps.js
index d9098d5..b128f05 100644
--- a/chrome/browser/resources/ntp/apps.js
+++ b/chrome/browser/resources/ntp/apps.js
@@ -36,6 +36,15 @@ function getAppsCallback(data) {
}
}
+function appsPrefChangeCallback(data) {
+ // Currently the only pref that is watched is the launch type.
+ data.apps.forEach(function(app) {
+ var appLink = document.querySelector('.app a[app-id=' + app['id'] + ']');
+ if (appLink)
+ appLink.setAttribute('launch-type', app['launch_type']);
+ });
+}
+
var apps = (function() {
function createElement(app) {
@@ -44,6 +53,7 @@ var apps = (function() {
var a = div.appendChild(document.createElement('a'));
a.setAttribute('app-id', app['id']);
+ a.setAttribute('launch-type', app['launch_type']);
a.xtitle = a.textContent = app['name'];
a.href = app['launch_url'];
@@ -99,6 +109,20 @@ var apps = (function() {
return false;
}
+ // Keep in sync with LaunchType in extension_prefs.h
+ var LaunchType = {
+ LAUNCH_PINNED: 0,
+ LAUNCH_REGULAR: 1,
+ LAUNCH_FULLSCREEN: 2
+ };
+
+ // Keep in sync with LaunchContainer in extension.h
+ var LaunchContainer = {
+ LAUNCH_WINDOW: 0,
+ LAUNCH_PANEL: 1,
+ LAUNCH_TAB: 2
+ };
+
var currentApp;
function addContextMenu(el, app) {
@@ -113,6 +137,24 @@ var apps = (function() {
$('apps-launch-command').label = app['name'];
$('apps-options-command').canExecuteChange();
+ var appLinkSel = '.app a[app-id=' + app['id'] + ']';
+ var launchType =
+ el.querySelector(appLinkSel).getAttribute('launch-type');
+
+ var launchContainer = app['launch_container'];
+ var isPanel = launchContainer == LaunchContainer.LAUNCH_PANEL;
+
+ // Update the commands related to the launch type.
+ var launchTypeIds = ['apps-launch-type-pinned',
+ 'apps-launch-type-regular',
+ 'apps-launch-type-fullscreen'];
+ launchTypeIds.forEach(function(id) {
+ var command = $(id);
+ command.disabled = isPanel;
+ command.checked = !isPanel &&
+ launchType == command.getAttribute('launch-type');
+ });
+
return $('app-context-menu');
}
});
@@ -122,7 +164,8 @@ var apps = (function() {
if (!currentApp)
return;
- switch (e.command.id) {
+ var commandId = e.command.id;
+ switch (commandId) {
case 'apps-options-command':
window.location = currentApp['options_url'];
break;
@@ -132,6 +175,12 @@ var apps = (function() {
case 'apps-uninstall-command':
chrome.send('uninstallApp', [currentApp['id']]);
break;
+ case 'apps-launch-type-pinned':
+ case 'apps-launch-type-regular':
+ case 'apps-launch-type-fullscreen':
+ chrome.send('setLaunchType',
+ [currentApp['id'], e.command.getAttribute('launch-type')]);
+ break;
}
});