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

Side by Side Diff: chrome/test/data/extensions/api_test/notification/galore/app/controller.js

Issue 12212037: Update notifications API after review. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge conflict resolved Created 7 years, 10 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 var Galore = Galore || {}; 5 var Galore = Galore || {};
6 6
7 Galore.controller = { 7 Galore.controller = {
8 8
9 BUTTON_IMAGE_SIZE: 64, 9 BUTTON_IMAGE_SIZE: 64,
10 NOTIFICATION_ICON_SIZE: 80, 10 NOTIFICATION_ICON_SIZE: 80,
(...skipping 15 matching lines...) Expand all
26 listen_: function(event) { 26 listen_: function(event) {
27 var listener = this.event_.bind(this, event); 27 var listener = this.event_.bind(this, event);
28 chrome.experimental.notification[event].addListener(listener); 28 chrome.experimental.notification[event].addListener(listener);
29 }, 29 },
30 30
31 /** @private */ 31 /** @private */
32 prepare_: function() { 32 prepare_: function() {
33 Galore.NOTIFICATIONS.forEach(function (type) { 33 Galore.NOTIFICATIONS.forEach(function (type) {
34 type.notifications.forEach(function (options) { 34 type.notifications.forEach(function (options) {
35 this.view.addNotificationButton( 35 this.view.addNotificationButton(
36 type.type, 36 type.templateType,
37 type.name, 37 type.name,
38 this.replace_(options.iconUrl, this.BUTTON_IMAGE_SIZE), 38 this.replace_(options.iconUrl, this.BUTTON_IMAGE_SIZE),
39 this.notify_.bind(this, type.type, options)); 39 this.notify_.bind(this, type.templateType, options));
40 }, this); 40 }, this);
41 }, this); 41 }, this);
42 }, 42 },
43 43
44 /** @private */ 44 /** @private */
45 id_: function() { 45 id_: function() {
46 this.counter += 1; 46 this.counter += 1;
47 return String(this.counter); 47 return String(this.counter);
48 }, 48 },
49 49
(...skipping 10 matching lines...) Expand all
60 delete expanded.buttonOneTitle; 60 delete expanded.buttonOneTitle;
61 delete expanded.buttonTwoIconUrl; 61 delete expanded.buttonTwoIconUrl;
62 delete expanded.buttonTwoTitle; 62 delete expanded.buttonTwoTitle;
63 chrome.experimental.notification.show(expanded, function() {}); 63 chrome.experimental.notification.show(expanded, function() {});
64 } 64 }
65 this.event_('create', id, 'priority: ' + priority); 65 this.event_('create', id, 'priority: ' + priority);
66 }, 66 },
67 67
68 /** @private */ 68 /** @private */
69 expand_: function(options, type, priority) { 69 expand_: function(options, type, priority) {
70 var expanded = {type: type, priority: priority}; 70 var expanded = {templateType: type, priority: priority};
71 Object.keys(options).forEach(function (key) { 71 Object.keys(options).forEach(function (key) {
72 expanded[key] = this.replace_(options[key], this.NOTIFICATION_ICON_SIZE); 72 expanded[key] = this.replace_(options[key], this.NOTIFICATION_ICON_SIZE);
73 }, this); 73 }, this);
74 return expanded; 74 return expanded;
75 }, 75 },
76 76
77 /** @private */ 77 /** @private */
78 replace_: function(option, size) { 78 replace_: function(option, size) {
79 var replaced = option; 79 var replaced;
80 if (typeof replaced === 'string') { 80 if (typeof option === 'string') {
81 replaced = replaced.replace(/\$#/g, this.counter); 81 replaced = option.replace(/\$#/g, this.counter);
82 replaced = replaced.replace(/\$@/g, this.prefix); 82 replaced = replaced.replace(/\$@/g, this.prefix);
83 replaced = replaced.replace(/\$%/g, size); 83 replaced = replaced.replace(/\$%/g, size);
84 } else if (Array.isArray(option)) {
85 replaced = [];
86 option.forEach(function(element) {
87 replaced.push(this.replace_(element, size));
88 }, this);
89 } else {
90 replaced = {};
91 Object.keys(option).forEach(function (key) {
92 replaced[key] = this.replace_(option[key], size);
93 }, this);
84 } 94 }
85 return replaced; 95 return replaced;
86 }, 96 },
87 97
88 /** @private */ 98 /** @private */
89 event_: function(event, id, var_args) { 99 event_: function(event, id, var_args) {
90 this.view.logEvent('Notification #' + id + ': ' + event + '(' + 100 this.view.logEvent('Notification #' + id + ': ' + event + '(' +
91 Array.prototype.slice.call(arguments, 2).join(', ') + 101 Array.prototype.slice.call(arguments, 2).join(', ') +
92 ')'); 102 ')');
93 } 103 }
94 104
95 }; 105 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698