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

Side by Side Diff: chrome/browser/resources/ntp_search/new_tab.js

Issue 10829131: Refactoring NTP5: new implementation of TilePage and MostVisitedPage (which now inherits from Thumb… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Manually fixing mock_data_autogen.js lines with more than 80 chars. Created 8 years, 4 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 /** 5 /**
6 * @fileoverview New tab page 6 * @fileoverview New tab page
7 * This is the main code for the new tab page used by touch-enabled Chrome 7 * This is the main code for the new tab page used by touch-enabled Chrome
8 * browsers. For now this is still a prototype. 8 * browsers. For now this is still a prototype.
9 */ 9 */
10 10
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 function NewTabView() { 80 function NewTabView() {
81 var pageSwitcherStart = null; 81 var pageSwitcherStart = null;
82 var pageSwitcherEnd = null; 82 var pageSwitcherEnd = null;
83 if (loadTimeData.getValue('showApps')) { 83 if (loadTimeData.getValue('showApps')) {
84 pageSwitcherStart = getRequiredElement('page-switcher-start'); 84 pageSwitcherStart = getRequiredElement('page-switcher-start');
85 pageSwitcherEnd = getRequiredElement('page-switcher-end'); 85 pageSwitcherEnd = getRequiredElement('page-switcher-end');
86 } 86 }
87 this.initialize(getRequiredElement('page-list'), 87 this.initialize(getRequiredElement('page-list'),
88 getRequiredElement('dot-list'), 88 getRequiredElement('dot-list'),
89 getRequiredElement('card-slider-frame'), 89 getRequiredElement('card-slider-frame'),
90 // TODO(pedrosimonetti): Remove the Trash component.
90 getRequiredElement('trash'), 91 getRequiredElement('trash'),
92 // TODO(pedrosimonetti): Remove page switchers.
91 pageSwitcherStart, pageSwitcherEnd); 93 pageSwitcherStart, pageSwitcherEnd);
92 } 94 }
93 95
94 NewTabView.prototype = { 96 NewTabView.prototype = {
95 __proto__: ntp.PageListView.prototype, 97 __proto__: ntp.PageListView.prototype,
96 98
97 /** @inheritDoc */ 99 /** @inheritDoc */
98 appendTilePage: function(page, title, titleIsEditable, opt_refNode) { 100 appendTilePage: function(page, title, titleIsEditable, opt_refNode) {
99 ntp.PageListView.prototype.appendTilePage.apply(this, arguments); 101 ntp.PageListView.prototype.appendTilePage.apply(this, arguments);
100 102
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 440
439 function setMostVisitedPages(data, hasBlacklistedUrls) { 441 function setMostVisitedPages(data, hasBlacklistedUrls) {
440 newTabView.mostVisitedPage.data = data; 442 newTabView.mostVisitedPage.data = data;
441 cr.dispatchSimpleEvent(document, 'sectionready', true, true); 443 cr.dispatchSimpleEvent(document, 'sectionready', true, true);
442 } 444 }
443 445
444 function setSuggestionsPages(data, hasBlacklistedUrls) { 446 function setSuggestionsPages(data, hasBlacklistedUrls) {
445 newTabView.suggestionsPage.data = data; 447 newTabView.suggestionsPage.data = data;
446 } 448 }
447 449
448 /** 450 function getThumbnailUrl(url) {
449 * Set the dominant color for a node. This will be called in response to 451 return 'chrome://thumb/' + url;
450 * getFaviconDominantColor. The node represented by |id| better have a setter
451 * for stripeColor.
452 * @param {string} id The ID of a node.
453 * @param {string} color The color represented as a CSS string.
454 */
455 function setStripeColor(id, color) {
456 var node = $(id);
457 if (node)
458 node.stripeColor = color;
459 } 452 }
460 453
461 /** 454 /**
462 * Updates the text displayed in the login container. If there is no text then 455 * Updates the text displayed in the login container. If there is no text then
463 * the login container is hidden. 456 * the login container is hidden.
464 * @param {string} loginHeader The first line of text. 457 * @param {string} loginHeader The first line of text.
465 * @param {string} loginSubHeader The second line of text. 458 * @param {string} loginSubHeader The second line of text.
466 * @param {string} iconURL The url for the login status icon. If this is null 459 * @param {string} iconURL The url for the login status icon. If this is null
467 then the login status icon is hidden. 460 then the login status icon is hidden.
468 * @param {boolean} isUserSignedIn Indicates if the user is signed in or not. 461 * @param {boolean} isUserSignedIn Indicates if the user is signed in or not.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 } 516 }
524 517
525 function appsPrefChangeCallback() { 518 function appsPrefChangeCallback() {
526 return newTabView.appsPrefChangedCallback.apply(newTabView, arguments); 519 return newTabView.appsPrefChangedCallback.apply(newTabView, arguments);
527 } 520 }
528 521
529 function appsReordered() { 522 function appsReordered() {
530 return newTabView.appsReordered.apply(newTabView, arguments); 523 return newTabView.appsReordered.apply(newTabView, arguments);
531 } 524 }
532 525
533 function enterRearrangeMode() {
534 return newTabView.enterRearrangeMode.apply(newTabView, arguments);
535 }
536
537 function setForeignSessions(sessionList, isTabSyncEnabled) { 526 function setForeignSessions(sessionList, isTabSyncEnabled) {
538 if (otherSessionsButton) 527 if (otherSessionsButton)
539 otherSessionsButton.setForeignSessions(sessionList, isTabSyncEnabled); 528 otherSessionsButton.setForeignSessions(sessionList, isTabSyncEnabled);
540 } 529 }
541 530
542 function getAppsCallback() { 531 function getAppsCallback() {
543 return newTabView.getAppsCallback.apply(newTabView, arguments); 532 return newTabView.getAppsCallback.apply(newTabView, arguments);
544 } 533 }
545 534
546 function getAppsPageIndex() { 535 function getAppsPageIndex() {
547 return newTabView.getAppsPageIndex.apply(newTabView, arguments); 536 return newTabView.getAppsPageIndex.apply(newTabView, arguments);
548 } 537 }
549 538
550 function getCardSlider() { 539 function getCardSlider() {
551 return newTabView.cardSlider; 540 return newTabView.cardSlider;
552 } 541 }
553 542
554 function leaveRearrangeMode() {
555 return newTabView.leaveRearrangeMode.apply(newTabView, arguments);
556 }
557
558 function saveAppPageName() { 543 function saveAppPageName() {
559 return newTabView.saveAppPageName.apply(newTabView, arguments); 544 return newTabView.saveAppPageName.apply(newTabView, arguments);
560 } 545 }
561 546
562 function setAppToBeHighlighted(appId) { 547 function setAppToBeHighlighted(appId) {
563 newTabView.highlightAppId = appId; 548 newTabView.highlightAppId = appId;
564 } 549 }
565 550
566 // Return an object with all the exports 551 // Return an object with all the exports
567 return { 552 return {
568 appAdded: appAdded, 553 appAdded: appAdded,
569 appMoved: appMoved, 554 appMoved: appMoved,
570 appRemoved: appRemoved, 555 appRemoved: appRemoved,
571 appsPrefChangeCallback: appsPrefChangeCallback, 556 appsPrefChangeCallback: appsPrefChangeCallback,
572 enterRearrangeMode: enterRearrangeMode,
573 getAppsCallback: getAppsCallback, 557 getAppsCallback: getAppsCallback,
574 getAppsPageIndex: getAppsPageIndex, 558 getAppsPageIndex: getAppsPageIndex,
575 getCardSlider: getCardSlider, 559 getCardSlider: getCardSlider,
560 getThumbnailUrl: getThumbnailUrl,
576 onLoad: onLoad, 561 onLoad: onLoad,
577 leaveRearrangeMode: leaveRearrangeMode,
578 NtpFollowAction: NtpFollowAction, 562 NtpFollowAction: NtpFollowAction,
579 saveAppPageName: saveAppPageName, 563 saveAppPageName: saveAppPageName,
580 setAppToBeHighlighted: setAppToBeHighlighted, 564 setAppToBeHighlighted: setAppToBeHighlighted,
581 setBookmarkBarAttached: setBookmarkBarAttached, 565 setBookmarkBarAttached: setBookmarkBarAttached,
582 setForeignSessions: setForeignSessions, 566 setForeignSessions: setForeignSessions,
583 setMostVisitedPages: setMostVisitedPages, 567 setMostVisitedPages: setMostVisitedPages,
584 setSuggestionsPages: setSuggestionsPages, 568 setSuggestionsPages: setSuggestionsPages,
585 setRecentlyClosedTabs: setRecentlyClosedTabs, 569 setRecentlyClosedTabs: setRecentlyClosedTabs,
586 setStripeColor: setStripeColor,
587 showNotification: showNotification, 570 showNotification: showNotification,
588 themeChanged: themeChanged, 571 themeChanged: themeChanged,
589 updateLogin: updateLogin 572 updateLogin: updateLogin
590 }; 573 };
591 }); 574 });
592 575
593 document.addEventListener('DOMContentLoaded', ntp.onLoad); 576 document.addEventListener('DOMContentLoaded', ntp.onLoad);
594 577
595 var toCssPx = cr.ui.toCssPx; 578 var toCssPx = cr.ui.toCssPx;
OLDNEW
« no previous file with comments | « chrome/browser/resources/ntp_search/new_tab.html ('k') | chrome/browser/resources/ntp_search/page_list_view.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698