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

Side by Side Diff: chrome/browser/resources/ntp4/apps_page.js

Issue 2617663002: WIP: run clang-format-js on lots of things (Closed)
Patch Set: merge Created 3 years, 11 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
OLDNEW
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 cr.define('ntp', function() { 5 cr.define('ntp', function() {
6 'use strict'; 6 'use strict';
7 7
8 var APP_LAUNCH = { 8 var APP_LAUNCH = {
9 // The histogram buckets (keep in sync with extension_constants.h). 9 // The histogram buckets (keep in sync with extension_constants.h).
10 NTP_APPS_MAXIMIZED: 0, 10 NTP_APPS_MAXIMIZED: 0,
11 NTP_APPS_COLLAPSED: 1, 11 NTP_APPS_COLLAPSED: 1,
12 NTP_APPS_MENU: 2, 12 NTP_APPS_MENU: 2,
13 NTP_MOST_VISITED: 3, 13 NTP_MOST_VISITED: 3,
14 NTP_APP_RE_ENABLE: 16, 14 NTP_APP_RE_ENABLE: 16,
15 NTP_WEBSTORE_FOOTER: 18, 15 NTP_WEBSTORE_FOOTER: 18,
16 NTP_WEBSTORE_PLUS_ICON: 19, 16 NTP_WEBSTORE_PLUS_ICON: 19,
17 }; 17 };
18 18
19 // Histogram buckets for UMA tracking of where a DnD drop came from. 19 // Histogram buckets for UMA tracking of where a DnD drop came from.
20 var DRAG_SOURCE = { 20 var DRAG_SOURCE = {
21 SAME_APPS_PANE: 0, 21 SAME_APPS_PANE: 0,
22 OTHER_APPS_PANE: 1, 22 OTHER_APPS_PANE: 1,
23 MOST_VISITED_PANE: 2, // Deprecated. 23 MOST_VISITED_PANE: 2, // Deprecated.
24 BOOKMARKS_PANE: 3, // Deprecated. 24 BOOKMARKS_PANE: 3, // Deprecated.
25 OUTSIDE_NTP: 4 25 OUTSIDE_NTP: 4
26 }; 26 };
27 var DRAG_SOURCE_LIMIT = DRAG_SOURCE.OUTSIDE_NTP + 1; 27 var DRAG_SOURCE_LIMIT = DRAG_SOURCE.OUTSIDE_NTP + 1;
28 28
29 /** 29 /**
30 * App context menu. The class is designed to be used as a singleton with 30 * App context menu. The class is designed to be used as a singleton with
31 * the app that is currently showing a context menu stored in this.app_. 31 * the app that is currently showing a context menu stored in this.app_.
32 * @constructor 32 * @constructor
33 */ 33 */
34 function AppContextMenu() { 34 function AppContextMenu() {
(...skipping 14 matching lines...) Expand all
49 49
50 menu.appendChild(cr.ui.MenuItem.createSeparator()); 50 menu.appendChild(cr.ui.MenuItem.createSeparator());
51 this.launchRegularTab_ = this.appendMenuItem_('applaunchtyperegular'); 51 this.launchRegularTab_ = this.appendMenuItem_('applaunchtyperegular');
52 this.launchPinnedTab_ = this.appendMenuItem_('applaunchtypepinned'); 52 this.launchPinnedTab_ = this.appendMenuItem_('applaunchtypepinned');
53 if (loadTimeData.getBoolean('canHostedAppsOpenInWindows')) 53 if (loadTimeData.getBoolean('canHostedAppsOpenInWindows'))
54 this.launchNewWindow_ = this.appendMenuItem_('applaunchtypewindow'); 54 this.launchNewWindow_ = this.appendMenuItem_('applaunchtypewindow');
55 this.launchFullscreen_ = this.appendMenuItem_('applaunchtypefullscreen'); 55 this.launchFullscreen_ = this.appendMenuItem_('applaunchtypefullscreen');
56 56
57 var self = this; 57 var self = this;
58 this.forAllLaunchTypes_(function(launchTypeButton, id) { 58 this.forAllLaunchTypes_(function(launchTypeButton, id) {
59 launchTypeButton.addEventListener('activate', 59 launchTypeButton.addEventListener(
60 self.onLaunchTypeChanged_.bind(self)); 60 'activate', self.onLaunchTypeChanged_.bind(self));
61 }); 61 });
62 62
63 this.launchTypeMenuSeparator_ = cr.ui.MenuItem.createSeparator(); 63 this.launchTypeMenuSeparator_ = cr.ui.MenuItem.createSeparator();
64 menu.appendChild(this.launchTypeMenuSeparator_); 64 menu.appendChild(this.launchTypeMenuSeparator_);
65 this.options_ = this.appendMenuItem_('appoptions'); 65 this.options_ = this.appendMenuItem_('appoptions');
66 this.uninstall_ = this.appendMenuItem_('appuninstall'); 66 this.uninstall_ = this.appendMenuItem_('appuninstall');
67 67
68 if (loadTimeData.getBoolean('canShowAppInfoDialog')) { 68 if (loadTimeData.getBoolean('canShowAppInfoDialog')) {
69 this.appinfo_ = this.appendMenuItem_('appinfodialog'); 69 this.appinfo_ = this.appendMenuItem_('appinfodialog');
70 this.appinfo_.addEventListener('activate', 70 this.appinfo_.addEventListener(
71 this.onShowAppInfo_.bind(this)); 71 'activate', this.onShowAppInfo_.bind(this));
72 } else { 72 } else {
73 this.details_ = this.appendMenuItem_('appdetails'); 73 this.details_ = this.appendMenuItem_('appdetails');
74 this.details_.addEventListener('activate', 74 this.details_.addEventListener(
75 this.onShowDetails_.bind(this)); 75 'activate', this.onShowDetails_.bind(this));
76 } 76 }
77 77
78 this.options_.addEventListener('activate', 78 this.options_.addEventListener(
79 this.onShowOptions_.bind(this)); 79 'activate', this.onShowOptions_.bind(this));
80 this.uninstall_.addEventListener('activate', 80 this.uninstall_.addEventListener(
81 this.onUninstall_.bind(this)); 81 'activate', this.onUninstall_.bind(this));
82 82
83 if (!cr.isChromeOS) { 83 if (!cr.isChromeOS) {
84 this.createShortcutSeparator_ = 84 this.createShortcutSeparator_ =
85 menu.appendChild(cr.ui.MenuItem.createSeparator()); 85 menu.appendChild(cr.ui.MenuItem.createSeparator());
86 this.createShortcut_ = this.appendMenuItem_('appcreateshortcut'); 86 this.createShortcut_ = this.appendMenuItem_('appcreateshortcut');
87 this.createShortcut_.addEventListener( 87 this.createShortcut_.addEventListener(
88 'activate', this.onCreateShortcut_.bind(this)); 88 'activate', this.onCreateShortcut_.bind(this));
89 } 89 }
90 90
91 document.body.appendChild(menu); 91 document.body.appendChild(menu);
(...skipping 14 matching lines...) Expand all
106 }, 106 },
107 107
108 /** 108 /**
109 * Iterates over all the launch type menu items. 109 * Iterates over all the launch type menu items.
110 * @param {function(cr.ui.MenuItem, number)} f The function to call for each 110 * @param {function(cr.ui.MenuItem, number)} f The function to call for each
111 * menu item. The parameters to the function include the menu item and 111 * menu item. The parameters to the function include the menu item and
112 * the associated launch ID. 112 * the associated launch ID.
113 */ 113 */
114 forAllLaunchTypes_: function(f) { 114 forAllLaunchTypes_: function(f) {
115 // Order matters: index matches launchType id. 115 // Order matters: index matches launchType id.
116 var launchTypes = [this.launchPinnedTab_, 116 var launchTypes = [
117 this.launchRegularTab_, 117 this.launchPinnedTab_, this.launchRegularTab_, this.launchFullscreen_,
118 this.launchFullscreen_, 118 this.launchNewWindow_
119 this.launchNewWindow_]; 119 ];
120 120
121 for (var i = 0; i < launchTypes.length; ++i) { 121 for (var i = 0; i < launchTypes.length; ++i) {
122 if (!launchTypes[i]) 122 if (!launchTypes[i])
123 continue; 123 continue;
124 124
125 f(launchTypes[i], i); 125 f(launchTypes[i], i);
126 } 126 }
127 }, 127 },
128 128
129 /** 129 /**
(...skipping 13 matching lines...) Expand all
143 // There are three cases when a launch type is hidden: 143 // There are three cases when a launch type is hidden:
144 // 1. packaged apps hide all launch types 144 // 1. packaged apps hide all launch types
145 // 2. canHostedAppsOpenInWindows is false and type is launchTypeWindow 145 // 2. canHostedAppsOpenInWindows is false and type is launchTypeWindow
146 // 3. enableNewBookmarkApps is true and type is anything except 146 // 3. enableNewBookmarkApps is true and type is anything except
147 // launchTypeWindow 147 // launchTypeWindow
148 launchTypeButton.hidden = app.appData.packagedApp || 148 launchTypeButton.hidden = app.appData.packagedApp ||
149 (!loadTimeData.getBoolean('canHostedAppsOpenInWindows') && 149 (!loadTimeData.getBoolean('canHostedAppsOpenInWindows') &&
150 launchTypeButton == launchTypeWindow) || 150 launchTypeButton == launchTypeWindow) ||
151 (loadTimeData.getBoolean('enableNewBookmarkApps') && 151 (loadTimeData.getBoolean('enableNewBookmarkApps') &&
152 launchTypeButton != launchTypeWindow); 152 launchTypeButton != launchTypeWindow);
153 if (!launchTypeButton.hidden) hasLaunchType = true; 153 if (!launchTypeButton.hidden)
154 hasLaunchType = true;
154 }); 155 });
155 156
156 this.launchTypeMenuSeparator_.hidden = 157 this.launchTypeMenuSeparator_.hidden =
157 app.appData.packagedApp || !hasLaunchType; 158 app.appData.packagedApp || !hasLaunchType;
158 159
159 this.options_.disabled = !app.appData.optionsUrl || !app.appData.enabled; 160 this.options_.disabled = !app.appData.optionsUrl || !app.appData.enabled;
160 if (this.details_) 161 if (this.details_)
161 this.details_.disabled = !app.appData.detailsUrl; 162 this.details_.disabled = !app.appData.detailsUrl;
162 this.uninstall_.disabled = !app.appData.mayDisable; 163 this.uninstall_.disabled = !app.appData.mayDisable;
163 164
(...skipping 15 matching lines...) Expand all
179 chrome.send('launchApp', [this.app_.appId, APP_LAUNCH.NTP_APPS_MENU]); 180 chrome.send('launchApp', [this.app_.appId, APP_LAUNCH.NTP_APPS_MENU]);
180 }, 181 },
181 onLaunchTypeChanged_: function(e) { 182 onLaunchTypeChanged_: function(e) {
182 var pressed = e.currentTarget; 183 var pressed = e.currentTarget;
183 var app = this.app_; 184 var app = this.app_;
184 var targetLaunchType = pressed; 185 var targetLaunchType = pressed;
185 // When bookmark apps are enabled, hosted apps can only toggle between 186 // When bookmark apps are enabled, hosted apps can only toggle between
186 // open as window and open as tab. 187 // open as window and open as tab.
187 if (loadTimeData.getBoolean('enableNewBookmarkApps')) { 188 if (loadTimeData.getBoolean('enableNewBookmarkApps')) {
188 targetLaunchType = this.launchNewWindow_.checked ? 189 targetLaunchType = this.launchNewWindow_.checked ?
189 this.launchRegularTab_ : this.launchNewWindow_; 190 this.launchRegularTab_ :
191 this.launchNewWindow_;
190 } 192 }
191 this.forAllLaunchTypes_(function(launchTypeButton, id) { 193 this.forAllLaunchTypes_(function(launchTypeButton, id) {
192 if (launchTypeButton == targetLaunchType) { 194 if (launchTypeButton == targetLaunchType) {
193 chrome.send('setLaunchType', [app.appId, id]); 195 chrome.send('setLaunchType', [app.appId, id]);
194 // Manually update the launch type. We will only get 196 // Manually update the launch type. We will only get
195 // appsPrefChangeCallback calls after changes to other NTP instances. 197 // appsPrefChangeCallback calls after changes to other NTP instances.
196 app.appData.launch_type = id; 198 app.appData.launch_type = id;
197 } 199 }
198 }); 200 });
199 }, 201 },
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 assert(this.appData_.id, 'Got an app without an ID'); 244 assert(this.appData_.id, 'Got an app without an ID');
243 this.id = this.appData_.id; 245 this.id = this.appData_.id;
244 this.setAttribute('role', 'menuitem'); 246 this.setAttribute('role', 'menuitem');
245 247
246 this.className = 'app focusable'; 248 this.className = 'app focusable';
247 249
248 this.appContents_ = $('app-icon-template').cloneNode(true); 250 this.appContents_ = $('app-icon-template').cloneNode(true);
249 this.appContents_.id = ''; 251 this.appContents_.id = '';
250 this.appendChild(this.appContents_); 252 this.appendChild(this.appContents_);
251 253
252 this.appImgContainer_ = /** @type {HTMLElement} */( 254 this.appImgContainer_ =
253 this.querySelector('.app-img-container')); 255 /** @type {HTMLElement} */ (this.querySelector('.app-img-container'));
254 this.appImg_ = this.appImgContainer_.querySelector('img'); 256 this.appImg_ = this.appImgContainer_.querySelector('img');
255 this.setIcon(); 257 this.setIcon();
256 258
257 this.addLaunchClickTarget_(this.appImgContainer_); 259 this.addLaunchClickTarget_(this.appImgContainer_);
258 this.appImgContainer_.title = this.appData_.full_name; 260 this.appImgContainer_.title = this.appData_.full_name;
259 261
260 // The app's full name is shown in the tooltip, whereas the short name 262 // The app's full name is shown in the tooltip, whereas the short name
261 // is used for the label. 263 // is used for the label.
262 var appSpan = /** @type {HTMLElement} */( 264 var appSpan = /** @type {HTMLElement} */ (
263 this.appContents_.querySelector('.title')); 265 this.appContents_.querySelector('.title'));
264 appSpan.textContent = this.appData_.title; 266 appSpan.textContent = this.appData_.title;
265 appSpan.title = this.appData_.full_name; 267 appSpan.title = this.appData_.full_name;
266 this.addLaunchClickTarget_(appSpan); 268 this.addLaunchClickTarget_(appSpan);
267 269
268 this.addEventListener('keydown', cr.ui.contextMenuHandler); 270 this.addEventListener('keydown', cr.ui.contextMenuHandler);
269 this.addEventListener('keyup', cr.ui.contextMenuHandler); 271 this.addEventListener('keyup', cr.ui.contextMenuHandler);
270 272
271 // This hack is here so that appContents.contextMenu will be the same as 273 // This hack is here so that appContents.contextMenu will be the same as
272 // this.contextMenu. 274 // this.contextMenu.
273 var self = this; 275 var self = this;
274 this.appContents_.__defineGetter__('contextMenu', function() { 276 this.appContents_.__defineGetter__('contextMenu', function() {
275 return self.contextMenu; 277 return self.contextMenu;
276 }); 278 });
277 279
278 if (!this.appData_.kioskMode) { 280 if (!this.appData_.kioskMode) {
279 this.appContents_.addEventListener('contextmenu', 281 this.appContents_.addEventListener(
280 cr.ui.contextMenuHandler); 282 'contextmenu', cr.ui.contextMenuHandler);
281 } 283 }
282 284
283 this.addEventListener('mousedown', this.onMousedown_, true); 285 this.addEventListener('mousedown', this.onMousedown_, true);
284 this.addEventListener('keydown', this.onKeydown_); 286 this.addEventListener('keydown', this.onKeydown_);
285 this.addEventListener('blur', this.onBlur_); 287 this.addEventListener('blur', this.onBlur_);
286 }, 288 },
287 289
288 /** 290 /**
289 * Removes the app tile from the page. Should be called after the app has 291 * Removes the app tile from the page. Should be called after the app has
290 * been uninstalled. 292 * been uninstalled.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 this.classList.remove('click-focus'); 354 this.classList.remove('click-focus');
353 this.appContents_.classList.remove('suppress-active'); 355 this.appContents_.classList.remove('suppress-active');
354 }, 356 },
355 357
356 /** 358 /**
357 * Invoked when an app is clicked. 359 * Invoked when an app is clicked.
358 * @param {Event} e The click/auxclick event. 360 * @param {Event} e The click/auxclick event.
359 * @private 361 * @private
360 */ 362 */
361 onClick_: function(e) { 363 onClick_: function(e) {
362 if (/** @type {MouseEvent} */(e).button > 1) 364 if (/** @type {MouseEvent} */ (e).button > 1)
363 return; 365 return;
364 366
365 chrome.send('launchApp', 367 chrome.send('launchApp', [
366 [this.appId, APP_LAUNCH.NTP_APPS_MAXIMIZED, 'chrome-ntp-icon', 368 this.appId, APP_LAUNCH.NTP_APPS_MAXIMIZED, 'chrome-ntp-icon', e.button,
367 e.button, e.altKey, e.ctrlKey, e.metaKey, e.shiftKey]); 369 e.altKey, e.ctrlKey, e.metaKey, e.shiftKey
370 ]);
368 371
369 // Don't allow the click to trigger a link or anything 372 // Don't allow the click to trigger a link or anything
370 e.preventDefault(); 373 e.preventDefault();
371 }, 374 },
372 375
373 /** 376 /**
374 * Invoked when the user presses a key while the app is focused. 377 * Invoked when the user presses a key while the app is focused.
375 * @param {Event} e The key event. 378 * @param {Event} e The key event.
376 * @private 379 * @private
377 */ 380 */
378 onKeydown_: function(e) { 381 onKeydown_: function(e) {
379 if (e.key == 'Enter') { 382 if (e.key == 'Enter') {
380 chrome.send('launchApp', 383 chrome.send('launchApp', [
381 [this.appId, APP_LAUNCH.NTP_APPS_MAXIMIZED, '', 384 this.appId, APP_LAUNCH.NTP_APPS_MAXIMIZED, '', 0, e.altKey, e.ctrlKey,
382 0, e.altKey, e.ctrlKey, e.metaKey, e.shiftKey]); 385 e.metaKey, e.shiftKey
386 ]);
383 e.preventDefault(); 387 e.preventDefault();
384 e.stopPropagation(); 388 e.stopPropagation();
385 } 389 }
386 }, 390 },
387 391
388 /** 392 /**
389 * Adds a node to the list of targets that will launch the app. This list 393 * Adds a node to the list of targets that will launch the app. This list
390 * is also used in onMousedown to determine whether the app contents should 394 * is also used in onMousedown to determine whether the app contents should
391 * be shown as active (if we don't do this, then clicking anywhere in 395 * be shown as active (if we don't do this, then clicking anywhere in
392 * appContents, even a part that is outside the ideally clickable region, 396 * appContents, even a part that is outside the ideally clickable region,
(...skipping 13 matching lines...) Expand all
406 * clickable regions. 410 * clickable regions.
407 * @param {Event} e The mousedown event. 411 * @param {Event} e The mousedown event.
408 */ 412 */
409 onMousedown_: function(e) { 413 onMousedown_: function(e) {
410 // If the current platform uses middle click to autoscroll and this 414 // If the current platform uses middle click to autoscroll and this
411 // mousedown isn't handled, onClick_() will never fire. crbug.com/142939 415 // mousedown isn't handled, onClick_() will never fire. crbug.com/142939
412 if (e.button == 1) 416 if (e.button == 1)
413 e.preventDefault(); 417 e.preventDefault();
414 418
415 if (e.button == 2 || 419 if (e.button == 2 ||
416 !findAncestorByClass(/** @type {Element} */(e.target), 420 !findAncestorByClass(
417 'launch-click-target')) { 421 /** @type {Element} */ (e.target), 'launch-click-target')) {
418 this.appContents_.classList.add('suppress-active'); 422 this.appContents_.classList.add('suppress-active');
419 } else { 423 } else {
420 this.appContents_.classList.remove('suppress-active'); 424 this.appContents_.classList.remove('suppress-active');
421 } 425 }
422 426
423 // This class is here so we don't show the focus state for apps that 427 // This class is here so we don't show the focus state for apps that
424 // gain keyboard focus via mouse clicking. 428 // gain keyboard focus via mouse clicking.
425 this.classList.add('click-focus'); 429 this.classList.add('click-focus');
426 }, 430 },
427 431
428 /** 432 /**
429 * Change the appData and update the appearance of the app. 433 * Change the appData and update the appearance of the app.
430 * @param {AppInfo} appData The new data object that describes the app. 434 * @param {AppInfo} appData The new data object that describes the app.
431 */ 435 */
432 replaceAppData: function(appData) { 436 replaceAppData: function(appData) {
433 this.appData_ = appData; 437 this.appData_ = appData;
434 this.setIcon(); 438 this.setIcon();
435 this.loadIcon(); 439 this.loadIcon();
436 }, 440 },
437 441
438 /** 442 /**
439 * The data and preferences for this app. 443 * The data and preferences for this app.
440 * @type {Object} 444 * @type {Object}
441 */ 445 */
442 set appData(data) { this.appData_ = data; }, 446 set appData(data) {
443 get appData() { return this.appData_; }, 447 this.appData_ = data;
448 },
449 get appData() {
450 return this.appData_;
451 },
444 452
445 get appId() { return this.appData_.id; }, 453 get appId() {
454 return this.appData_.id;
455 },
446 456
447 /** 457 /**
448 * Returns a pointer to the context menu for this app. All apps share the 458 * Returns a pointer to the context menu for this app. All apps share the
449 * singleton AppContextMenu. This function is called by the 459 * singleton AppContextMenu. This function is called by the
450 * ContextMenuHandler in response to the 'contextmenu' event. 460 * ContextMenuHandler in response to the 'contextmenu' event.
451 * @type {cr.ui.Menu} 461 * @type {cr.ui.Menu}
452 */ 462 */
453 get contextMenu() { 463 get contextMenu() {
454 var menu = AppContextMenu.getInstance(); 464 var menu = AppContextMenu.getInstance();
455 menu.setupForApp(this); 465 menu.setupForApp(this);
456 return menu.menu; 466 return menu.menu;
457 }, 467 },
458 468
459 /** 469 /**
460 * Returns whether this element can be 'removed' from chrome (i.e. whether 470 * Returns whether this element can be 'removed' from chrome (i.e. whether
461 * the user can drag it onto the trash and expect something to happen). 471 * the user can drag it onto the trash and expect something to happen).
462 * @return {boolean} True if the app can be uninstalled. 472 * @return {boolean} True if the app can be uninstalled.
463 */ 473 */
464 canBeRemoved: function() { return this.appData_.mayDisable; }, 474 canBeRemoved: function() {
475 return this.appData_.mayDisable;
476 },
465 477
466 /** 478 /**
467 * Uninstalls the app after it's been dropped on the trash. 479 * Uninstalls the app after it's been dropped on the trash.
468 */ 480 */
469 removeFromChrome: function() { 481 removeFromChrome: function() {
470 chrome.send('uninstallApp', [this.appData_.id, true]); 482 chrome.send('uninstallApp', [this.appData_.id, true]);
471 this.tile.tilePage.removeTile(this.tile, true); 483 this.tile.tilePage.removeTile(this.tile, true);
472 }, 484 },
473 485
474 /** 486 /**
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 this.setDropEffect(e.dataTransfer); 617 this.setDropEffect(e.dataTransfer);
606 } 618 }
607 }, 619 },
608 620
609 /** @override */ 621 /** @override */
610 shouldAcceptDrag: function(e) { 622 shouldAcceptDrag: function(e) {
611 if (ntp.getCurrentlyDraggingTile()) 623 if (ntp.getCurrentlyDraggingTile())
612 return true; 624 return true;
613 if (!e.dataTransfer || !e.dataTransfer.types) 625 if (!e.dataTransfer || !e.dataTransfer.types)
614 return false; 626 return false;
615 return Array.prototype.indexOf.call(e.dataTransfer.types, 627 return Array.prototype.indexOf.call(
616 'text/uri-list') != -1; 628 e.dataTransfer.types, 'text/uri-list') != -1;
617 }, 629 },
618 630
619 /** @override */ 631 /** @override */
620 addDragData: function(dataTransfer, index) { 632 addDragData: function(dataTransfer, index) {
621 var sourceId = -1; 633 var sourceId = -1;
622 var currentlyDraggingTile = ntp.getCurrentlyDraggingTile(); 634 var currentlyDraggingTile = ntp.getCurrentlyDraggingTile();
623 if (currentlyDraggingTile) { 635 if (currentlyDraggingTile) {
624 var tileContents = currentlyDraggingTile.firstChild; 636 var tileContents = currentlyDraggingTile.firstChild;
625 if (tileContents.classList.contains('app')) { 637 if (tileContents.classList.contains('app')) {
626 var originalPage = currentlyDraggingTile.tilePage; 638 var originalPage = currentlyDraggingTile.tilePage;
627 var samePageDrag = originalPage == this; 639 var samePageDrag = originalPage == this;
628 sourceId = samePageDrag ? DRAG_SOURCE.SAME_APPS_PANE : 640 sourceId = samePageDrag ? DRAG_SOURCE.SAME_APPS_PANE :
629 DRAG_SOURCE.OTHER_APPS_PANE; 641 DRAG_SOURCE.OTHER_APPS_PANE;
630 this.tileGrid_.insertBefore(currentlyDraggingTile, 642 this.tileGrid_.insertBefore(
631 this.tileElements_[index]); 643 currentlyDraggingTile, this.tileElements_[index]);
632 this.tileMoved(currentlyDraggingTile); 644 this.tileMoved(currentlyDraggingTile);
633 if (!samePageDrag) { 645 if (!samePageDrag) {
634 originalPage.fireRemovedEvent(currentlyDraggingTile, index, true); 646 originalPage.fireRemovedEvent(currentlyDraggingTile, index, true);
635 this.fireAddedEvent(currentlyDraggingTile, index, true); 647 this.fireAddedEvent(currentlyDraggingTile, index, true);
636 } 648 }
637 } 649 }
638 } else { 650 } else {
639 this.addOutsideData_(dataTransfer); 651 this.addOutsideData_(dataTransfer);
640 sourceId = DRAG_SOURCE.OUTSIDE_NTP; 652 sourceId = DRAG_SOURCE.OUTSIDE_NTP;
641 } 653 }
642 654
643 assert(sourceId != -1); 655 assert(sourceId != -1);
644 chrome.send('metricsHandler:recordInHistogram', 656 chrome.send(
657 'metricsHandler:recordInHistogram',
645 ['NewTabPage.AppsPageDragSource', sourceId, DRAG_SOURCE_LIMIT]); 658 ['NewTabPage.AppsPageDragSource', sourceId, DRAG_SOURCE_LIMIT]);
646 }, 659 },
647 660
648 /** 661 /**
649 * Adds drag data that has been dropped from a source that is not a tile. 662 * Adds drag data that has been dropped from a source that is not a tile.
650 * @param {Object} dataTransfer The data transfer object that holds drop 663 * @param {Object} dataTransfer The data transfer object that holds drop
651 * data. 664 * data.
652 * @private 665 * @private
653 */ 666 */
654 addOutsideData_: function(dataTransfer) { 667 addOutsideData_: function(dataTransfer) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 chrome.send('launchApp', [appId, APP_LAUNCH.NTP_APP_RE_ENABLE]); 740 chrome.send('launchApp', [appId, APP_LAUNCH.NTP_APP_RE_ENABLE]);
728 } 741 }
729 742
730 return { 743 return {
731 APP_LAUNCH: APP_LAUNCH, 744 APP_LAUNCH: APP_LAUNCH,
732 App: App, 745 App: App,
733 AppsPage: AppsPage, 746 AppsPage: AppsPage,
734 launchAppAfterEnable: launchAppAfterEnable, 747 launchAppAfterEnable: launchAppAfterEnable,
735 }; 748 };
736 }); 749 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/network_speech_synthesis/tts_extension.js ('k') | chrome/browser/resources/ntp4/dot_list.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698