Index: chrome/browser/ui/webui/history_ui.cc |
=================================================================== |
--- chrome/browser/ui/webui/history_ui.cc (revision 216076) |
+++ chrome/browser/ui/webui/history_ui.cc (working copy) |
@@ -51,6 +51,7 @@ |
#include "grit/generated_resources.h" |
#include "grit/theme_resources.h" |
#include "net/base/escape.h" |
+#include "net/base/net_util.h" |
#include "sync/protocol/history_delete_directive_specifics.pb.h" |
#include "ui/base/l10n/l10n_util.h" |
#include "ui/base/resource/resource_bundle.h" |
@@ -276,7 +277,8 @@ |
BrowsingHistoryHandler::HistoryEntry::EntryType entry_type, |
const GURL& url, const string16& title, base::Time time, |
const std::string& client_id, bool is_search_result, |
- const string16& snippet, bool blocked_visit) { |
+ const string16& snippet, bool blocked_visit, |
+ const std::string& languages) { |
this->entry_type = entry_type; |
this->url = url; |
this->title = title; |
@@ -286,6 +288,7 @@ |
this->is_search_result = is_search_result; |
this->snippet = snippet; |
this->blocked_visit = blocked_visit; |
+ this->languages = languages; |
} |
BrowsingHistoryHandler::HistoryEntry::HistoryEntry() |
@@ -319,12 +322,19 @@ |
result->SetString("title", title_to_set); |
} |
+void BrowsingHistoryHandler::HistoryEntry::SetDisplayableDomain( |
Patrick Dubroy
2013/08/20 14:26:37
I don't see much value in having this as a separat
|
+ DictionaryValue* result) const { |
+ result->SetString("displayableDomain", |
+ net::IDNToUnicode(url.host(), languages)); |
+} |
+ |
scoped_ptr<DictionaryValue> BrowsingHistoryHandler::HistoryEntry::ToValue( |
BookmarkModel* bookmark_model, |
ManagedUserService* managed_user_service, |
const ProfileSyncService* sync_service) const { |
scoped_ptr<DictionaryValue> result(new DictionaryValue()); |
SetUrlAndTitle(result.get()); |
+ SetDisplayableDomain(result.get()); |
result->SetDouble("time", time.ToJsTime()); |
// Pass the timestamps in a list. |
@@ -741,6 +751,7 @@ |
history::QueryResults* results) { |
DCHECK_EQ(0U, query_results_.size()); |
query_results_.reserve(results->size()); |
+ const std::string languages = GetLanguages(); |
for (size_t i = 0; i < results->size(); ++i) { |
history::URLResult const &page = (*results)[i]; |
@@ -754,7 +765,8 @@ |
std::string(), |
!search_text.empty(), |
page.snippet().text(), |
- page.blocked_visit())); |
+ page.blocked_visit(), |
+ languages)); |
} |
results_info_value_.SetString("term", search_text); |
@@ -784,6 +796,7 @@ |
const DictionaryValue* results_value) { |
base::TimeDelta delta = base::TimeTicks::Now() - start_time; |
UMA_HISTOGRAM_TIMES("WebHistory.ResponseTime", delta); |
+ const std::string languages = GetLanguages(); |
// If the response came in too late, do nothing. |
// TODO(dubroy): Maybe show a banner, and prompt the user to reload? |
@@ -851,7 +864,8 @@ |
client_id, |
!search_text.empty(), |
string16(), |
- /* blocked_visit */ false)); |
+ /* blocked_visit */ false, |
+ languages)); |
} |
} |
} else if (results_value) { |
@@ -954,6 +968,12 @@ |
web_ui()->CallJavascriptFunction("historyDeleted"); |
} |
+std::string BrowsingHistoryHandler::GetLanguages() const { |
+ Profile* profile = Profile::FromWebUI(web_ui()); |
+ return profile ? profile->GetPrefs()->GetString(prefs::kAcceptLanguages) : |
Patrick Dubroy
2013/08/20 14:26:37
Nit: looks like this actually fits on one line.
|
+ ""; |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// |
// HistoryUI |