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

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

Issue 3053015: Revert bookmark bar promo CL, r52993... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 loading = true; 5 var loading = true;
6 6
7 function updateSimpleSection(id, section) { 7 function updateSimpleSection(id, section) {
8 if (shownSections & section) 8 if (shownSections & section)
9 $(id).classList.remove('hidden'); 9 $(id).classList.remove('hidden');
10 else 10 else
11 $(id).classList.add('hidden'); 11 $(id).classList.add('hidden');
12 } 12 }
13 13
14 var tipCache = {}; 14 var tipCache = {};
15 15
16 function tips(data) { 16 function tips(data) {
17 logEvent('received tips'); 17 logEvent('received tips');
18 tipCache = data; 18 tipCache = data;
19 renderTip(); 19 renderTip();
20 } 20 }
21 21
22 function createTip(data) { 22 function createTip(data) {
23 if (data.length) { 23 if (data.length) {
24 if (data[0].set_homepage_tip) { 24 if (data[0].set_homepage_tip) {
25 var homepageButton = document.createElement('button'); 25 var homepageButton = document.createElement('button');
26 homepageButton.className = 'link'; 26 homepageButton.className = 'link';
27 homepageButton.textContent = data[0].set_homepage_tip; 27 homepageButton.textContent = data[0].set_homepage_tip;
28 homepageButton.addEventListener('click', setAsHomePageLinkClicked); 28 homepageButton.addEventListener('click', setAsHomePageLinkClicked);
29 return homepageButton; 29 return homepageButton;
30 } else if (data[0].set_promo_tip) {
31 var promoMessage = document.createElement('span');
32 promoMessage.innerHTML = data[0].set_promo_tip;
33 var promoButton = promoMessage.querySelector('button');
34 promoButton.addEventListener('click', importBookmarksLinkClicked);
35 return promoMessage;
36 } else { 30 } else {
37 try { 31 try {
38 return parseHtmlSubset(data[0].tip_html_text); 32 return parseHtmlSubset(data[0].tip_html_text);
39 } catch (parseErr) { 33 } catch (parseErr) {
40 console.error('Error parsing tips: ' + parseErr.message); 34 console.error('Error parsing tips: ' + parseErr.message);
41 } 35 }
42 } 36 }
43 } 37 }
44 // Return an empty DF in case of failure. 38 // Return an empty DF in case of failure.
45 return document.createDocumentFragment(); 39 return document.createDocumentFragment();
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 var actionLink = notificationElement.querySelector('.link-color'); 434 var actionLink = notificationElement.querySelector('.link-color');
441 // Prevent tabbing to the hidden link. 435 // Prevent tabbing to the hidden link.
442 actionLink.tabIndex = -1; 436 actionLink.tabIndex = -1;
443 // Setting tabIndex to -1 only prevents future tabbing to it. If, however, the 437 // Setting tabIndex to -1 only prevents future tabbing to it. If, however, the
444 // user switches window or a tab and then moves back to this tab the element 438 // user switches window or a tab and then moves back to this tab the element
445 // may gain focus. We therefore make sure that we blur the element so that the 439 // may gain focus. We therefore make sure that we blur the element so that the
446 // element focus is not restored when coming back to this window. 440 // element focus is not restored when coming back to this window.
447 actionLink.blur(); 441 actionLink.blur();
448 } 442 }
449 443
444 function showFirstRunNotification() {
445 showNotification(localStrings.getString('firstrunnotification'),
446 localStrings.getString('closefirstrunnotification'),
447 null, 30000);
448 var notificationElement = $('notification');
449 notification.classList.add('first-run');
450 }
451
450 /** 452 /**
451 * This handles the option menu. 453 * This handles the option menu.
452 * @param {Element} button The button element. 454 * @param {Element} button The button element.
453 * @param {Element} menu The menu element. 455 * @param {Element} menu The menu element.
454 * @constructor 456 * @constructor
455 */ 457 */
456 function OptionMenu(button, menu) { 458 function OptionMenu(button, menu) {
457 this.button = button; 459 this.button = button;
458 this.menu = menu; 460 this.menu = menu;
459 this.button.onmousedown = bind(this.handleMouseDown, this); 461 this.button.onmousedown = bind(this.handleMouseDown, this);
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 if (document.documentElement.getAttribute('syncispresent') == 'true') { 845 if (document.documentElement.getAttribute('syncispresent') == 'true') {
844 chrome.send('GetSyncMessage'); 846 chrome.send('GetSyncMessage');
845 } 847 }
846 } 848 }
847 849
848 function setAsHomePageLinkClicked(e) { 850 function setAsHomePageLinkClicked(e) {
849 chrome.send('setHomePage'); 851 chrome.send('setHomePage');
850 e.preventDefault(); 852 e.preventDefault();
851 } 853 }
852 854
853 function importBookmarksLinkClicked(e) {
854 chrome.send('importBookmarks');
855 e.preventDefault();
856 }
857
858 function onHomePageSet(data) { 855 function onHomePageSet(data) {
859 showNotification(data[0], data[1]); 856 showNotification(data[0], data[1]);
860 // Removes the "make this my home page" tip. 857 // Removes the "make this my home page" tip.
861 clearTipLine(); 858 clearTipLine();
862 } 859 }
863 860
864 function hideAllMenus() { 861 function hideAllMenus() {
865 optionMenu.hide(); 862 optionMenu.hide();
866 } 863 }
867 864
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 mostVisited.layout(); 924 mostVisited.layout();
928 925
929 loading = false; 926 loading = false;
930 927
931 // Remove class name in a timeout so that changes done in this JS thread are 928 // Remove class name in a timeout so that changes done in this JS thread are
932 // not animated. 929 // not animated.
933 window.setTimeout(function() { 930 window.setTimeout(function() {
934 mostVisited.ensureSmallGridCorrect(); 931 mostVisited.ensureSmallGridCorrect();
935 document.body.classList.remove('loading'); 932 document.body.classList.remove('loading');
936 }, 1); 933 }, 1);
934
935 // Only show the first run notification if first run.
936 if (firstRun) {
937 showFirstRunNotification();
938 }
937 } 939 }
938 940
939 // Log clicked links from the tips section. 941 // Log clicked links from the tips section.
940 document.addEventListener('click', function(e) { 942 document.addEventListener('click', function(e) {
941 var tipLinks = document.querySelectorAll('#tip-line a'); 943 var tipLinks = document.querySelectorAll('#tip-line a');
942 for (var i = 0, tipLink; tipLink = tipLinks[i]; i++) { 944 for (var i = 0, tipLink; tipLink = tipLinks[i]; i++) {
943 if (tipLink.contains(e.target)) { 945 if (tipLink.contains(e.target)) {
944 chrome.send('metrics', ['NTPTip_' + tipLink.href]); 946 chrome.send('metrics', ['NTPTip_' + tipLink.href]);
945 break; 947 break;
946 } 948 }
947 } 949 }
948 }); 950 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/new_new_tab.css ('k') | chrome/browser/tab_contents/web_contents_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698