diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-07 06:22:21 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-07 06:22:21 +0000 |
commit | e1406eca301d114eaa3c64efca9ac15978d70c7c (patch) | |
tree | db0465afb544f2680040062bc3437d8e033b7ade /chrome | |
parent | 6f149b3e2d3d4f2522632533ffdf38a64bfcfb63 (diff) | |
download | chromium_src-e1406eca301d114eaa3c64efca9ac15978d70c7c.zip chromium_src-e1406eca301d114eaa3c64efca9ac15978d70c7c.tar.gz chromium_src-e1406eca301d114eaa3c64efca9ac15978d70c7c.tar.bz2 |
Convert browser/dom_ui/[g-m]*.cc to not use wstrings/wchar_t*s.
At least the easy cases anyway.
BUG=23581
TEST=builds and tests pass
Review URL: http://codereview.chromium.org/3094004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55344 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/dom_ui/import_data_handler.cc | 54 | ||||
-rw-r--r-- | chrome/browser/dom_ui/mediaplayer_ui.cc | 11 | ||||
-rw-r--r-- | chrome/browser/dom_ui/most_visited_handler.cc | 90 | ||||
-rw-r--r-- | chrome/browser/dom_ui/most_visited_handler.h | 2 |
4 files changed, 79 insertions, 78 deletions
diff --git a/chrome/browser/dom_ui/import_data_handler.cc b/chrome/browser/dom_ui/import_data_handler.cc index 9aa8d18..73108f4 100644 --- a/chrome/browser/dom_ui/import_data_handler.cc +++ b/chrome/browser/dom_ui/import_data_handler.cc @@ -7,6 +7,7 @@ #include "app/l10n_util.h" #include "base/basictypes.h" #include "base/scoped_ptr.h" +#include "base/string16.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "base/values.h" @@ -31,24 +32,24 @@ void ImportDataHandler::Initialize() { void ImportDataHandler::GetLocalizedValues( DictionaryValue* localized_strings) { DCHECK(localized_strings); - localized_strings->SetString(L"import_data_title", - l10n_util::GetString(IDS_IMPORT_SETTINGS_TITLE)); - localized_strings->SetString(L"import_from_label", - l10n_util::GetString(IDS_IMPORT_FROM_LABEL)); - localized_strings->SetString(L"import_commit", - l10n_util::GetString(IDS_IMPORT_COMMIT)); - localized_strings->SetString(L"import_description", - l10n_util::GetString(IDS_IMPORT_ITEMS_LABEL)); - localized_strings->SetString(L"import_favorites", - l10n_util::GetString(IDS_IMPORT_FAVORITES_CHKBOX)); - localized_strings->SetString(L"import_search", - l10n_util::GetString(IDS_IMPORT_SEARCH_ENGINES_CHKBOX)); - localized_strings->SetString(L"import_passwords", - l10n_util::GetString(IDS_IMPORT_PASSWORDS_CHKBOX)); - localized_strings->SetString(L"import_history", - l10n_util::GetString(IDS_IMPORT_HISTORY_CHKBOX)); - localized_strings->SetString(L"no_profile_found", - l10n_util::GetString(IDS_IMPORT_NO_PROFILE_FOUND)); + localized_strings->SetString("import_data_title", + l10n_util::GetStringUTF16(IDS_IMPORT_SETTINGS_TITLE)); + localized_strings->SetString("import_from_label", + l10n_util::GetStringUTF16(IDS_IMPORT_FROM_LABEL)); + localized_strings->SetString("import_commit", + l10n_util::GetStringUTF16(IDS_IMPORT_COMMIT)); + localized_strings->SetString("import_description", + l10n_util::GetStringUTF16(IDS_IMPORT_ITEMS_LABEL)); + localized_strings->SetString("import_favorites", + l10n_util::GetStringUTF16(IDS_IMPORT_FAVORITES_CHKBOX)); + localized_strings->SetString("import_search", + l10n_util::GetStringUTF16(IDS_IMPORT_SEARCH_ENGINES_CHKBOX)); + localized_strings->SetString("import_passwords", + l10n_util::GetStringUTF16(IDS_IMPORT_PASSWORDS_CHKBOX)); + localized_strings->SetString("import_history", + l10n_util::GetStringUTF16(IDS_IMPORT_HISTORY_CHKBOX)); + localized_strings->SetString("no_profile_found", + l10n_util::GetStringUTF16(IDS_IMPORT_NO_PROFILE_FOUND)); } void ImportDataHandler::RegisterMessages() { @@ -62,10 +63,11 @@ void ImportDataHandler::DetectSupportedBrowsers() { if (profiles_count > 0) { for (int i = 0; i < profiles_count; i++) { - std::wstring profile = importer_host_->GetSourceProfileNameAt(i); + string16 profile = + WideToUTF16Hack(importer_host_->GetSourceProfileNameAt(i)); DictionaryValue* entry = new DictionaryValue(); - entry->SetString(L"name", profile); - entry->SetInteger(L"index", i); + entry->SetString("name", profile); + entry->SetInteger("index", i); supported_browsers.Append(entry); } } @@ -83,7 +85,7 @@ void ImportDataHandler::ImportData(const Value* value) { const ListValue* param_values = static_cast<const ListValue*>(value); std::string string_value; - if(param_values->GetSize() != 1 || + if (param_values->GetSize() != 1 || !param_values->GetString(0, &string_value)) { NOTREACHED(); return; @@ -91,16 +93,16 @@ void ImportDataHandler::ImportData(const Value* value) { int browser_index = string_value[0] - '0'; uint16 items = importer::NONE; - if(string_value[1] == '1') { + if (string_value[1] == '1') { items |= importer::FAVORITES; } - if(string_value[2] == '1') { + if (string_value[2] == '1') { items |= importer::SEARCH_ENGINES; } - if(string_value[3] == '1') { + if (string_value[3] == '1') { items |= importer::PASSWORDS; } - if(string_value[4] == '1') { + if (string_value[4] == '1') { items |= importer::HISTORY; } diff --git a/chrome/browser/dom_ui/mediaplayer_ui.cc b/chrome/browser/dom_ui/mediaplayer_ui.cc index eb8c515..b142559 100644 --- a/chrome/browser/dom_ui/mediaplayer_ui.cc +++ b/chrome/browser/dom_ui/mediaplayer_ui.cc @@ -47,11 +47,10 @@ #include "grit/generated_resources.h" #include "grit/locale_settings.h" -static const std::wstring kPropertyPath = L"path"; -static const std::wstring kPropertyForce = L"force"; -static const std::wstring kPropertyTitle = L"title"; -static const std::wstring kPropertyOffset = L"currentOffset"; -static const std::wstring kPropertyError = L"error"; +static const char kPropertyPath[] = "path"; +static const char kPropertyForce[] = "force"; +static const char kPropertyOffset[] = "currentOffset"; +static const char kPropertyError[] = "error"; const char* kMediaplayerURL = "chrome://mediaplayer"; const char* kMediaplayerPlaylistURL = "chrome://mediaplayer#playlist"; @@ -166,7 +165,7 @@ void MediaplayerUIHTMLSource::StartDataRequest(const std::string& path, DictionaryValue localized_strings; // TODO(dhg): Fix the strings that are currently hardcoded so they // use the localized versions. - localized_strings.SetString(L"errorstring", "Error Playing Back"); + localized_strings.SetString("errorstring", "Error Playing Back"); SetFontAndTextDirection(&localized_strings); diff --git a/chrome/browser/dom_ui/most_visited_handler.cc b/chrome/browser/dom_ui/most_visited_handler.cc index e6e8ac14..1670ac3 100644 --- a/chrome/browser/dom_ui/most_visited_handler.cc +++ b/chrome/browser/dom_ui/most_visited_handler.cc @@ -12,6 +12,7 @@ #include "base/md5.h" #include "base/singleton.h" #include "base/scoped_vector.h" +#include "base/string16.h" #include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "base/thread.h" @@ -52,7 +53,7 @@ const int kMostVisitedScope = 90; // This struct is used when getting the pre-populated pages in case the user // hasn't filled up his most visited pages. struct MostVisitedHandler::MostVisitedPage { - std::wstring title; + string16 title; GURL url; GURL thumbnail_url; GURL favicon_url; @@ -133,11 +134,11 @@ void MostVisitedHandler::HandleGetMostVisited(const Value* value) { void SetDictionaryValue(const history::MostVisitedURL& url, DictionaryValue& dict) { NewTabUI::SetURLTitleAndDirection(&dict, url.title, url.url); - dict.SetString(L"url", url.url.spec()); - dict.SetString(L"faviconUrl", url.favicon_url.spec()); + dict.SetString("url", url.url.spec()); + dict.SetString("faviconUrl", url.favicon_url.spec()); // TODO(Nik): Need thumbnailUrl? // TODO(Nik): Add pinned and blacklisted URLs. - dict.SetBoolean(L"pinned", false); + dict.SetBoolean("pinned", false); } void MostVisitedHandler::SendPagesValue() { @@ -204,7 +205,7 @@ void MostVisitedHandler::HandleRemoveURLsFromBlacklist(const Value* urls) { for (ListValue::const_iterator iter = list->begin(); iter != list->end(); ++iter) { - std::wstring url; + std::string url; bool r = (*iter)->GetAsString(&url); if (!r) { NOTREACHED(); @@ -214,11 +215,11 @@ void MostVisitedHandler::HandleRemoveURLsFromBlacklist(const Value* urls) { dom_ui_->GetProfile()); if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTopSites)) { history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites(); - ts->RemoveBlacklistedURL(GURL(WideToASCII(url))); + ts->RemoveBlacklistedURL(GURL(url)); return; } - r = url_blacklist_->Remove(GetDictionaryKeyForURL(WideToUTF8(url)), NULL); + r = url_blacklist_->Remove(GetDictionaryKeyForURL(url), NULL); DCHECK(r) << "Unknown URL removed from the NTP Most Visited blacklist."; } } @@ -246,15 +247,16 @@ void MostVisitedHandler::HandleAddPinnedURL(const Value* value) { DCHECK_EQ(5U, list->GetSize()) << "Wrong number of params to addPinnedURL"; MostVisitedPage mvp; std::string tmp_string; + string16 tmp_string16; int index; bool r = list->GetString(0, &tmp_string); DCHECK(r) << "Missing URL in addPinnedURL from the NTP Most Visited."; mvp.url = GURL(tmp_string); - r = list->GetString(1, &tmp_string); + r = list->GetString(1, &tmp_string16); DCHECK(r) << "Missing title in addPinnedURL from the NTP Most Visited."; - mvp.title = UTF8ToWide(tmp_string); + mvp.title = tmp_string16; r = list->GetString(2, &tmp_string); DCHECK(r) << "Failed to read the favicon URL in addPinnedURL from the NTP " @@ -291,7 +293,7 @@ void MostVisitedHandler::AddPinnedURL(const MostVisitedPage& page, int index) { DictionaryValue* new_value = new DictionaryValue(); SetMostVisistedPage(new_value, page); - new_value->SetInteger(L"index", index); + new_value->SetInteger("index", index); pinned_urls_->Set(GetDictionaryKeyForURL(page.url.spec()), new_value); // TODO(arv): Notify observers? @@ -321,7 +323,7 @@ void MostVisitedHandler::RemovePinnedURL(const GURL& url) { return; } - const std::wstring key = GetDictionaryKeyForURL(url.spec()); + const std::string key = GetDictionaryKeyForURL(url.spec()); if (pinned_urls_->HasKey(key)) pinned_urls_->Remove(key, NULL); @@ -348,20 +350,20 @@ bool MostVisitedHandler::GetPinnedURLAtIndex(int index, int dict_index; DictionaryValue* dict = static_cast<DictionaryValue*>(value); - if (dict->GetInteger(L"index", &dict_index) && dict_index == index) { + if (dict->GetInteger("index", &dict_index) && dict_index == index) { // The favicon and thumbnail URLs may be empty. std::string tmp_string; - if (dict->GetString(L"faviconUrl", &tmp_string)) + if (dict->GetString("faviconUrl", &tmp_string)) page->favicon_url = GURL(tmp_string); - if (dict->GetString(L"thumbnailUrl", &tmp_string)) + if (dict->GetString("thumbnailUrl", &tmp_string)) page->thumbnail_url = GURL(tmp_string); - if (dict->GetString(L"url", &tmp_string)) + if (dict->GetString("url", &tmp_string)) page->url = GURL(tmp_string); else return false; - return dict->GetString(L"title", &page->title); + return dict->GetString("title", &page->title); } } else { NOTREACHED() << "DictionaryValue iterators are filthy liars."; @@ -412,17 +414,17 @@ void MostVisitedHandler::SetPagesValue(std::vector<PageUsageData*>* data) { mvp.url = page.GetURL(); // Don't include blacklisted or pinned URLs. - std::wstring key = GetDictionaryKeyForURL(mvp.url.spec()); + std::string key = GetDictionaryKeyForURL(mvp.url.spec()); if (pinned_urls_->HasKey(key) || url_blacklist_->HasKey(key)) continue; - mvp.title = UTF16ToWide(page.GetTitle()); + mvp.title = page.GetTitle(); found = true; } while (!found && pre_populated_index < pre_populated_pages.size()) { mvp = pre_populated_pages[pre_populated_index++]; - std::wstring key = GetDictionaryKeyForURL(mvp.url.spec()); + std::string key = GetDictionaryKeyForURL(mvp.url.spec()); if (pinned_urls_->HasKey(key) || url_blacklist_->HasKey(key) || seen_urls.find(mvp.url) != seen_urls.end()) continue; @@ -432,7 +434,7 @@ void MostVisitedHandler::SetPagesValue(std::vector<PageUsageData*>* data) { if (!found && add_chrome_store) { mvp = GetChromeStorePage(); - std::wstring key = GetDictionaryKeyForURL(mvp.url.spec()); + std::string key = GetDictionaryKeyForURL(mvp.url.spec()); if (!pinned_urls_->HasKey(key) && !url_blacklist_->HasKey(key) && seen_urls.find(mvp.url) == seen_urls.end()) { found = true; @@ -444,13 +446,13 @@ void MostVisitedHandler::SetPagesValue(std::vector<PageUsageData*>* data) { // Add fillers as needed. while (pages_value_->GetSize() < output_index) { DictionaryValue* filler_value = new DictionaryValue(); - filler_value->SetBoolean(L"filler", true); + filler_value->SetBoolean("filler", true); pages_value_->Append(filler_value); } DictionaryValue* page_value = new DictionaryValue(); SetMostVisistedPage(page_value, mvp); - page_value->SetBoolean(L"pinned", pinned); + page_value->SetBoolean("pinned", pinned); pages_value_->Append(page_value); most_visited_urls_.push_back(mvp.url); seen_urls.insert(mvp.url); @@ -465,13 +467,13 @@ void MostVisitedHandler::SetPagesValue(std::vector<PageUsageData*>* data) { if (seen_urls.find(chrome_store_page.url) != seen_urls.end()) return; - std::wstring key = GetDictionaryKeyForURL(chrome_store_page.url.spec()); + std::string key = GetDictionaryKeyForURL(chrome_store_page.url.spec()); if (url_blacklist_->HasKey(key)) return; for (int i = kMostVisitedPages - 1; i >= 0; --i) { GURL url = most_visited_urls_[i]; - std::wstring key = GetDictionaryKeyForURL(url.spec()); + std::string key = GetDictionaryKeyForURL(url.spec()); if (!pinned_urls_->HasKey(key)) { // Not pinned, replace. DictionaryValue* page_value = new DictionaryValue(); @@ -491,7 +493,7 @@ void MostVisitedHandler::SetPagesValueFromTopSites( const history::MostVisitedURL& url = data[i]; DictionaryValue* page_value = new DictionaryValue(); if (url.url.is_empty()) { - page_value->SetBoolean(L"filler", true); + page_value->SetBoolean("filler", true); pages_value_->Append(page_value); continue; } @@ -500,25 +502,24 @@ void MostVisitedHandler::SetPagesValueFromTopSites( url.title, url.url); if (!url.favicon_url.is_empty()) - page_value->SetString(L"faviconUrl", url.favicon_url.spec()); + page_value->SetString("faviconUrl", url.favicon_url.spec()); // Special case for prepopulated pages: thumbnailUrl is different from url. - if (url.url.spec() == - WideToASCII(l10n_util::GetString(IDS_CHROME_WELCOME_URL))) { - page_value->SetString(L"thumbnailUrl", + if (url.url.spec() == l10n_util::GetStringUTF8(IDS_CHROME_WELCOME_URL)) { + page_value->SetString("thumbnailUrl", "chrome://theme/IDR_NEWTAB_CHROME_WELCOME_PAGE_THUMBNAIL"); } else if (url.url.spec() == - WideToASCII(l10n_util::GetString(IDS_THEMES_GALLERY_URL))) { - page_value->SetString(L"thumbnailUrl", + l10n_util::GetStringUTF8(IDS_THEMES_GALLERY_URL)) { + page_value->SetString("thumbnailUrl", "chrome://theme/IDR_NEWTAB_THEMES_GALLERY_THUMBNAIL"); } else if (url.url == GetChromeStoreURLWithLocale()) { - page_value->SetString(L"thumbnailUrl", + page_value->SetString("thumbnailUrl", "chrome://theme/IDR_NEWTAB_CHROME_STORE_PAGE_THUMBNAIL"); } history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites(); if (ts->IsURLPinned(url.url)) - page_value->SetBoolean(L"pinned", true); + page_value->SetBoolean("pinned", true); pages_value_->Append(page_value); } } @@ -545,11 +546,11 @@ bool MostVisitedHandler::IsFirstRun() { void MostVisitedHandler::SetMostVisistedPage( DictionaryValue* dict, const MostVisitedHandler::MostVisitedPage& page) { - NewTabUI::SetURLTitleAndDirection(dict, WideToUTF16(page.title), page.url); + NewTabUI::SetURLTitleAndDirection(dict, page.title, page.url); if (!page.favicon_url.is_empty()) - dict->SetString(L"faviconUrl", page.favicon_url.spec()); + dict->SetString("faviconUrl", page.favicon_url.spec()); if (!page.thumbnail_url.is_empty()) - dict->SetString(L"thumbnailUrl", page.thumbnail_url.spec()); + dict->SetString("thumbnailUrl", page.thumbnail_url.spec()); } @@ -561,15 +562,15 @@ const std::vector<MostVisitedHandler::MostVisitedPage>& static std::vector<MostVisitedPage> pages; if (pages.empty()) { MostVisitedPage welcome_page = { - l10n_util::GetString(IDS_NEW_TAB_CHROME_WELCOME_PAGE_TITLE), - GURL(WideToUTF8(l10n_util::GetString(IDS_CHROME_WELCOME_URL))), + l10n_util::GetStringUTF16(IDS_NEW_TAB_CHROME_WELCOME_PAGE_TITLE), + GURL(l10n_util::GetStringUTF8(IDS_CHROME_WELCOME_URL)), GURL("chrome://theme/IDR_NEWTAB_CHROME_WELCOME_PAGE_THUMBNAIL"), GURL("chrome://theme/IDR_NEWTAB_CHROME_WELCOME_PAGE_FAVICON")}; pages.push_back(welcome_page); MostVisitedPage gallery_page = { - l10n_util::GetString(IDS_NEW_TAB_THEMES_GALLERY_PAGE_TITLE), - GURL(WideToUTF8(l10n_util::GetString(IDS_THEMES_GALLERY_URL))), + l10n_util::GetStringUTF16(IDS_NEW_TAB_THEMES_GALLERY_PAGE_TITLE), + GURL(l10n_util::GetStringUTF8(IDS_THEMES_GALLERY_URL)), GURL("chrome://theme/IDR_NEWTAB_THEMES_GALLERY_THUMBNAIL"), GURL("chrome://theme/IDR_NEWTAB_THEMES_GALLERY_FAVICON")}; pages.push_back(gallery_page); @@ -581,7 +582,7 @@ const std::vector<MostVisitedHandler::MostVisitedPage>& // static MostVisitedHandler::MostVisitedPage MostVisitedHandler::GetChromeStorePage() { MostVisitedHandler::MostVisitedPage page = { - l10n_util::GetString(IDS_EXTENSION_WEB_STORE_TITLE), + l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE), GetChromeStoreURLWithLocale(), GURL("chrome://theme/IDR_NEWTAB_CHROME_STORE_PAGE_THUMBNAIL"), GURL("chrome://theme/IDR_NEWTAB_CHROME_STORE_PAGE_FAVICON")}; @@ -615,15 +616,14 @@ void MostVisitedHandler::BlacklistURL(const GURL& url) { RemovePinnedURL(url); - std::wstring key = GetDictionaryKeyForURL(url.spec()); + std::string key = GetDictionaryKeyForURL(url.spec()); if (url_blacklist_->HasKey(key)) return; url_blacklist_->SetBoolean(key, true); } -std::wstring MostVisitedHandler::GetDictionaryKeyForURL( - const std::string& url) { - return ASCIIToWide(MD5String(url)); +std::string MostVisitedHandler::GetDictionaryKeyForURL(const std::string& url) { + return MD5String(url); } // static diff --git a/chrome/browser/dom_ui/most_visited_handler.h b/chrome/browser/dom_ui/most_visited_handler.h index bc6ac80..00a0b6e 100644 --- a/chrome/browser/dom_ui/most_visited_handler.h +++ b/chrome/browser/dom_ui/most_visited_handler.h @@ -90,7 +90,7 @@ class MostVisitedHandler : public DOMMessageHandler, // Returns the key used in url_blacklist_ and pinned_urls_ for the passed // |url|. - std::wstring GetDictionaryKeyForURL(const std::string& url); + std::string GetDictionaryKeyForURL(const std::string& url); // Gets the page data for a pinned URL at a given index. This returns // true if found. |