summaryrefslogtreecommitdiffstats
path: root/chrome/browser/dom_ui
diff options
context:
space:
mode:
authordsh@google.com <dsh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 21:49:53 +0000
committerdsh@google.com <dsh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 21:49:53 +0000
commit3a79b3cc8393d54d72c8c7e14615fe64d86fd039 (patch)
tree2730ef27672c8f9c9e1b6ef3f443434ac98bfd4f /chrome/browser/dom_ui
parent1c9e90e17741f9c34f4cbe7f3e68a8300ed24e08 (diff)
downloadchromium_src-3a79b3cc8393d54d72c8c7e14615fe64d86fd039.zip
chromium_src-3a79b3cc8393d54d72c8c7e14615fe64d86fd039.tar.gz
chromium_src-3a79b3cc8393d54d72c8c7e14615fe64d86fd039.tar.bz2
Port DictionaryValue to use string16 instead of wstring.
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=10818 Review URL: http://codereview.chromium.org/31014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10833 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r--chrome/browser/dom_ui/dom_ui.cc4
-rw-r--r--chrome/browser/dom_ui/history_ui.cc74
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.cc105
3 files changed, 102 insertions, 81 deletions
diff --git a/chrome/browser/dom_ui/dom_ui.cc b/chrome/browser/dom_ui/dom_ui.cc
index b0efcad..23ac2c3 100644
--- a/chrome/browser/dom_ui/dom_ui.cc
+++ b/chrome/browser/dom_ui/dom_ui.cc
@@ -111,7 +111,7 @@ void DOMMessageHandler::SetURLAndTitle(DictionaryValue* dictionary,
std::wstring title,
const GURL& gurl) {
std::wstring wstring_url = UTF8ToWide(gurl.spec());
- dictionary->SetString(L"url", wstring_url);
+ dictionary->SetString(ASCIIToUTF16("url"), WideToUTF16Hack(wstring_url));
bool using_url_as_the_title = false;
if (title.empty()) {
@@ -133,7 +133,7 @@ void DOMMessageHandler::SetURLAndTitle(DictionaryValue* dictionary,
DCHECK(success ? (title != title_to_set) : (title == title_to_set));
}
}
- dictionary->SetString(L"title", title_to_set);
+ dictionary->SetString(ASCIIToUTF16("title"), WideToUTF16Hack(title_to_set));
}
bool DOMMessageHandler::ExtractIntegerValue(const Value* value, int* out_int) {
diff --git a/chrome/browser/dom_ui/history_ui.cc b/chrome/browser/dom_ui/history_ui.cc
index 9bc5d61..2423458 100644
--- a/chrome/browser/dom_ui/history_ui.cc
+++ b/chrome/browser/dom_ui/history_ui.cc
@@ -49,32 +49,34 @@ HistoryUIHTMLSource::HistoryUIHTMLSource()
void HistoryUIHTMLSource::StartDataRequest(const std::string& path,
int request_id) {
DictionaryValue localized_strings;
- localized_strings.SetString(L"title",
- l10n_util::GetString(IDS_HISTORY_TITLE));
- localized_strings.SetString(L"loading",
- l10n_util::GetString(IDS_HISTORY_LOADING));
- localized_strings.SetString(L"newest",
- l10n_util::GetString(IDS_HISTORY_NEWEST));
- localized_strings.SetString(L"newer",
- l10n_util::GetString(IDS_HISTORY_NEWER));
- localized_strings.SetString(L"older",
- l10n_util::GetString(IDS_HISTORY_OLDER));
- localized_strings.SetString(L"searchresultsfor",
- l10n_util::GetString(IDS_HISTORY_SEARCHRESULTSFOR));
- localized_strings.SetString(L"history",
- l10n_util::GetString(IDS_HISTORY_BROWSERESULTS));
- localized_strings.SetString(L"cont",
- l10n_util::GetString(IDS_HISTORY_CONTINUED));
- localized_strings.SetString(L"searchbutton",
- l10n_util::GetString(IDS_HISTORY_SEARCH_BUTTON));
- localized_strings.SetString(L"noresults",
- l10n_util::GetString(IDS_HISTORY_NO_RESULTS));
- localized_strings.SetString(L"noitems",
- l10n_util::GetString(IDS_HISTORY_NO_ITEMS));
- localized_strings.SetString(L"deleteday",
- l10n_util::GetString(IDS_HISTORY_DELETE_PRIOR_VISITS_LINK));
- localized_strings.SetString(L"deletedaywarning",
- l10n_util::GetString(IDS_HISTORY_DELETE_PRIOR_VISITS_WARNING));
+ localized_strings.SetString(ASCIIToUTF16("title"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_TITLE)));
+ localized_strings.SetString(ASCIIToUTF16("loading"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_LOADING)));
+ localized_strings.SetString(ASCIIToUTF16("newest"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_NEWEST)));
+ localized_strings.SetString(ASCIIToUTF16("newer"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_NEWER)));
+ localized_strings.SetString(ASCIIToUTF16("older"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_OLDER)));
+ localized_strings.SetString(ASCIIToUTF16("searchresultsfor"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_SEARCHRESULTSFOR)));
+ localized_strings.SetString(ASCIIToUTF16("history"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_BROWSERESULTS)));
+ localized_strings.SetString(ASCIIToUTF16("cont"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_CONTINUED)));
+ localized_strings.SetString(ASCIIToUTF16("searchbutton"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_SEARCH_BUTTON)));
+ localized_strings.SetString(ASCIIToUTF16("noresults"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_NO_RESULTS)));
+ localized_strings.SetString(ASCIIToUTF16("noitems"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_NO_ITEMS)));
+ localized_strings.SetString(ASCIIToUTF16("deleteday"),
+ WideToUTF16Hack(
+ l10n_util::GetString(IDS_HISTORY_DELETE_PRIOR_VISITS_LINK)));
+ localized_strings.SetString(ASCIIToUTF16("deletedaywarning"),
+ WideToUTF16Hack(
+ l10n_util::GetString(IDS_HISTORY_DELETE_PRIOR_VISITS_WARNING)));
static const StringPiece history_html(
ResourceBundle::GetSharedInstance().GetRawDataResource(
@@ -226,7 +228,7 @@ void BrowsingHistoryHandler::QueryComplete(
SetURLAndTitle(page_value, page.title(), page.url());
// Need to pass the time in epoch time (fastest JS conversion).
- page_value->SetInteger(L"time",
+ page_value->SetInteger(ASCIIToUTF16("time"),
static_cast<int>(page.visit_time().ToTimeT()));
// Until we get some JS i18n infrastructure, we also need to
@@ -246,15 +248,19 @@ void BrowsingHistoryHandler::QueryComplete(
IDS_HISTORY_DATE_WITH_RELATIVE_TIME,
date_str, base::TimeFormatFriendlyDate(page.visit_time()));
}
- page_value->SetString(L"dateRelativeDay", date_str);
- page_value->SetString(L"dateTimeOfDay",
- base::TimeFormatTimeOfDay(page.visit_time()));
+ page_value->SetString(ASCIIToUTF16("dateRelativeDay"),
+ WideToUTF16Hack(date_str));
+ page_value->SetString(
+ ASCIIToUTF16("dateTimeOfDay"),
+ WideToUTF16Hack(base::TimeFormatTimeOfDay(page.visit_time())));
} else {
- page_value->SetString(L"dateShort",
- base::TimeFormatShortDate(page.visit_time()));
- page_value->SetString(L"snippet", page.snippet().text());
+ page_value->SetString(
+ ASCIIToUTF16("dateShort"),
+ WideToUTF16Hack(base::TimeFormatShortDate(page.visit_time())));
+ page_value->SetString(
+ ASCIIToUTF16("snippet"), WideToUTF16Hack(page.snippet().text()));
}
- page_value->SetBoolean(L"starred",
+ page_value->SetBoolean(ASCIIToUTF16("starred"),
dom_ui_->get_profile()->GetBookmarkModel()->IsBookmarked(page.url()));
results_value.Append(page_value);
}
diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc
index afb7baa..1195cc9 100644
--- a/chrome/browser/dom_ui/new_tab_ui.cc
+++ b/chrome/browser/dom_ui/new_tab_ui.cc
@@ -125,14 +125,14 @@ class PaintTimer : public RenderWidgetHost::PaintObserver {
void SetURLTitleAndDirection(DictionaryValue* dictionary,
const std::wstring& title,
const GURL& gurl) {
- std::wstring wstring_url = UTF8ToWide(gurl.spec());
- dictionary->SetString(L"url", wstring_url);
+ string16 string_url = UTF8ToUTF16(gurl.spec());
+ dictionary->SetString(ASCIIToUTF16("url"), string_url);
bool using_url_as_the_title = false;
std::wstring title_to_set(title);
if (title_to_set.empty()) {
using_url_as_the_title = true;
- title_to_set = wstring_url;
+ title_to_set = UTF16ToWideHack(string_url);
}
// We set the "dir" attribute of the title, so that in RTL locales, a LTR
@@ -168,8 +168,8 @@ void SetURLTitleAndDirection(DictionaryValue* dictionary,
}
}
}
- dictionary->SetString(L"title", title_to_set);
- dictionary->SetString(L"direction", direction);
+ dictionary->SetString(ASCIIToUTF16("title"), WideToUTF16Hack(title_to_set));
+ dictionary->SetString(ASCIIToUTF16("direction"), WideToUTF16Hack(direction));
}
} // end anonymous namespace
@@ -208,35 +208,43 @@ void NewTabHTMLSource::StartDataRequest(const std::string& path,
profile_name);
}
DictionaryValue localized_strings;
- localized_strings.SetString(L"title", title);
- localized_strings.SetString(L"mostvisited", most_visited);
- localized_strings.SetString(L"searches",
- l10n_util::GetString(IDS_NEW_TAB_SEARCHES));
- localized_strings.SetString(L"bookmarks",
- l10n_util::GetString(IDS_NEW_TAB_BOOKMARKS));
- localized_strings.SetString(L"showhistory",
- 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"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) ?
- kRTLHtmlTextDirection : kDefaultHtmlTextDirection);
+ localized_strings.SetString(ASCIIToUTF16("title"), WideToUTF16Hack(title));
+ localized_strings.SetString(ASCIIToUTF16("mostvisited"),
+ WideToUTF16Hack(most_visited));
+ localized_strings.SetString(ASCIIToUTF16("searches"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_SEARCHES)));
+ localized_strings.SetString(ASCIIToUTF16("bookmarks"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_BOOKMARKS)));
+ localized_strings.SetString(ASCIIToUTF16("showhistory"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_HISTORY_SHOW)));
+ localized_strings.SetString(ASCIIToUTF16("searchhistory"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_HISTORY_SEARCH)));
+ localized_strings.SetString(ASCIIToUTF16("recentlyclosed"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_RECENTLY_CLOSED)));
+ localized_strings.SetString(
+ ASCIIToUTF16("mostvisitedintro"),
+ WideToUTF16Hack(l10n_util::GetStringF(
+ IDS_NEW_TAB_MOST_VISITED_INTRO,
+ l10n_util::GetString(IDS_WELCOME_PAGE_URL))));
+ localized_strings.SetString(
+ ASCIIToUTF16("closedwindow"),
+ WideToUTF16Hack(
+ l10n_util::GetString(IDS_NEW_TAB_RECENTLY_CLOSED_WINDOW)));
+
+ localized_strings.SetString(
+ ASCIIToUTF16("textdirection"),
+ WideToUTF16Hack(
+ (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
+ kRTLHtmlTextDirection : kDefaultHtmlTextDirection));
// Let the tab know whether it's the first tab being viewed.
- localized_strings.SetString(L"firstview",
- first_view_ ? L"true" : std::wstring());
+ localized_strings.SetString(ASCIIToUTF16("firstview"),
+ first_view_ ? ASCIIToUTF16("true") : string16());
first_view_ = false;
#ifdef CHROME_PERSONALIZATION
- localized_strings.SetString(L"p13nsrc", Personalization::GetNewTabSource());
+ localized_strings.SetString(ASCIIToUTF16("p13nsrc"),
+ Personalization::GetNewTabSource());
#endif
static const StringPiece new_tab_html(
@@ -263,15 +271,19 @@ IncognitoTabHTMLSource::IncognitoTabHTMLSource()
void IncognitoTabHTMLSource::StartDataRequest(const std::string& path,
int request_id) {
DictionaryValue localized_strings;
- localized_strings.SetString(L"title",
- l10n_util::GetString(IDS_NEW_TAB_TITLE));
- localized_strings.SetString(L"content",
- l10n_util::GetStringF(IDS_NEW_TAB_OTR_MESSAGE,
- l10n_util::GetString(IDS_LEARN_MORE_INCOGNITO_URL)));
-
- localized_strings.SetString(L"textdirection",
- (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
- kRTLHtmlTextDirection : kDefaultHtmlTextDirection);
+ localized_strings.SetString(ASCIIToUTF16("title"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_TITLE)));
+ localized_strings.SetString(
+ ASCIIToUTF16("content"),
+ WideToUTF16Hack(l10n_util::GetStringF(
+ IDS_NEW_TAB_OTR_MESSAGE,
+ l10n_util::GetString(IDS_LEARN_MORE_INCOGNITO_URL))));
+
+ localized_strings.SetString(
+ ASCIIToUTF16("textdirection"),
+ WideToUTF16Hack(
+ (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
+ kRTLHtmlTextDirection : kDefaultHtmlTextDirection));
static const StringPiece incognito_tab_html(
ResourceBundle::GetSharedInstance().GetRawDataResource(
@@ -481,12 +493,15 @@ void TemplateURLHandler::OnTemplateURLModelChanged() {
if (!urlref)
continue;
DictionaryValue* entry_value = new DictionaryValue;
- entry_value->SetString(L"short_name", urls[i]->short_name());
- entry_value->SetString(L"keyword", urls[i]->keyword());
+ entry_value->SetString(ASCIIToUTF16("short_name"),
+ WideToUTF16Hack(urls[i]->short_name()));
+ entry_value->SetString(ASCIIToUTF16("keyword"),
+ WideToUTF16Hack(urls[i]->keyword()));
const GURL& url = urls[i]->GetFavIconURL();
if (url.is_valid())
- entry_value->SetString(L"favIconURL", UTF8ToWide(url.spec()));
+ entry_value->SetString(ASCIIToUTF16("favIconURL"),
+ UTF8ToUTF16(url.spec()));
urls_value.Append(entry_value);
}
@@ -645,7 +660,7 @@ void RecentlyClosedTabsHandler::TabRestoreServiceChanged(
(entry->type == TabRestoreService::WINDOW &&
WindowToValue(*static_cast<TabRestoreService::Window*>(entry),
value))) {
- value->SetInteger(L"sessionId", entry->id);
+ value->SetInteger(ASCIIToUTF16("sessionId"), entry->id);
list_value.Append(value);
added_count++;
} else {
@@ -673,7 +688,7 @@ bool RecentlyClosedTabsHandler::TabToValue(
SetURLTitleAndDirection(dictionary, current_navigation.title(),
current_navigation.url());
- dictionary->SetString(L"type", L"tab");
+ dictionary->SetString(ASCIIToUTF16("type"), ASCIIToUTF16("tab"));
return true;
}
@@ -698,8 +713,8 @@ bool RecentlyClosedTabsHandler::WindowToValue(
return false;
}
- dictionary->SetString(L"type", L"window");
- dictionary->Set(L"tabs", tab_values);
+ dictionary->SetString(ASCIIToUTF16("type"), ASCIIToUTF16("window"));
+ dictionary->Set(ASCIIToUTF16("tabs"), tab_values);
return true;
}