summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-02 02:21:36 +0000
committermirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-02 02:21:36 +0000
commitc4712105103f7132e4e97eaf9377c728565dc345 (patch)
tree64f83446693eae1118367981cfa97592ad8eee42 /chrome
parent62f1c6e07577f962fbeaf38e54535d3e5904308b (diff)
downloadchromium_src-c4712105103f7132e4e97eaf9377c728565dc345.zip
chromium_src-c4712105103f7132e4e97eaf9377c728565dc345.tar.gz
chromium_src-c4712105103f7132e4e97eaf9377c728565dc345.tar.bz2
Revert 33527 - Put "make this my home page" link into the tip section.
BUG= 28196 TEST= "make this my home page" should show up as a tip. Review URL: http://codereview.chromium.org/449073 TBR=mirandac@chromium.org Review URL: http://codereview.chromium.org/460007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33538 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/dom_ui/ntp_resource_cache.cc5
-rw-r--r--chrome/browser/dom_ui/tips_handler.cc32
-rw-r--r--chrome/browser/dom_ui/tips_handler.h7
-rw-r--r--chrome/browser/resources/new_new_tab.html9
-rw-r--r--chrome/browser/resources/new_new_tab.js44
5 files changed, 43 insertions, 54 deletions
diff --git a/chrome/browser/dom_ui/ntp_resource_cache.cc b/chrome/browser/dom_ui/ntp_resource_cache.cc
index 8f10ffe..42a2683 100644
--- a/chrome/browser/dom_ui/ntp_resource_cache.cc
+++ b/chrome/browser/dom_ui/ntp_resource_cache.cc
@@ -143,6 +143,7 @@ NTPResourceCache::NTPResourceCache(Profile* profile) : profile_(profile) {
// Watch for pref changes that cause us to need to invalidate the HTML cache.
PrefService* pref_service = profile_->GetPrefs();
pref_service->AddPrefObserver(prefs::kShowBookmarkBar, this);
+ pref_service->AddPrefObserver(prefs::kHomePageIsNewTabPage, this);
pref_service->AddPrefObserver(prefs::kNTPShownSections, this);
// Watch for pref changes that cause us to need to invalidate the CSS cache.
@@ -152,6 +153,7 @@ NTPResourceCache::NTPResourceCache(Profile* profile) : profile_(profile) {
NTPResourceCache::~NTPResourceCache() {
PrefService* pref_service = profile_->GetPrefs();
pref_service->RemovePrefObserver(prefs::kShowBookmarkBar, this);
+ pref_service->RemovePrefObserver(prefs::kHomePageIsNewTabPage, this);
pref_service->RemovePrefObserver(prefs::kNTPShownSections, this);
pref_service->RemovePrefObserver(prefs::kNTPPromoLineRemaining, this);
@@ -357,6 +359,9 @@ void NTPResourceCache::CreateNewTabHTML() {
else
localized_strings.SetString(L"syncispresent", "false");
+ if (!profile_->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage))
+ localized_strings.SetString(L"showsetashomepage", "true");
+
ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings);
// Control fade and resize animations.
diff --git a/chrome/browser/dom_ui/tips_handler.cc b/chrome/browser/dom_ui/tips_handler.cc
index 7fd5ac1..ee429f7 100644
--- a/chrome/browser/dom_ui/tips_handler.cc
+++ b/chrome/browser/dom_ui/tips_handler.cc
@@ -4,7 +4,6 @@
#include <string>
-#include "app/l10n_util.h"
#include "base/string_util.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
@@ -15,7 +14,6 @@
#include "chrome/common/web_resource/web_resource_unpacker.h"
#include "chrome/common/url_constants.h"
#include "googleurl/src/gurl.h"
-#include "grit/generated_resources.h"
DOMMessageHandler* TipsHandler::Attach(DOMUI* dom_ui) {
dom_ui_ = dom_ui;
@@ -30,7 +28,7 @@ void TipsHandler::RegisterMessages() {
}
void TipsHandler::HandleGetTips(const Value* content) {
- // List containing the tips to be displayed.
+ // List containing the tips to be displayed.
ListValue list_value;
// Holds the web resource data found in the preferences cache.
@@ -60,34 +58,18 @@ void TipsHandler::HandleGetTips(const Value* content) {
tips_cache_->GetList(
WebResourceService::kTipCachePrefName, &wr_list) &&
wr_list && wr_list->GetSize() > 0) {
- if (wr_list->GetSize() <= static_cast<size_t>(current_tip_index)) {
- // Check to see whether the home page is set to NTP; if not, add tip
- // to set home page before resetting tip index to 0.
+ if (wr_list->GetSize() <= static_cast<size_t>(current_tip_index))
current_tip_index = 0;
- if (!dom_ui_->GetProfile()->GetPrefs()->GetBoolean(
- prefs::kHomePageIsNewTabPage)) {
- SendTip(WideToASCII(l10n_util::GetString(
- IDS_NEW_TAB_MAKE_THIS_HOMEPAGE)), L"set_homepage_tip",
- current_tip_index);
- return;
- }
- }
if (wr_list->GetString(current_tip_index, &current_tip)) {
- SendTip(current_tip, L"tip_html_text", current_tip_index + 1);
+ DictionaryValue* tip_dict = new DictionaryValue();
+ tip_dict->SetString(L"tip_html_text", current_tip);
+ list_value.Append(tip_dict);
+ tips_cache_->SetInteger(WebResourceService::kCurrentTipPrefName,
+ current_tip_index + 1);
}
}
}
-}
-void TipsHandler::SendTip(std::string tip, std::wstring tip_type,
- int tip_index) {
- // List containing the tips to be displayed.
- ListValue list_value;
- DictionaryValue* tip_dict = new DictionaryValue();
- tip_dict->SetString(tip_type, tip);
- list_value.Append(tip_dict);
- tips_cache_->SetInteger(WebResourceService::kCurrentTipPrefName,
- tip_index);
// Send list of web resource items back out to the DOM.
dom_ui_->CallJavascriptFunction(L"tips", list_value);
}
diff --git a/chrome/browser/dom_ui/tips_handler.h b/chrome/browser/dom_ui/tips_handler.h
index d85d4d8..a5915ec 100644
--- a/chrome/browser/dom_ui/tips_handler.h
+++ b/chrome/browser/dom_ui/tips_handler.h
@@ -9,8 +9,6 @@
#ifndef CHROME_BROWSER_DOM_UI_TIPS_HANDLER_H_
#define CHROME_BROWSER_DOM_UI_TIPS_HANDLER_H_
-#include <string>
-
#include "chrome/browser/dom_ui/dom_ui.h"
class DictionaryValue;
@@ -37,11 +35,6 @@ class TipsHandler : public DOMMessageHandler {
// Make sure the string we are pushing to the NTP is a valid URL.
bool IsValidURL(const std::wstring& url_string);
- // Send a tip to the NTP. tip_type is "tip_html_text" if the tip is from
- // the tip server, and "set_homepage_tip" if it's the tip to set the NTP
- // as home page.
- void SendTip(std::string tip, std::wstring tip_type, int tip_index);
-
// So we can push data out to the page that has called this handler.
DOMUI* dom_ui_;
diff --git a/chrome/browser/resources/new_new_tab.html b/chrome/browser/resources/new_new_tab.html
index 831d3b1..a3ff823 100644
--- a/chrome/browser/resources/new_new_tab.html
+++ b/chrome/browser/resources/new_new_tab.html
@@ -4,7 +4,8 @@
bookmarkbarattached:bookmarkbarattached;
hasattribution:hasattribution;
anim:anim;
- syncispresent:syncispresent">
+ syncispresent:syncispresent;
+ showsetashomepage:showsetashomepage">
<meta charset="utf-8">
<title i18n-content="title"></title>
@@ -254,6 +255,12 @@ function updateSimpleSection(id, section) {
</div>
<script>updateSimpleSection('sync-status', Section.SYNC);</script>
+ <div id="set-as-home-page">
+ <button class="link">
+ <span class="link-color" i18n-content="makethishomepage"></span>
+ </button>
+ </div>
+
<div id="tip-line"></div>
<script>updateSimpleSection('tip-line', Section.TIPS);</script>
diff --git a/chrome/browser/resources/new_new_tab.js b/chrome/browser/resources/new_new_tab.js
index 7b60721..aecc89a 100644
--- a/chrome/browser/resources/new_new_tab.js
+++ b/chrome/browser/resources/new_new_tab.js
@@ -102,34 +102,20 @@ function tips(data) {
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',
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 @@ function setAsHomePageLinkClicked(e) {
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() {