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

Unified Diff: chrome/browser/resources/new_new_tab.js

Issue 460007: Revert 33527 - Put "make this my home page" link into the tip section.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/new_new_tab.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/new_new_tab.js
===================================================================
--- chrome/browser/resources/new_new_tab.js (revision 33537)
+++ chrome/browser/resources/new_new_tab.js (working copy)
@@ -102,34 +102,20 @@
function createTip(data) {
if (data.length) {
- if (data[0].set_homepage_tip) {
- var homepageButton = document.createElement('button');
- homepageButton.className = 'link';
- homepageButton.textContent = data[0].set_homepage_tip;
- homepageButton.addEventListener('click', setAsHomePageLinkClicked);
- return homepageButton;
- } else {
- try {
- return parseHtmlSubset(data[0].tip_html_text);
- } catch (parseErr) {
- console.error('Error parsing tips: ' + parseErr.message);
- }
+ try {
+ return parseHtmlSubset(data[0].tip_html_text);
+ } catch (parseErr) {
+ console.error('Error parsing tips: ' + parseErr.message);
}
}
// Return an empty DF in case of failure.
return document.createDocumentFragment();
}
-function clearTipLine() {
+function renderTip() {
var tipElement = $('tip-line');
// There should always be only one tip.
tipElement.textContent = '';
- tipElement.removeEventListener('click', setAsHomePageLinkClicked);
-}
-
-function renderTip() {
- clearTipLine();
- var tipElement = $('tip-line');
tipElement.appendChild(createTip(tipCache));
fixLinkUnderlines(tipElement);
}
@@ -1271,6 +1257,10 @@
document.addEventListener('DOMContentLoaded',
callGetSyncMessageIfSyncIsPresent);
+// This link allows user to make new tab page as homepage from the new tab
+// page itself (without going to Options dialog box).
+document.addEventListener('DOMContentLoaded', showSetAsHomePageLink);
+
// Set up links and text-decoration for promotional message.
document.addEventListener('DOMContentLoaded', setUpPromoMessage);
@@ -1290,10 +1280,22 @@
e.preventDefault();
}
+function showSetAsHomePageLink() {
+ var setAsHomePageElement = $('set-as-home-page');
+ var style = setAsHomePageElement.style;
+ if (document.documentElement.getAttribute('showsetashomepage') != 'true') {
+ // Hide the section (if new tab page is already homepage).
+ return;
+ }
+
+ style.display = 'block';
+ var buttonElement = setAsHomePageElement.firstElementChild;
+ buttonElement.addEventListener('click', setAsHomePageLinkClicked);
+}
+
function onHomePageSet(data) {
+ $('set-as-home-page').style.display = 'none';
showNotification(data[0], data[1]);
- // Removes the "make this my home page" tip.
- clearTipLine();
}
function hideAllMenus() {
« no previous file with comments | « chrome/browser/resources/new_new_tab.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698