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
3 // found in the LICENSE file.
7 // Namespace object for the utilities.
8 var ActionChoiceUtil = {};
11 * Gets list of defined actions.
12 * @param {Object} loadTimeData Load time data for i18n.
13 * @param {function(Array.<Object>)} callback Callback with list of defined
16 ActionChoiceUtil.getDefinedActions = function(loadTimeData, callback) {
17 // Fill out predefined actions first.
20 title: loadTimeData.getString('ACTION_CHOICE_VIEW_FILES'),
21 class: 'view-files-icon'
23 id: 'import-photos-to-drive',
24 title: loadTimeData.getString('ACTION_CHOICE_PHOTOS_DRIVE'),
25 class: 'import-photos-to-drive-icon',
27 disabledTitle: loadTimeData.getString('ACTION_CHOICE_DRIVE_NOT_REACHED')
29 id: 'watch-single-video',
30 class: 'watch-single-video-icon',
34 chrome.mediaGalleriesPrivate.getHandlers(function(handlers) {
35 for (var i = 0; i < handlers.length; i++) {
37 id: handlers[i].extensionId + ':' + handlers[i].id,
38 title: handlers[i].title,
39 // TODO(mtomasz): Get the passed icon instead of the extension icon.
41 'chrome://extension-icon/' + handlers[i].extensionId + '/32/1',
43 'chrome://extension-icon/' + handlers[i].extensionId + '/64/1',
44 extensionId: handlers[i].extensionId,
45 actionId: handlers[i].id
54 * Gets the remembered action's identifier.
55 * @param {function(string=)} callback Callback with the identifier.
57 ActionChoiceUtil.getRememberedActionId = function(callback) {
58 chrome.storage.local.get(['action-choice'], function(result) {
59 callback(result['action-choice']);
64 * Sets the remembered action's identifier.
65 * @param {string=} opt_actionId Action's identifier. If undefined, then forgets
66 * the remembered choice.
68 ActionChoiceUtil.setRememberedActionId = function(opt_actionId) {
69 chrome.storage.local.set({'action-choice': opt_actionId});