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 /** | 5 /** |
6 * Namespace for utility functions. | 6 * Namespace for utility functions. |
7 */ | 7 */ |
8 var util = {}; | 8 var util = {}; |
9 | 9 |
10 /** | 10 /** |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 var search; | 749 var search; |
750 if (typeof opt_param == 'string') | 750 if (typeof opt_param == 'string') |
751 search = opt_param; | 751 search = opt_param; |
752 else if (typeof opt_param == 'object') | 752 else if (typeof opt_param == 'object') |
753 search = '?' + JSON.stringify(opt_param); | 753 search = '?' + JSON.stringify(opt_param); |
754 else | 754 else |
755 search = location.search; | 755 search = location.search; |
756 | 756 |
757 var hash; | 757 var hash; |
758 if (path) | 758 if (path) |
759 hash = '#' + encodeURI(path); | 759 hash = '#' + encodeURIComponent(path); |
760 else | 760 else |
761 hash = location.hash; | 761 hash = location.hash; |
762 | 762 |
763 var newLocation = location.origin + location.pathname + search + hash; | 763 var newLocation = location.origin + location.pathname + search + hash; |
764 //TODO(kaznacheev): Fix replaceState for component extensions. Currently it | 764 //TODO(kaznacheev): Fix replaceState for component extensions. Currently it |
765 //does not replace the content of the address bar. | 765 //does not replace the content of the address bar. |
766 if (replace) | 766 if (replace) |
767 window.history.replaceState(undefined, path, newLocation); | 767 window.history.replaceState(undefined, path, newLocation); |
768 else | 768 else |
769 window.history.pushState(undefined, path, newLocation); | 769 window.history.pushState(undefined, path, newLocation); |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 util.disableBrowserShortcutKeys = function(element) { | 1255 util.disableBrowserShortcutKeys = function(element) { |
1256 element.addEventListener('keydown', function(e) { | 1256 element.addEventListener('keydown', function(e) { |
1257 switch (util.getKeyModifiers(e) + e.keyCode) { | 1257 switch (util.getKeyModifiers(e) + e.keyCode) { |
1258 case 'Ctrl-79': // Disable native Ctrl-O (open file). | 1258 case 'Ctrl-79': // Disable native Ctrl-O (open file). |
1259 case 'Ctrl-83': // Disable native Ctrl-S (save as). | 1259 case 'Ctrl-83': // Disable native Ctrl-S (save as). |
1260 case 'Ctrl-85': // Disable native Ctrl-U (view source). | 1260 case 'Ctrl-85': // Disable native Ctrl-U (view source). |
1261 e.preventDefault(); | 1261 e.preventDefault(); |
1262 } | 1262 } |
1263 }); | 1263 }); |
1264 }; | 1264 }; |
OLD | NEW |