summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorsky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-11 22:36:47 +0000
committersky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-11 22:36:47 +0000
commit0a0ed3fed8087979a870721eced93aeca5ddbe28 (patch)
treeec1c917398b64e55e8b02c898c768dca1ecff6f5 /chrome/browser
parent699614ff7a85fe28c2a088dc611dac3192bea807 (diff)
downloadchromium_src-0a0ed3fed8087979a870721eced93aeca5ddbe28.zip
chromium_src-0a0ed3fed8087979a870721eced93aeca5ddbe28.tar.gz
chromium_src-0a0ed3fed8087979a870721eced93aeca5ddbe28.tar.bz2
Changes new tab page to show recently closed window correctly.
BUG=4804 TEST=none Review URL: http://codereview.chromium.org/13760 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6836 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.cc6
-rw-r--r--chrome/browser/resources/new_tab.html92
2 files changed, 90 insertions, 8 deletions
diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc
index 440bdd1..3bcf866b 100644
--- a/chrome/browser/dom_ui/new_tab_ui.cc
+++ b/chrome/browser/dom_ui/new_tab_ui.cc
@@ -195,11 +195,13 @@ void NewTabHTMLSource::StartDataRequest(const std::string& path,
l10n_util::GetString(IDS_NEW_TAB_HISTORY_SHOW));
localized_strings.SetString(L"searchhistory",
l10n_util::GetString(IDS_NEW_TAB_HISTORY_SEARCH));
- localized_strings.SetString(L"closedtabs",
- l10n_util::GetString(IDS_NEW_TAB_CLOSED_TABS));
+ localized_strings.SetString(L"recentlyclosed",
+ l10n_util::GetString(IDS_NEW_TAB_RECENTLY_CLOSED));
localized_strings.SetString(L"mostvisitedintro",
l10n_util::GetStringF(IDS_NEW_TAB_MOST_VISITED_INTRO,
l10n_util::GetString(IDS_WELCOME_PAGE_URL)));
+ localized_strings.SetString(L"closedwindow",
+ l10n_util::GetString(IDS_NEW_TAB_RECENTLY_CLOSED_WINDOW));
localized_strings.SetString(L"textdirection",
(l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
diff --git a/chrome/browser/resources/new_tab.html b/chrome/browser/resources/new_tab.html
index dc0516b..eab0ff5 100644
--- a/chrome/browser/resources/new_tab.html
+++ b/chrome/browser/resources/new_tab.html
@@ -33,6 +33,51 @@ var unprocessedData = {
var renderFunctionsDefined = false;
+// TODO(glen): Merge into common file used by this and history.
+var localStrings;
+
+///////////////////////////////////////////////////////////////////////////////
+// localStrings:
+/**
+ * We get strings into the page by using JSTemplate to populate some elements
+ * with localized content, then reading the content of those elements into
+ * this global strings object.
+ * @param {Node} node The DOM node containing all our strings.
+ */
+function LocalStrings(node) {
+ this.strings_ = {};
+
+ var children = node.childNodes;
+ for (var i = 0, child; child = children[i]; i++) {
+ var id = child.id;
+ if (id) {
+ this.strings_[id] = child.innerHTML;
+ }
+ }
+}
+
+/**
+ * Gets a localized string by its id.
+ * @param {string} s The id of the string we want
+ * @return {string} The localized string
+ */
+LocalStrings.prototype.getString = function(s) {
+ return (s in this.strings_) ? this.strings_[s] : '';
+}
+
+/**
+ * Returns a formatted localized string (where all %s contents are replaced
+ * by the second argument).
+ * @param {string} s The id of the string we want
+ * @param {string} d The string to include in the formatted string
+ * @return {string} The formatted string.
+ */
+LocalStrings.prototype.formatString = function(s, d) {
+ return (s in this.strings_) ? this.strings_[s].replace(/\%s/, d) : '';
+}
+
+function $(o) {return document.getElementById(o);}
+
/**
* If the functions that can render content are defined, render
* the content for any data we've received so far.
@@ -235,6 +280,14 @@ a.thumbnail {
text-overflow: ellipsis;
text-decoration:underline;
}
+.recent-window-container {
+ line-height:16px;
+ display:block;
+ margin:3px 0px 3px 22px;
+}
+.recent-window-container img {
+ margin:0 3px -2px 3px;
+}
html[dir='rtl'] .recent-bookmark {
background-position:right;
padding-left:0px;
@@ -293,6 +346,9 @@ html[dir='rtl'] #searches input {
</style>
</head>
<body onload="logEvent('body onload fired');">
+<div id="l10n" style="display:none;">
+ <span id="closedwindow" jscontent="closedwindow">Window</span>
+</div>
<script>
// We apply the size class here so that we don't trigger layout animations onload.
handleWindowResize();
@@ -373,7 +429,7 @@ document.addEventListener('DOMContentLoaded', handleDOMContentLoaded);
</div>
<div id="recentlyClosedTabs" class="sidebar" style="display:none">
- <div class="section-title" jscontent="closedtabs"></div>
+ <div class="section-title" jscontent="recentlyclosed"></div>
<div id="recentlyClosedContainer"></div>
</div>
</td>
@@ -581,7 +637,33 @@ function renderRecentlyClosedTabs(entries) {
section.style.display = 'block';
for (var i = 0; entry = entries[i]; ++i) {
- var link = DOM('a', {href:entry.url, className:'recent-bookmark', title:entry.title});
+ var link;
+
+ if (entry.type == "tab") {
+ // Closed tab.
+ link = DOM('a', {href:entry.url, className:'recent-bookmark', title:entry.title});
+ link.style.backgroundImage = 'url("chrome://favicon/' + entry.url + '")';
+ link.appendChild(document.createTextNode(entry.title));
+ container.appendChild(link);
+ } else {
+ // Closed window.
+ var linkSpanContainer = DOM('div', { className: 'recent-window-container'});
+ var linkSpan = DOM('span');
+ link = DOM('a', { href: "window",
+ title: localStrings.getString('closedWindow') } );
+ link.appendChild(
+ document.createTextNode(localStrings.getString('closedwindow')));
+ linkSpan.appendChild(link);
+ linkSpan.appendChild(document.createTextNode(" ("));
+ for (var windowIndex = 0; windowIndex < entry.tabs.length; windowIndex++) {
+ var tab = entry.tabs[windowIndex];
+ var tabImg = DOM('img', {src:'url("chrome://favicon/' + tab.url + '")', width:16, height:16, });
+ linkSpan.appendChild(tabImg);
+ }
+ linkSpan.appendChild(document.createTextNode(")"));
+ linkSpanContainer.appendChild(linkSpan);
+ container.appendChild(linkSpanContainer);
+ }
link.onclick = function(sessionId) {
return function() {
@@ -592,10 +674,6 @@ function renderRecentlyClosedTabs(entries) {
return false;
}
}(entry.sessionId);
-
- link.style.backgroundImage = 'url("chrome://favicon/' + entry.url + '")';
- link.appendChild(document.createTextNode(entry.title));
- container.appendChild(link);
}
}
@@ -617,6 +695,8 @@ function viewLog() {
logEvent('end of second script block');
+localStrings = new LocalStrings($('l10n'));
+
// We've got all the JS we need, render any unprocessed data.
renderFunctionsDefined = true;
processData();