OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 cr.define('ntp', function() { | 5 cr.define('ntp', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 var APP_LAUNCH = { | 8 var APP_LAUNCH = { |
9 // The histogram buckets (keep in sync with extension_constants.h). | 9 // The histogram buckets (keep in sync with extension_constants.h). |
10 NTP_APPS_MAXIMIZED: 0, | 10 NTP_APPS_MAXIMIZED: 0, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 cr.ui.decorate(menu, cr.ui.Menu); | 43 cr.ui.decorate(menu, cr.ui.Menu); |
44 menu.classList.add('app-context-menu'); | 44 menu.classList.add('app-context-menu'); |
45 this.menu = menu; | 45 this.menu = menu; |
46 | 46 |
47 this.launch_ = this.appendMenuItem_(); | 47 this.launch_ = this.appendMenuItem_(); |
48 this.launch_.addEventListener('activate', this.onLaunch_.bind(this)); | 48 this.launch_.addEventListener('activate', this.onLaunch_.bind(this)); |
49 | 49 |
50 menu.appendChild(cr.ui.MenuItem.createSeparator()); | 50 menu.appendChild(cr.ui.MenuItem.createSeparator()); |
51 this.launchRegularTab_ = this.appendMenuItem_('applaunchtyperegular'); | 51 this.launchRegularTab_ = this.appendMenuItem_('applaunchtyperegular'); |
52 this.launchPinnedTab_ = this.appendMenuItem_('applaunchtypepinned'); | 52 this.launchPinnedTab_ = this.appendMenuItem_('applaunchtypepinned'); |
53 if (loadTimeData.getBoolean('enableNewBookmarkApps') || !cr.isMac) | 53 if (loadTimeData.getBoolean('hostedAppsInWindowsEnabled')) |
54 this.launchNewWindow_ = this.appendMenuItem_('applaunchtypewindow'); | 54 this.launchNewWindow_ = this.appendMenuItem_('applaunchtypewindow'); |
55 this.launchFullscreen_ = this.appendMenuItem_('applaunchtypefullscreen'); | 55 this.launchFullscreen_ = this.appendMenuItem_('applaunchtypefullscreen'); |
56 | 56 |
57 var self = this; | 57 var self = this; |
58 this.forAllLaunchTypes_(function(launchTypeButton, id) { | 58 this.forAllLaunchTypes_(function(launchTypeButton, id) { |
59 launchTypeButton.addEventListener('activate', | 59 launchTypeButton.addEventListener('activate', |
60 self.onLaunchTypeChanged_.bind(self)); | 60 self.onLaunchTypeChanged_.bind(self)); |
61 }); | 61 }); |
62 | 62 |
63 this.launchTypeMenuSeparator_ = cr.ui.MenuItem.createSeparator(); | 63 this.launchTypeMenuSeparator_ = cr.ui.MenuItem.createSeparator(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 /** | 129 /** |
130 * Does all the necessary setup to show the menu for the given app. | 130 * Does all the necessary setup to show the menu for the given app. |
131 * @param {App} app The App object that will be showing a context menu. | 131 * @param {App} app The App object that will be showing a context menu. |
132 */ | 132 */ |
133 setupForApp: function(app) { | 133 setupForApp: function(app) { |
134 this.app_ = app; | 134 this.app_ = app; |
135 | 135 |
136 this.launch_.textContent = app.appData.title; | 136 this.launch_.textContent = app.appData.title; |
137 | 137 |
138 var launchTypeWindow = this.launchNewWindow_; | 138 var launchTypeWindow = this.launchNewWindow_; |
139 var hasLaunchType = false; | |
139 this.forAllLaunchTypes_(function(launchTypeButton, id) { | 140 this.forAllLaunchTypes_(function(launchTypeButton, id) { |
140 launchTypeButton.disabled = false; | 141 launchTypeButton.disabled = false; |
141 launchTypeButton.checked = app.appData.launch_type == id; | 142 launchTypeButton.checked = app.appData.launch_type == id; |
142 // If bookmark apps are enabled, only show the "Open as window" button. | 143 // There are three cases when a launch type is hidden: |
144 // 1. packaged apps hide all launch types | |
145 // 2. hostedAppsInWindowsEnabled is false and type is launchTypeWindow | |
146 // 3. enableNewBookmarkApps is true and type is anything except | |
147 // launchTypeWindow | |
143 launchTypeButton.hidden = app.appData.packagedApp || | 148 launchTypeButton.hidden = app.appData.packagedApp || |
149 (!loadTimeData.getBoolean('hostedAppsInWindowsEnabled') && | |
150 launchTypeButton == launchTypeWindow) || | |
144 (loadTimeData.getBoolean('enableNewBookmarkApps') && | 151 (loadTimeData.getBoolean('enableNewBookmarkApps') && |
145 launchTypeButton != launchTypeWindow); | 152 launchTypeButton != launchTypeWindow); |
153 hasLaunchType = hasLaunchType || !launchTypeButton.hidden; | |
Dan Beam
2015/08/20 18:25:57
if (!launchTypeButton.hidden) hasLaunchType = true
dominickn
2015/08/20 22:07:44
Done.
| |
146 }); | 154 }); |
147 | 155 |
148 this.launchTypeMenuSeparator_.hidden = app.appData.packagedApp; | 156 this.launchTypeMenuSeparator_.hidden = |
157 app.appData.packagedApp || !hasLaunchType; | |
149 | 158 |
150 this.options_.disabled = !app.appData.optionsUrl || !app.appData.enabled; | 159 this.options_.disabled = !app.appData.optionsUrl || !app.appData.enabled; |
151 if (this.details_) | 160 if (this.details_) |
152 this.details_.disabled = !app.appData.detailsUrl; | 161 this.details_.disabled = !app.appData.detailsUrl; |
153 this.uninstall_.disabled = !app.appData.mayDisable; | 162 this.uninstall_.disabled = !app.appData.mayDisable; |
154 | 163 |
155 if (cr.isMac) { | 164 if (cr.isMac) { |
156 // On Windows and Linux, these should always be visible. On ChromeOS, | 165 // On Windows and Linux, these should always be visible. On ChromeOS, |
157 // they are never created. On Mac, shortcuts can only be created for | 166 // they are never created. On Mac, shortcuts can only be created for |
158 // new-style packaged apps, so hide the menu item. | 167 // new-style packaged apps, so hide the menu item. |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
778 function launchAppAfterEnable(appId) { | 787 function launchAppAfterEnable(appId) { |
779 chrome.send('launchApp', [appId, APP_LAUNCH.NTP_APP_RE_ENABLE]); | 788 chrome.send('launchApp', [appId, APP_LAUNCH.NTP_APP_RE_ENABLE]); |
780 } | 789 } |
781 | 790 |
782 return { | 791 return { |
783 APP_LAUNCH: APP_LAUNCH, | 792 APP_LAUNCH: APP_LAUNCH, |
784 AppsPage: AppsPage, | 793 AppsPage: AppsPage, |
785 launchAppAfterEnable: launchAppAfterEnable, | 794 launchAppAfterEnable: launchAppAfterEnable, |
786 }; | 795 }; |
787 }); | 796 }); |
OLD | NEW |