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

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: Fixed incorrect favicon function name 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 =
596 touchIconURI : 'chrome://touch-icon/size/64/' + item.url; 596 item.icon ? item.icon : 'chrome://touch-icon/size/64/' + item.url;
Evan Stade 2012/09/10 09:16:08 reverseditto
Ted C 2012/09/10 22:35:08 Done.
597 var icon = createDiv('icon', iconUrl); 597 var icon = createDiv('icon', iconUrl);
598 trackImageLoad(iconUrl); 598 trackImageLoad(iconUrl);
599 cell.appendChild(icon); 599 cell.appendChild(icon);
600 600
601 var title = createDiv('title'); 601 var title = createDiv('title');
602 title.textContent = item.title; 602 title.textContent = item.title;
603 cell.appendChild(title); 603 cell.appendChild(title);
604 604
605 wrapClickHandler(cell, item, opt_clickCallback); 605 wrapClickHandler(cell, item, opt_clickCallback);
606 606
(...skipping 15 matching lines...) Expand all
622 // thumbnail-cell -- main outer container 622 // thumbnail-cell -- main outer container
623 // thumbnail-container -- container for the thumbnail 623 // thumbnail-container -- container for the thumbnail
624 // thumbnail -- the actual thumbnail image; outer border 624 // thumbnail -- the actual thumbnail image; outer border
625 // inner-border -- inner border 625 // inner-border -- inner border
626 // title -- container for the title 626 // title -- container for the title
627 // img -- hack align title text baseline with bottom 627 // img -- hack align title text baseline with bottom
628 // title text -- the actual text of the title 628 // title text -- the actual text of the title
629 var thumbnailCell = createDiv('thumbnail-cell'); 629 var thumbnailCell = createDiv('thumbnail-cell');
630 var thumbnailContainer = createDiv('thumbnail-container'); 630 var thumbnailContainer = createDiv('thumbnail-container');
631 var backgroundUrl = item.thumbnailUrl || 'chrome://thumb/' + item.url; 631 var backgroundUrl = item.thumbnailUrl || 'chrome://thumb/' + item.url;
632 if (MOCK)
633 backgroundUrl = thumbnailURI;
634 if (backgroundUrl == 'chrome://thumb/chrome://welcome/') { 632 if (backgroundUrl == 'chrome://thumb/chrome://welcome/') {
635 // Ideally, it would be nice to use the URL as is. However, as of now 633 // 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 634 // 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 635 // URL from a style and use it. Don't just use the style because
638 // trackImageLoad(...) must be called with the background URL. 636 // trackImageLoad(...) must be called with the background URL.
639 var welcomeStyle = findCssRule('.welcome-to-chrome').style; 637 var welcomeStyle = findCssRule('.welcome-to-chrome').style;
640 var backgroundImage = welcomeStyle.backgroundImage; 638 var backgroundImage = welcomeStyle.backgroundImage;
641 // trim the "url(" prefix and ")" suffix 639 // trim the "url(" prefix and ")" suffix
642 backgroundUrl = backgroundImage.substring(4, backgroundImage.length - 1); 640 backgroundUrl = backgroundImage.substring(4, backgroundImage.length - 1);
643 } 641 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 function makeBookmarkItem(item, opt_clickCallback) { 679 function makeBookmarkItem(item, opt_clickCallback) {
682 var holder = createDiv('favicon-cell'); 680 var holder = createDiv('favicon-cell');
683 addActiveTouchListener(holder, 'favicon-cell-active'); 681 addActiveTouchListener(holder, 'favicon-cell-active');
684 682
685 holder.setAttribute(CONTEXT_MENU_URL_KEY, item.url); 683 holder.setAttribute(CONTEXT_MENU_URL_KEY, item.url);
686 holder.contextMenuItem = item; 684 holder.contextMenuItem = item;
687 var faviconBox = createDiv('favicon-box'); 685 var faviconBox = createDiv('favicon-box');
688 if (item.folder) { 686 if (item.folder) {
689 faviconBox.classList.add('folder'); 687 faviconBox.classList.add('folder');
690 } else { 688 } else {
691 var iconUrl = MOCK ? item.icon : 'chrome://touch-icon/' + item.url; 689 var iconUrl = item.icon ? item.icon : 'chrome://touch-icon/' + item.url;
Evan Stade 2012/09/10 09:16:08 reverse ditto
Ted C 2012/09/10 22:35:08 Done.
692 var faviconIcon = createDiv('favicon-icon'); 690 var faviconIcon = createDiv('favicon-icon');
693 faviconIcon.style.backgroundImage = 'url(' + iconUrl + ')'; 691 faviconIcon.style.backgroundImage = 'url(' + iconUrl + ')';
694 trackImageLoad(iconUrl); 692 trackImageLoad(iconUrl);
695 693
696 var image = new Image(); 694 var image = new Image();
697 image.src = iconUrl; 695 image.src = iconUrl;
698 image.onload = function() { 696 image.onload = function() {
699 var w = image.width; 697 var w = image.width;
700 var h = image.height; 698 var h = image.height;
701 if (w <= 16 || h <= 16) { 699 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. 802 * @param {Object} item The data of the item used to generate the shortcut.
805 * @param {function(Object, string, BrowserEvent)=} opt_clickCallback The 803 * @param {function(Object, string, BrowserEvent)=} opt_clickCallback The
806 * click callback to be triggered upon selection (if not provided it will 804 * click callback to be triggered upon selection (if not provided it will
807 * use the default -- itemShortcutClickHandler). 805 * use the default -- itemShortcutClickHandler).
808 * @return {Element} The shortcut element created. 806 * @return {Element} The shortcut element created.
809 */ 807 */
810 function makeListEntryItem(item, opt_clickCallback) { 808 function makeListEntryItem(item, opt_clickCallback) {
811 var listItem = createDiv('list-item'); 809 var listItem = createDiv('list-item');
812 addActiveTouchListener(listItem, ACTIVE_LIST_ITEM_CSS_CLASS); 810 addActiveTouchListener(listItem, ACTIVE_LIST_ITEM_CSS_CLASS);
813 listItem.setAttribute(CONTEXT_MENU_URL_KEY, item.url); 811 listItem.setAttribute(CONTEXT_MENU_URL_KEY, item.url);
814 var iconUrl = MOCK ? item.icon : 'chrome://touch-icon/size/64/' + item.url; 812 var iconUrl =
813 item.icon ? item.icon : 'chrome://touch-icon/size/64/' + item.url;
Evan Stade 2012/09/10 09:16:08 in javascript you do this like so: var iconUrl =
Ted C 2012/09/10 22:35:08 Done.
815 listItem.appendChild(createDiv('icon', iconUrl)); 814 listItem.appendChild(createDiv('icon', iconUrl));
816 trackImageLoad(iconUrl); 815 trackImageLoad(iconUrl);
817 var title = createElement('span', { 816 var title = createElement('span', {
818 textContent: item.title, 817 textContent: item.title,
819 className: 'title' 818 className: 'title'
820 }); 819 });
821 listItem.appendChild(title); 820 listItem.appendChild(title);
822 listItem.addEventListener('click', function(evt) { 821 listItem.addEventListener('click', function(evt) {
823 var clickCallback = 822 var clickCallback =
824 opt_clickCallback ? opt_clickCallback : itemShortcutClickHandler; 823 opt_clickCallback ? opt_clickCallback : itemShortcutClickHandler;
(...skipping 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after
2617 // NTP Entry point. 2616 // NTP Entry point.
2618 ///////////////////////////////////////////////////////////////////////////// 2617 /////////////////////////////////////////////////////////////////////////////
2619 2618
2620 /* 2619 /*
2621 * Handles initializing the UI when the page has finished loading. 2620 * Handles initializing the UI when the page has finished loading.
2622 */ 2621 */
2623 window.addEventListener('DOMContentLoaded', function(evt) { 2622 window.addEventListener('DOMContentLoaded', function(evt) {
2624 ntp.init(); 2623 ntp.init();
2625 $('content-area').style.display = 'block'; 2624 $('content-area').style.display = 'block';
2626 }); 2625 });
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