| OLD | NEW |
| 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 #include "chrome/browser/dom_ui/history_ui.h" | 5 #include "chrome/browser/dom_ui/history_ui.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/singleton.h" | 12 #include "base/singleton.h" |
| 13 #include "base/string16.h" |
| 13 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 14 #include "base/string_piece.h" | 15 #include "base/string_piece.h" |
| 15 #include "base/thread.h" | 16 #include "base/thread.h" |
| 16 #include "base/time.h" | 17 #include "base/time.h" |
| 18 #include "base/utf_string_conversions.h" |
| 17 #include "base/values.h" | 19 #include "base/values.h" |
| 18 #include "chrome/browser/bookmarks/bookmark_model.h" | 20 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 19 #include "chrome/browser/browser.h" | 21 #include "chrome/browser/browser.h" |
| 20 #include "chrome/browser/chrome_thread.h" | 22 #include "chrome/browser/chrome_thread.h" |
| 21 #include "chrome/browser/dom_ui/dom_ui_favicon_source.h" | 23 #include "chrome/browser/dom_ui/dom_ui_favicon_source.h" |
| 22 #include "chrome/browser/metrics/user_metrics.h" | 24 #include "chrome/browser/metrics/user_metrics.h" |
| 23 #include "chrome/browser/history/history_types.h" | 25 #include "chrome/browser/history/history_types.h" |
| 24 #include "chrome/browser/profile.h" | 26 #include "chrome/browser/profile.h" |
| 25 #include "chrome/browser/tab_contents/tab_contents.h" | 27 #include "chrome/browser/tab_contents/tab_contents.h" |
| 26 #include "chrome/browser/tab_contents/tab_contents_delegate.h" | 28 #include "chrome/browser/tab_contents/tab_contents_delegate.h" |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 static_cast<int>(page.visit_time().ToTimeT())); | 258 static_cast<int>(page.visit_time().ToTimeT())); |
| 257 | 259 |
| 258 // Until we get some JS i18n infrastructure, we also need to | 260 // Until we get some JS i18n infrastructure, we also need to |
| 259 // pass the dates in as strings. This could use some | 261 // pass the dates in as strings. This could use some |
| 260 // optimization. | 262 // optimization. |
| 261 | 263 |
| 262 // Only pass in the strings we need (search results need a shortdate | 264 // Only pass in the strings we need (search results need a shortdate |
| 263 // and snippet, browse results need day and time information). | 265 // and snippet, browse results need day and time information). |
| 264 if (search_text_.empty()) { | 266 if (search_text_.empty()) { |
| 265 // Figure out the relative date string. | 267 // Figure out the relative date string. |
| 266 std::wstring date_str = TimeFormat::RelativeDate(page.visit_time(), | 268 string16 date_str = TimeFormat::RelativeDate(page.visit_time(), |
| 267 &midnight_today); | 269 &midnight_today); |
| 268 if (date_str.empty()) { | 270 if (date_str.empty()) { |
| 269 date_str = base::TimeFormatFriendlyDate(page.visit_time()); | 271 date_str = |
| 272 WideToUTF16Hack(base::TimeFormatFriendlyDate(page.visit_time())); |
| 270 } else { | 273 } else { |
| 271 date_str = l10n_util::GetStringF( | 274 date_str = l10n_util::GetStringFUTF16( |
| 272 IDS_HISTORY_DATE_WITH_RELATIVE_TIME, | 275 IDS_HISTORY_DATE_WITH_RELATIVE_TIME, |
| 273 date_str, base::TimeFormatFriendlyDate(page.visit_time())); | 276 date_str, |
| 277 WideToUTF16Hack(base::TimeFormatFriendlyDate(page.visit_time()))); |
| 274 } | 278 } |
| 275 page_value->SetString("dateRelativeDay", WideToUTF16Hack(date_str)); | 279 page_value->SetString("dateRelativeDay", date_str); |
| 276 page_value->SetString("dateTimeOfDay", | 280 page_value->SetString("dateTimeOfDay", |
| 277 WideToUTF16Hack(base::TimeFormatTimeOfDay(page.visit_time()))); | 281 WideToUTF16Hack(base::TimeFormatTimeOfDay(page.visit_time()))); |
| 278 } else { | 282 } else { |
| 279 page_value->SetString("dateShort", | 283 page_value->SetString("dateShort", |
| 280 WideToUTF16Hack(base::TimeFormatShortDate(page.visit_time()))); | 284 WideToUTF16Hack(base::TimeFormatShortDate(page.visit_time()))); |
| 281 page_value->SetString("snippet", page.snippet().text()); | 285 page_value->SetString("snippet", page.snippet().text()); |
| 282 } | 286 } |
| 283 page_value->SetBoolean("starred", | 287 page_value->SetBoolean("starred", |
| 284 dom_ui_->GetProfile()->GetBookmarkModel()->IsBookmarked(page.url())); | 288 dom_ui_->GetProfile()->GetBookmarkModel()->IsBookmarked(page.url())); |
| 285 results_value.Append(page_value); | 289 results_value.Append(page_value); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 const GURL HistoryUI::GetHistoryURLWithSearchText(const string16& text) { | 409 const GURL HistoryUI::GetHistoryURLWithSearchText(const string16& text) { |
| 406 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + | 410 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + |
| 407 EscapeQueryParamValue(UTF16ToUTF8(text), true)); | 411 EscapeQueryParamValue(UTF16ToUTF8(text), true)); |
| 408 } | 412 } |
| 409 | 413 |
| 410 // static | 414 // static |
| 411 RefCountedMemory* HistoryUI::GetFaviconResourceBytes() { | 415 RefCountedMemory* HistoryUI::GetFaviconResourceBytes() { |
| 412 return ResourceBundle::GetSharedInstance(). | 416 return ResourceBundle::GetSharedInstance(). |
| 413 LoadDataResourceBytes(IDR_HISTORY_FAVICON); | 417 LoadDataResourceBytes(IDR_HISTORY_FAVICON); |
| 414 } | 418 } |
| OLD | NEW |