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

Side by Side Diff: chrome/browser/resources/ntp_android/ntp_android.js

Issue 10928039: Add support for testing Android's NTP w/o Android. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Resolved review nits. Created 8 years, 3 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
« no previous file with comments | « chrome/browser/resources/ntp_android/new_tab.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // File Description: 5 // File Description:
6 // Contains all the necessary functions for rendering the NTP on mobile 6 // Contains all the necessary functions for rendering the NTP on mobile
7 // devices. 7 // devices.
8 8
9 /** 9 /**
10 * The event type used to determine when a touch starts. 10 * The event type used to determine when a touch starts.
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 * @param {function(Object, string, BrowserEvent)=} opt_clickCallback The 585 * @param {function(Object, string, BrowserEvent)=} opt_clickCallback The
586 * click callback to be triggered upon selection (if not provided it will 586 * click callback to be triggered upon selection (if not provided it will
587 * use the default -- itemShortcutClickHandler). 587 * use the default -- itemShortcutClickHandler).
588 * @return {Element} The shortcut element created. 588 * @return {Element} The shortcut element created.
589 */ 589 */
590 function makeRecentlyClosedTabletItem(item, opt_clickCallback) { 590 function makeRecentlyClosedTabletItem(item, opt_clickCallback) {
591 var cell = createDiv('cell'); 591 var cell = createDiv('cell');
592 592
593 cell.setAttribute(CONTEXT_MENU_URL_KEY, item.url); 593 cell.setAttribute(CONTEXT_MENU_URL_KEY, item.url);
594 594
595 var iconUrl = MOCK ? 595 var iconUrl = item.icon || 'chrome://touch-icon/size/64/' + item.url;
596 touchIconURI : 'chrome://touch-icon/size/64/' + item.url;
597 var icon = createDiv('icon', iconUrl); 596 var icon = createDiv('icon', iconUrl);
598 trackImageLoad(iconUrl); 597 trackImageLoad(iconUrl);
599 cell.appendChild(icon); 598 cell.appendChild(icon);
600 599
601 var title = createDiv('title'); 600 var title = createDiv('title');
602 title.textContent = item.title; 601 title.textContent = item.title;
603 cell.appendChild(title); 602 cell.appendChild(title);
604 603
605 wrapClickHandler(cell, item, opt_clickCallback); 604 wrapClickHandler(cell, item, opt_clickCallback);
606 605
(...skipping 15 matching lines...) Expand all
622 // thumbnail-cell -- main outer container 621 // thumbnail-cell -- main outer container
623 // thumbnail-container -- container for the thumbnail 622 // thumbnail-container -- container for the thumbnail
624 // thumbnail -- the actual thumbnail image; outer border 623 // thumbnail -- the actual thumbnail image; outer border
625 // inner-border -- inner border 624 // inner-border -- inner border
626 // title -- container for the title 625 // title -- container for the title
627 // img -- hack align title text baseline with bottom 626 // img -- hack align title text baseline with bottom
628 // title text -- the actual text of the title 627 // title text -- the actual text of the title
629 var thumbnailCell = createDiv('thumbnail-cell'); 628 var thumbnailCell = createDiv('thumbnail-cell');
630 var thumbnailContainer = createDiv('thumbnail-container'); 629 var thumbnailContainer = createDiv('thumbnail-container');
631 var backgroundUrl = item.thumbnailUrl || 'chrome://thumb/' + item.url; 630 var backgroundUrl = item.thumbnailUrl || 'chrome://thumb/' + item.url;
632 if (MOCK)
633 backgroundUrl = thumbnailURI;
634 if (backgroundUrl == 'chrome://thumb/chrome://welcome/') { 631 if (backgroundUrl == 'chrome://thumb/chrome://welcome/') {
635 // Ideally, it would be nice to use the URL as is. However, as of now 632 // Ideally, it would be nice to use the URL as is. However, as of now
636 // theme support has been removed from Chrome. Instead, load the image 633 // theme support has been removed from Chrome. Instead, load the image
637 // URL from a style and use it. Don't just use the style because 634 // URL from a style and use it. Don't just use the style because
638 // trackImageLoad(...) must be called with the background URL. 635 // trackImageLoad(...) must be called with the background URL.
639 var welcomeStyle = findCssRule('.welcome-to-chrome').style; 636 var welcomeStyle = findCssRule('.welcome-to-chrome').style;
640 var backgroundImage = welcomeStyle.backgroundImage; 637 var backgroundImage = welcomeStyle.backgroundImage;
641 // trim the "url(" prefix and ")" suffix 638 // trim the "url(" prefix and ")" suffix
642 backgroundUrl = backgroundImage.substring(4, backgroundImage.length - 1); 639 backgroundUrl = backgroundImage.substring(4, backgroundImage.length - 1);
643 } 640 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 function makeBookmarkItem(item, opt_clickCallback) { 678 function makeBookmarkItem(item, opt_clickCallback) {
682 var holder = createDiv('favicon-cell'); 679 var holder = createDiv('favicon-cell');
683 addActiveTouchListener(holder, 'favicon-cell-active'); 680 addActiveTouchListener(holder, 'favicon-cell-active');
684 681
685 holder.setAttribute(CONTEXT_MENU_URL_KEY, item.url); 682 holder.setAttribute(CONTEXT_MENU_URL_KEY, item.url);
686 holder.contextMenuItem = item; 683 holder.contextMenuItem = item;
687 var faviconBox = createDiv('favicon-box'); 684 var faviconBox = createDiv('favicon-box');
688 if (item.folder) { 685 if (item.folder) {
689 faviconBox.classList.add('folder'); 686 faviconBox.classList.add('folder');
690 } else { 687 } else {
691 var iconUrl = MOCK ? item.icon : 'chrome://touch-icon/' + item.url; 688 var iconUrl = item.icon || 'chrome://touch-icon/' + item.url;
692 var faviconIcon = createDiv('favicon-icon'); 689 var faviconIcon = createDiv('favicon-icon');
693 faviconIcon.style.backgroundImage = 'url(' + iconUrl + ')'; 690 faviconIcon.style.backgroundImage = 'url(' + iconUrl + ')';
694 trackImageLoad(iconUrl); 691 trackImageLoad(iconUrl);
695 692
696 var image = new Image(); 693 var image = new Image();
697 image.src = iconUrl; 694 image.src = iconUrl;
698 image.onload = function() { 695 image.onload = function() {
699 var w = image.width; 696 var w = image.width;
700 var h = image.height; 697 var h = image.height;
701 if (w <= 16 || h <= 16) { 698 if (w <= 16 || h <= 16) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 * @param {Object} item The data of the item used to generate the shortcut. 801 * @param {Object} item The data of the item used to generate the shortcut.
805 * @param {function(Object, string, BrowserEvent)=} opt_clickCallback The 802 * @param {function(Object, string, BrowserEvent)=} opt_clickCallback The
806 * click callback to be triggered upon selection (if not provided it will 803 * click callback to be triggered upon selection (if not provided it will
807 * use the default -- itemShortcutClickHandler). 804 * use the default -- itemShortcutClickHandler).
808 * @return {Element} The shortcut element created. 805 * @return {Element} The shortcut element created.
809 */ 806 */
810 function makeListEntryItem(item, opt_clickCallback) { 807 function makeListEntryItem(item, opt_clickCallback) {
811 var listItem = createDiv('list-item'); 808 var listItem = createDiv('list-item');
812 addActiveTouchListener(listItem, ACTIVE_LIST_ITEM_CSS_CLASS); 809 addActiveTouchListener(listItem, ACTIVE_LIST_ITEM_CSS_CLASS);
813 listItem.setAttribute(CONTEXT_MENU_URL_KEY, item.url); 810 listItem.setAttribute(CONTEXT_MENU_URL_KEY, item.url);
814 var iconUrl = MOCK ? item.icon : 'chrome://touch-icon/size/64/' + item.url; 811 var iconUrl = item.icon || 'chrome://touch-icon/size/64/' + item.url;
815 listItem.appendChild(createDiv('icon', iconUrl)); 812 listItem.appendChild(createDiv('icon', iconUrl));
816 trackImageLoad(iconUrl); 813 trackImageLoad(iconUrl);
817 var title = createElement('span', { 814 var title = createElement('span', {
818 textContent: item.title, 815 textContent: item.title,
819 className: 'title' 816 className: 'title'
820 }); 817 });
821 listItem.appendChild(title); 818 listItem.appendChild(title);
822 listItem.addEventListener('click', function(evt) { 819 listItem.addEventListener('click', function(evt) {
823 var clickCallback = 820 var clickCallback =
824 opt_clickCallback ? opt_clickCallback : itemShortcutClickHandler; 821 opt_clickCallback ? opt_clickCallback : itemShortcutClickHandler;
(...skipping 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after
2617 // NTP Entry point. 2614 // NTP Entry point.
2618 ///////////////////////////////////////////////////////////////////////////// 2615 /////////////////////////////////////////////////////////////////////////////
2619 2616
2620 /* 2617 /*
2621 * Handles initializing the UI when the page has finished loading. 2618 * Handles initializing the UI when the page has finished loading.
2622 */ 2619 */
2623 window.addEventListener('DOMContentLoaded', function(evt) { 2620 window.addEventListener('DOMContentLoaded', function(evt) {
2624 ntp.init(); 2621 ntp.init();
2625 $('content-area').style.display = 'block'; 2622 $('content-area').style.display = 'block';
2626 }); 2623 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/ntp_android/new_tab.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698