| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/string_piece.h" | 8 #include "base/string_piece.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/thread.h" | 10 #include "base/thread.h" |
| 11 #include "base/time.h" | 11 #include "base/time.h" |
| 12 #include "base/time_format.h" | 12 #include "base/time_format.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_model.h" | 13 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/dom_ui/dom_ui_favicon_source.h" | 15 #include "chrome/browser/dom_ui/dom_ui_favicon_source.h" |
| 16 #include "chrome/browser/metrics/user_metrics.h" | 16 #include "chrome/browser/metrics/user_metrics.h" |
| 17 #include "chrome/browser/history/history_types.h" | 17 #include "chrome/browser/history/history_types.h" |
| 18 #include "chrome/browser/profile.h" | 18 #include "chrome/browser/profile.h" |
| 19 #include "chrome/common/jstemplate_builder.h" | 19 #include "chrome/common/jstemplate_builder.h" |
| 20 #include "chrome/common/l10n_util.h" | 20 #include "chrome/common/l10n_util.h" |
| 21 #include "chrome/common/notification_service.h" | 21 #include "chrome/common/notification_service.h" |
| 22 #include "chrome/common/resource_bundle.h" | 22 #include "chrome/common/resource_bundle.h" |
| 23 #include "chrome/common/time_format.h" | 23 #include "chrome/common/time_format.h" |
| 24 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
| 25 #include "net/base/escape.h" | 25 #include "net/base/escape.h" |
| 26 | 26 |
| 27 #include "grit/browser_resources.h" | 27 #include "grit/browser_resources.h" |
| 28 #include "grit/chromium_strings.h" | 28 #include "grit/chromium_strings.h" |
| 29 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 30 #include "grit/locale_settings.h" |
| 30 | 31 |
| 31 // Maximum number of search results to return in a given search. We should | 32 // Maximum number of search results to return in a given search. We should |
| 32 // eventually remove this. | 33 // eventually remove this. |
| 33 static const int kMaxSearchResults = 100; | 34 static const int kMaxSearchResults = 100; |
| 34 | 35 |
| 35 //////////////////////////////////////////////////////////////////////////////// | 36 //////////////////////////////////////////////////////////////////////////////// |
| 36 // | 37 // |
| 37 // HistoryHTMLSource | 38 // HistoryHTMLSource |
| 38 // | 39 // |
| 39 //////////////////////////////////////////////////////////////////////////////// | 40 //////////////////////////////////////////////////////////////////////////////// |
| 40 | 41 |
| 41 HistoryUIHTMLSource::HistoryUIHTMLSource() | 42 HistoryUIHTMLSource::HistoryUIHTMLSource() |
| 42 : DataSource(chrome::kChromeUIHistoryHost, MessageLoop::current()) { | 43 : DataSource(chrome::kChromeUIHistoryHost, MessageLoop::current()) { |
| 43 } | 44 } |
| 44 | 45 |
| 45 void HistoryUIHTMLSource::StartDataRequest(const std::string& path, | 46 void HistoryUIHTMLSource::StartDataRequest(const std::string& path, |
| 46 int request_id) { | 47 int request_id) { |
| 47 DictionaryValue localized_strings; | 48 DictionaryValue localized_strings; |
| 49 localized_strings.SetString(L"loading", |
| 50 l10n_util::GetString(IDS_HISTORY_LOADING)); |
| 48 localized_strings.SetString(L"title", | 51 localized_strings.SetString(L"title", |
| 49 l10n_util::GetString(IDS_HISTORY_TITLE)); | 52 l10n_util::GetString(IDS_HISTORY_TITLE)); |
| 50 localized_strings.SetString(L"loading", | 53 localized_strings.SetString(L"loading", |
| 51 l10n_util::GetString(IDS_HISTORY_LOADING)); | 54 l10n_util::GetString(IDS_HISTORY_LOADING)); |
| 52 localized_strings.SetString(L"newest", | 55 localized_strings.SetString(L"newest", |
| 53 l10n_util::GetString(IDS_HISTORY_NEWEST)); | 56 l10n_util::GetString(IDS_HISTORY_NEWEST)); |
| 54 localized_strings.SetString(L"newer", | 57 localized_strings.SetString(L"newer", |
| 55 l10n_util::GetString(IDS_HISTORY_NEWER)); | 58 l10n_util::GetString(IDS_HISTORY_NEWER)); |
| 56 localized_strings.SetString(L"older", | 59 localized_strings.SetString(L"older", |
| 57 l10n_util::GetString(IDS_HISTORY_OLDER)); | 60 l10n_util::GetString(IDS_HISTORY_OLDER)); |
| 58 localized_strings.SetString(L"searchresultsfor", | 61 localized_strings.SetString(L"searchresultsfor", |
| 59 l10n_util::GetString(IDS_HISTORY_SEARCHRESULTSFOR)); | 62 l10n_util::GetString(IDS_HISTORY_SEARCHRESULTSFOR)); |
| 60 localized_strings.SetString(L"history", | 63 localized_strings.SetString(L"history", |
| 61 l10n_util::GetString(IDS_HISTORY_BROWSERESULTS)); | 64 l10n_util::GetString(IDS_HISTORY_BROWSERESULTS)); |
| 62 localized_strings.SetString(L"cont", | 65 localized_strings.SetString(L"cont", |
| 63 l10n_util::GetString(IDS_HISTORY_CONTINUED)); | 66 l10n_util::GetString(IDS_HISTORY_CONTINUED)); |
| 64 localized_strings.SetString(L"searchbutton", | 67 localized_strings.SetString(L"searchbutton", |
| 65 l10n_util::GetString(IDS_HISTORY_SEARCH_BUTTON)); | 68 l10n_util::GetString(IDS_HISTORY_SEARCH_BUTTON)); |
| 66 localized_strings.SetString(L"noresults", | 69 localized_strings.SetString(L"noresults", |
| 67 l10n_util::GetString(IDS_HISTORY_NO_RESULTS)); | 70 l10n_util::GetString(IDS_HISTORY_NO_RESULTS)); |
| 68 localized_strings.SetString(L"noitems", | 71 localized_strings.SetString(L"noitems", |
| 69 l10n_util::GetString(IDS_HISTORY_NO_ITEMS)); | 72 l10n_util::GetString(IDS_HISTORY_NO_ITEMS)); |
| 70 localized_strings.SetString(L"deleteday", | 73 localized_strings.SetString(L"deleteday", |
| 71 l10n_util::GetString(IDS_HISTORY_DELETE_PRIOR_VISITS_LINK)); | 74 l10n_util::GetString(IDS_HISTORY_DELETE_PRIOR_VISITS_LINK)); |
| 72 localized_strings.SetString(L"deletedaywarning", | 75 localized_strings.SetString(L"deletedaywarning", |
| 73 l10n_util::GetString(IDS_HISTORY_DELETE_PRIOR_VISITS_WARNING)); | 76 l10n_util::GetString(IDS_HISTORY_DELETE_PRIOR_VISITS_WARNING)); |
| 74 | 77 |
| 75 localized_strings.SetString(L"textdirection", | 78 SetFontAndTextDirection(&localized_strings); |
| 76 (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? | |
| 77 L"rtl" : L"ltr"); | |
| 78 | 79 |
| 79 static const StringPiece history_html( | 80 static const StringPiece history_html( |
| 80 ResourceBundle::GetSharedInstance().GetRawDataResource( | 81 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 81 IDR_HISTORY_HTML)); | 82 IDR_HISTORY_HTML)); |
| 82 const std::string full_html = jstemplate_builder::GetTemplateHtml( | 83 const std::string full_html = jstemplate_builder::GetTemplateHtml( |
| 83 history_html, &localized_strings, "t"); | 84 history_html, &localized_strings, "t"); |
| 84 | 85 |
| 85 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); | 86 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); |
| 86 html_bytes->data.resize(full_html.size()); | 87 html_bytes->data.resize(full_html.size()); |
| 87 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); | 88 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 NewRunnableMethod(&chrome_url_data_manager, | 370 NewRunnableMethod(&chrome_url_data_manager, |
| 370 &ChromeURLDataManager::AddDataSource, | 371 &ChromeURLDataManager::AddDataSource, |
| 371 html_source)); | 372 html_source)); |
| 372 } | 373 } |
| 373 | 374 |
| 374 // static | 375 // static |
| 375 const GURL HistoryUI::GetHistoryURLWithSearchText(const std::wstring& text) { | 376 const GURL HistoryUI::GetHistoryURLWithSearchText(const std::wstring& text) { |
| 376 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + | 377 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + |
| 377 EscapeQueryParamValue(WideToUTF8(text))); | 378 EscapeQueryParamValue(WideToUTF8(text))); |
| 378 } | 379 } |
| OLD | NEW |