Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: chrome/browser/resources/bookmark_manager/js/main.js

Issue 10544021: Disable the new window context menu option in the bookmarks extension for Windows 8 metro mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 /** @const */ var BookmarkList = bmm.BookmarkList; 5 /** @const */ var BookmarkList = bmm.BookmarkList;
6 /** @const */ var BookmarkTree = bmm.BookmarkTree; 6 /** @const */ var BookmarkTree = bmm.BookmarkTree;
7 /** @const */ var Command = cr.ui.Command; 7 /** @const */ var Command = cr.ui.Command;
8 /** @const */ var CommandBinding = cr.ui.CommandBinding; 8 /** @const */ var CommandBinding = cr.ui.CommandBinding;
9 /** @const */ var LinkKind = cr.LinkKind; 9 /** @const */ var LinkKind = cr.LinkKind;
10 /** @const */ var ListItem = cr.ui.ListItem; 10 /** @const */ var ListItem = cr.ui.ListItem;
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 * - 'forced' for when incognito mode is forced (normal mode is unavailable). 845 * - 'forced' for when incognito mode is forced (normal mode is unavailable).
846 */ 846 */
847 var incognitoModeAvailability = 'enabled'; 847 var incognitoModeAvailability = 'enabled';
848 chrome.systemPrivate.getIncognitoModeAvailability(function(result) { 848 chrome.systemPrivate.getIncognitoModeAvailability(function(result) {
849 // TODO(rustema): propagate policy value to the bookmark manager when 849 // TODO(rustema): propagate policy value to the bookmark manager when
850 // it changes. 850 // it changes.
851 incognitoModeAvailability = result; 851 incognitoModeAvailability = result;
852 }); 852 });
853 853
854 /** 854 /**
855 * New Windows are not allowed in Windows 8 metro mode.
856 */
857 var canOpenNewWindows = true;
858 chrome.experimental.bookmarkManager.canOpenNewWindows(function(result) {
859 canOpenNewWindows = result;
860 });
861
862 /**
855 * Helper function that updates the canExecute and labels for the open-like 863 * Helper function that updates the canExecute and labels for the open-like
856 * commands. 864 * commands.
857 * @param {!cr.ui.CanExecuteEvent} e The event fired by the command system. 865 * @param {!cr.ui.CanExecuteEvent} e The event fired by the command system.
858 * @param {!cr.ui.Command} command The command we are currently processing. 866 * @param {!cr.ui.Command} command The command we are currently processing.
859 */ 867 */
860 function updateOpenCommands(e, command) { 868 function updateOpenCommands(e, command) {
861 var selectedItem = e.target.selectedItem; 869 var selectedItem = e.target.selectedItem;
862 var selectionCount; 870 var selectionCount;
863 if (e.target == tree) { 871 if (e.target == tree) {
864 selectionCount = selectedItem ? 1 : 0; 872 selectionCount = selectedItem ? 1 : 0;
(...skipping 19 matching lines...) Expand all
884 switch (command.id) { 892 switch (command.id) {
885 case 'open-in-new-tab-command': 893 case 'open-in-new-tab-command':
886 command.label = loadTimeData.getString(multiple ? 894 command.label = loadTimeData.getString(multiple ?
887 'open_all' : 'open_in_new_tab'); 895 'open_all' : 'open_in_new_tab');
888 break; 896 break;
889 897
890 case 'open-in-new-window-command': 898 case 'open-in-new-window-command':
891 command.label = loadTimeData.getString(multiple ? 899 command.label = loadTimeData.getString(multiple ?
892 'open_all_new_window' : 'open_in_new_window'); 900 'open_all_new_window' : 'open_in_new_window');
893 // Disabled when incognito is forced. 901 // Disabled when incognito is forced.
894 commandDisabled = incognitoModeAvailability == 'forced'; 902 commandDisabled = incognitoModeAvailability == 'forced' ||
903 !canOpenNewWindows;
895 break; 904 break;
896 case 'open-incognito-window-command': 905 case 'open-incognito-window-command':
897 command.label = loadTimeData.getString(multiple ? 906 command.label = loadTimeData.getString(multiple ?
898 'open_all_incognito' : 'open_incognito'); 907 'open_all_incognito' : 'open_incognito');
899 // Not available withn incognito is disabled. 908 // Not available withn incognito is disabled.
900 commandDisabled = incognitoModeAvailability == 'disabled'; 909 commandDisabled = incognitoModeAvailability == 'disabled';
901 break; 910 break;
902 } 911 }
903 e.canExecute = selectionCount > 0 && !!selectedItem && !commandDisabled; 912 e.canExecute = selectionCount > 0 && !!selectedItem && !commandDisabled;
904 if (isFolder && e.canExecute) { 913 if (isFolder && e.canExecute) {
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 document.addEventListener('copy', handle('copy-command')); 1646 document.addEventListener('copy', handle('copy-command'));
1638 document.addEventListener('cut', handle('cut-command')); 1647 document.addEventListener('cut', handle('cut-command'));
1639 1648
1640 var pasteHandler = handle('paste-command'); 1649 var pasteHandler = handle('paste-command');
1641 document.addEventListener('paste', function(e) { 1650 document.addEventListener('paste', function(e) {
1642 // Paste is a bit special since we need to do an async call to see if we can 1651 // Paste is a bit special since we need to do an async call to see if we can
1643 // paste because the paste command might not be up to date. 1652 // paste because the paste command might not be up to date.
1644 updatePasteCommand(pasteHandler); 1653 updatePasteCommand(pasteHandler);
1645 }); 1654 });
1646 })(); 1655 })();
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_tabs_module.cc ('k') | chrome/common/extensions/api/experimental_bookmark_manager.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698