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 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 } catch (ignore) { | 847 } catch (ignore) { |
848 // TODO: fill the status object once the API is available. | 848 // TODO: fill the status object once the API is available. |
849 callback({}); | 849 callback({}); |
850 } | 850 } |
851 }, | 851 }, |
852 | 852 |
853 /** | 853 /** |
854 * Close current window. | 854 * Close current window. |
855 */ | 855 */ |
856 closeWindow: function() { | 856 closeWindow: function() { |
857 if (this.v2()) { | 857 if (util.platform.v2()) { |
858 window.close(); | 858 window.close(); |
859 } else { | 859 } else { |
860 chrome.tabs.getCurrent(function(tab) { | 860 chrome.tabs.getCurrent(function(tab) { |
861 chrome.tabs.remove(tab.id); | 861 chrome.tabs.remove(tab.id); |
862 }); | 862 }); |
863 } | 863 } |
864 }, | 864 }, |
865 | 865 |
866 /** | 866 /** |
867 * @return {string} Applicaton id. | 867 * @return {string} Applicaton id. |
868 */ | 868 */ |
869 getAppId: function() { | 869 getAppId: function() { |
870 if (this.v2()) { | 870 if (util.platform.v2()) { |
871 return chrome.runtime.id; | 871 return chrome.runtime.id; |
872 } else { | 872 } else { |
873 return chrome.extension.getURL('').split('/')[2]; | 873 return chrome.extension.getURL('').split('/')[2]; |
874 } | 874 } |
875 }, | 875 }, |
876 | 876 |
877 /** | 877 /** |
878 * @param {string} path Path relative to the extension root. | 878 * @param {string} path Path relative to the extension root. |
879 * @return {string} Extension-based URL. | 879 * @return {string} Extension-based URL. |
880 */ | 880 */ |
881 getURL: function(path) { | 881 getURL: function(path) { |
882 if (this.v2()) { | 882 if (util.platform.v2()) { |
883 return chrome.runtime.getURL(path); | 883 return chrome.runtime.getURL(path); |
884 } else { | 884 } else { |
885 return chrome.extension.getURL(path); | 885 return chrome.extension.getURL(path); |
886 } | 886 } |
887 }, | 887 }, |
888 | 888 |
889 /** | 889 /** |
890 * Suppress default context menu in a current window. | 890 * Suppress default context menu in a current window. |
891 */ | 891 */ |
892 suppressContextMenu: function() { | 892 suppressContextMenu: function() { |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 * overriden). | 1251 * overriden). |
1252 * @param {Object} object The object. | 1252 * @param {Object} object The object. |
1253 * @param {string} propertyName The property name. | 1253 * @param {string} propertyName The property name. |
1254 * @param {*} value Value to set. | 1254 * @param {*} value Value to set. |
1255 */ | 1255 */ |
1256 util.callInheritedSetter = function(object, propertyName, value) { | 1256 util.callInheritedSetter = function(object, propertyName, value) { |
1257 var d = util.findPropertyDescriptor(Object.getPrototypeOf(object), | 1257 var d = util.findPropertyDescriptor(Object.getPrototypeOf(object), |
1258 propertyName); | 1258 propertyName); |
1259 d.set.call(object, value); | 1259 d.set.call(object, value); |
1260 }; | 1260 }; |
OLD | NEW |