1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
// Namespace object for the utilities.
var ActionChoiceUtil = {};
/**
* Gets list of defined actions.
* @param {Object} loadTimeData Load time data for i18n.
* @param {function(Array.<Object>)} callback Callback with list of defined
* actions.
*/
ActionChoiceUtil.getDefinedActions = function(loadTimeData, callback) {
// Fill out predefined actions first.
var result = [{
id: 'view-files',
title: loadTimeData.getString('ACTION_CHOICE_VIEW_FILES'),
class: 'view-files-icon'
}, {
id: 'import-photos-to-drive',
title: loadTimeData.getString('ACTION_CHOICE_PHOTOS_DRIVE'),
class: 'import-photos-to-drive-icon',
disabled: true,
disabledTitle: loadTimeData.getString('ACTION_CHOICE_DRIVE_NOT_REACHED')
}, {
id: 'watch-single-video',
class: 'watch-single-video-icon',
hidden: true,
disabled: true
}];
chrome.mediaGalleriesPrivate.getHandlers(function(handlers) {
for (var i = 0; i < handlers.length; i++) {
var action = {
id: handlers[i].extensionId + ':' + handlers[i].id,
title: handlers[i].title,
// TODO(mtomasz): Get the passed icon instead of the extension icon.
icon100:
'chrome://extension-icon/' + handlers[i].extensionId + '/32/1',
icon200:
'chrome://extension-icon/' + handlers[i].extensionId + '/64/1',
extensionId: handlers[i].extensionId,
actionId: handlers[i].id
};
result.push(action);
}
callback(result);
}.bind(this));
};
/**
* Gets the remembered action's identifier.
* @param {function(string=)} callback Callback with the identifier.
*/
ActionChoiceUtil.getRememberedActionId = function(callback) {
util.storage.local.get(['action-choice'], function(result) {
callback(result['action-choice']);
});
};
/**
* Sets the remembered action's identifier.
* @param {string=} opt_actionId Action's identifier. If undefined, then forgets
* the remembered choice.
*/
ActionChoiceUtil.setRememberedActionId = function(opt_actionId) {
util.storage.local.set({'action-choice': opt_actionId});
};
|