diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-30 19:47:47 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-30 19:47:47 +0000 |
commit | e7b418bc2ddad0832b849de9e9594745ee180d03 (patch) | |
tree | 16ad06a92cbfc71e1bc5a4e3254abcb54c40f3c3 /chrome/browser | |
parent | 813fd51fbd13972fb52b46ef7c1606be80af0fd4 (diff) | |
download | chromium_src-e7b418bc2ddad0832b849de9e9594745ee180d03.zip chromium_src-e7b418bc2ddad0832b849de9e9594745ee180d03.tar.gz chromium_src-e7b418bc2ddad0832b849de9e9594745ee180d03.tar.bz2 |
Convert DictionaryValue's keys to std::string (from wstring).
Everything now needs to be changed to avoid the deprecated wstring methods; this
includes the unit tests.
BUG=23581
TEST=all our tests still pass
Review URL: http://codereview.chromium.org/3075010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54359 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/background_contents_service.cc | 2 | ||||
-rw-r--r-- | chrome/browser/browser_theme_pack.cc | 8 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_prefs.cc | 29 | ||||
-rw-r--r-- | chrome/browser/extensions/external_pref_extension_provider.cc | 10 | ||||
-rw-r--r-- | chrome/browser/extensions/sandboxed_extension_unpacker.cc | 7 | ||||
-rw-r--r-- | chrome/browser/geolocation/access_token_store.cc | 2 | ||||
-rw-r--r-- | chrome/browser/geolocation/geolocation_content_settings_map.cc | 10 | ||||
-rw-r--r-- | chrome/browser/history/top_sites.cc | 4 | ||||
-rw-r--r-- | chrome/browser/host_content_settings_map.cc | 18 | ||||
-rw-r--r-- | chrome/browser/host_zoom_map.cc | 6 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_log.cc | 16 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_log.h | 2 | ||||
-rw-r--r-- | chrome/browser/tab_contents/render_view_host_delegate_helper.cc | 2 | ||||
-rw-r--r-- | chrome/browser/webdata/web_database_unittest.cc | 2 |
14 files changed, 59 insertions, 59 deletions
diff --git a/chrome/browser/background_contents_service.cc b/chrome/browser/background_contents_service.cc index c10d9d2..654a0a1 100644 --- a/chrome/browser/background_contents_service.cc +++ b/chrome/browser/background_contents_service.cc @@ -151,7 +151,7 @@ void BackgroundContentsService::LoadBackgroundContentsFromPrefs( CreateBackgroundContents(profile, GURL(url), frame_name, - WideToUTF16(*it)); + UTF8ToUTF16(*it)); } } diff --git a/chrome/browser/browser_theme_pack.cc b/chrome/browser/browser_theme_pack.cc index 943b1e8..8d2fe89 100644 --- a/chrome/browser/browser_theme_pack.cc +++ b/chrome/browser/browser_theme_pack.cc @@ -618,7 +618,7 @@ void BrowserThemePack::BuildTintsFromJSON(DictionaryValue* tints_value) { if (ValidRealValue(tint_list, 0, &hsl.h) && ValidRealValue(tint_list, 1, &hsl.s) && ValidRealValue(tint_list, 2, &hsl.l)) { - int id = GetIntForString(WideToUTF8(*iter), kTintTable); + int id = GetIntForString(*iter, kTintTable); if (id != -1) { temp_tints[id] = hsl; } @@ -689,7 +689,7 @@ void BrowserThemePack::ReadColorsFromJSON( color = SkColorSetRGB(r, g, b); } - int id = GetIntForString(WideToUTF8(*iter), kColorTable); + int id = GetIntForString(*iter, kColorTable); if (id != -1) { (*temp_colors)[id] = color; } @@ -769,7 +769,7 @@ void BrowserThemePack::BuildDisplayPropertiesFromJSON( for (DictionaryValue::key_iterator iter( display_properties_value->begin_keys()); iter != display_properties_value->end_keys(); ++iter) { - int property_id = GetIntForString(WideToUTF8(*iter), kDisplayProperties); + int property_id = GetIntForString(*iter, kDisplayProperties); switch (property_id) { case BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT: { std::string val; @@ -817,7 +817,7 @@ void BrowserThemePack::ParseImageNamesFromJSON( iter != images_value->end_keys(); ++iter) { std::string val; if (images_value->GetString(*iter, &val)) { - int id = GetPersistentIDByName(WideToUTF8(*iter)); + int id = GetPersistentIDByName(*iter); if (id != -1) (*file_paths)[id] = images_path.AppendASCII(val); } diff --git a/chrome/browser/extensions/extension_prefs.cc b/chrome/browser/extensions/extension_prefs.cc index 4006120..8380543 100644 --- a/chrome/browser/extensions/extension_prefs.cc +++ b/chrome/browser/extensions/extension_prefs.cc @@ -82,16 +82,16 @@ namespace { // and http://crbug.com/39745 for more details). static void CleanupBadExtensionKeys(PrefService* prefs) { DictionaryValue* dictionary = prefs->GetMutableDictionary(kExtensionsPref); - std::set<std::wstring> bad_keys; + std::set<std::string> bad_keys; for (DictionaryValue::key_iterator i = dictionary->begin_keys(); i != dictionary->end_keys(); ++i) { - const std::wstring key_name = *i; - if (!Extension::IdIsValid(WideToASCII(key_name))) { + const std::string& key_name(*i); + if (!Extension::IdIsValid(key_name)) { bad_keys.insert(key_name); } } bool dirty = false; - for (std::set<std::wstring>::iterator i = bad_keys.begin(); + for (std::set<std::string>::iterator i = bad_keys.begin(); i != bad_keys.end(); ++i) { dirty = true; dictionary->Remove(*i, NULL); @@ -259,7 +259,7 @@ void ExtensionPrefs::UpdateBlacklist( NOTREACHED() << "Invalid pref for extension " << *extension_id; continue; } - std::string id = WideToASCII(*extension_id); + const std::string& id(*extension_id); if (blacklist_set.find(id) == blacklist_set.end()) { if (!IsBlacklistBitSet(ext)) { // This extension is not in blacklist. And it was not blacklisted @@ -373,10 +373,9 @@ void ExtensionPrefs::GetKilledExtensionIds(std::set<std::string>* killed_ids) { for (DictionaryValue::key_iterator i = dict->begin_keys(); i != dict->end_keys(); ++i) { - std::wstring key_name = *i; - if (!Extension::IdIsValid(WideToASCII(key_name))) { - LOG(WARNING) << "Invalid external extension ID encountered: " - << WideToASCII(key_name); + const std::string& key_name(*i); + if (!Extension::IdIsValid(key_name)) { + LOG(WARNING) << "Invalid external extension ID encountered: " << key_name; continue; } @@ -390,8 +389,7 @@ void ExtensionPrefs::GetKilledExtensionIds(std::set<std::string>* killed_ids) { int state; if (extension->GetInteger(kPrefState, &state) && state == static_cast<int>(Extension::KILLBIT)) { - StringToLowerASCII(&key_name); - killed_ids->insert(WideToASCII(key_name)); + killed_ids->insert(StringToLowerASCII(key_name)); } } } @@ -643,8 +641,7 @@ static ExtensionInfo* GetInstalledExtensionInfoImpl( // Just a warning for now. } - return new ExtensionInfo(manifest, WideToASCII(*extension_id), - FilePath(path), location); + return new ExtensionInfo(manifest, *extension_id, FilePath(path), location); } ExtensionPrefs::ExtensionsInfo* ExtensionPrefs::GetInstalledExtensionsInfo() { @@ -655,7 +652,7 @@ ExtensionPrefs::ExtensionsInfo* ExtensionPrefs::GetInstalledExtensionsInfo() { for (DictionaryValue::key_iterator extension_id( extension_data->begin_keys()); extension_id != extension_data->end_keys(); ++extension_id) { - if (!Extension::IdIsValid(WideToASCII(*extension_id))) + if (!Extension::IdIsValid(*extension_id)) continue; ExtensionInfo* info = GetInstalledExtensionInfoImpl(extension_data.get(), @@ -674,7 +671,7 @@ ExtensionInfo* ExtensionPrefs::GetInstalledExtensionInfo( for (DictionaryValue::key_iterator extension_iter( extension_data->begin_keys()); extension_iter != extension_data->end_keys(); ++extension_iter) { - if (WideToASCII(*extension_iter) == extension_id) { + if (*extension_iter == extension_id) { return GetInstalledExtensionInfoImpl(extension_data.get(), extension_iter); } @@ -762,7 +759,7 @@ std::set<std::string> ExtensionPrefs::GetIdleInstallInfoIds() { for (DictionaryValue::key_iterator iter = extensions->begin_keys(); iter != extensions->end_keys(); ++iter) { - std::string id = WideToASCII(*iter); + const std::string& id(*iter); if (!Extension::IdIsValid(id)) { NOTREACHED(); continue; diff --git a/chrome/browser/extensions/external_pref_extension_provider.cc b/chrome/browser/extensions/external_pref_extension_provider.cc index 5fe39b4..a7c99ff 100644 --- a/chrome/browser/extensions/external_pref_extension_provider.cc +++ b/chrome/browser/extensions/external_pref_extension_provider.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -44,8 +44,8 @@ void ExternalPrefExtensionProvider::VisitRegisteredExtension( Visitor* visitor, const std::set<std::string>& ids_to_ignore) const { for (DictionaryValue::key_iterator i = prefs_->begin_keys(); i != prefs_->end_keys(); ++i) { - const std::wstring& extension_id = *i; - if (ids_to_ignore.find(WideToASCII(extension_id)) != ids_to_ignore.end()) + const std::string& extension_id = *i; + if (ids_to_ignore.find(extension_id) != ids_to_ignore.end()) continue; DictionaryValue* extension; @@ -79,8 +79,8 @@ void ExternalPrefExtensionProvider::VisitRegisteredExtension( scoped_ptr<Version> version; version.reset(Version::GetVersionFromString(external_version)); - visitor->OnExternalExtensionFound(WideToASCII(extension_id), version.get(), - path, Extension::EXTERNAL_PREF); + visitor->OnExternalExtensionFound(extension_id, version.get(), path, + Extension::EXTERNAL_PREF); } } diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker.cc b/chrome/browser/extensions/sandboxed_extension_unpacker.cc index a564d11..de3a8a6 100644 --- a/chrome/browser/extensions/sandboxed_extension_unpacker.cc +++ b/chrome/browser/extensions/sandboxed_extension_unpacker.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,6 +12,7 @@ #include "base/message_loop.h" #include "base/scoped_handle.h" #include "base/task.h" +#include "base/utf_string_conversions.h" // TODO(viettrungluu): delete me. #include "chrome/browser/chrome_thread.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/renderer_host/resource_dispatcher_host.h" @@ -381,7 +382,9 @@ bool SandboxedExtensionUnpacker::RewriteCatalogFiles() { return false; } - FilePath relative_path = FilePath::FromWStringHack(*key_it); + // TODO(viettrungluu): Fix the |FilePath::FromWStringHack(UTF8ToWide())| + // hack and remove the corresponding #include. + FilePath relative_path = FilePath::FromWStringHack(UTF8ToWide(*key_it)); relative_path = relative_path.Append(Extension::kMessagesFilename); if (relative_path.IsAbsolute() || relative_path.ReferencesParent()) { ReportFailure("Invalid path for catalog."); diff --git a/chrome/browser/geolocation/access_token_store.cc b/chrome/browser/geolocation/access_token_store.cc index b0d2d5e..f790c51 100644 --- a/chrome/browser/geolocation/access_token_store.cc +++ b/chrome/browser/geolocation/access_token_store.cc @@ -47,7 +47,7 @@ void ChromePrefsAccessTokenStore::LoadDictionaryStoreInUIThread( if (token_dictionary != NULL) { for (DictionaryValue::key_iterator it = token_dictionary->begin_keys(); it != token_dictionary->end_keys(); ++it) { - GURL url(WideToUTF8(*it)); + GURL url(*it); if (!url.is_valid()) continue; token_dictionary->GetStringAsUTF16WithoutPathExpansion( diff --git a/chrome/browser/geolocation/geolocation_content_settings_map.cc b/chrome/browser/geolocation/geolocation_content_settings_map.cc index 2723870..77fb103 100644 --- a/chrome/browser/geolocation/geolocation_content_settings_map.cc +++ b/chrome/browser/geolocation/geolocation_content_settings_map.cc @@ -92,13 +92,13 @@ GeolocationContentSettingsMap::AllOriginsSettings if (all_settings_dictionary != NULL) { for (DictionaryValue::key_iterator i(all_settings_dictionary->begin_keys()); i != all_settings_dictionary->end_keys(); ++i) { - const std::wstring& wide_origin(*i); - GURL origin_as_url(WideToUTF8(wide_origin)); + const std::string& origin(*i); + GURL origin_as_url(origin); if (!origin_as_url.is_valid()) continue; DictionaryValue* requesting_origin_settings_dictionary = NULL; bool found = all_settings_dictionary->GetDictionaryWithoutPathExpansion( - wide_origin, &requesting_origin_settings_dictionary); + origin, &requesting_origin_settings_dictionary); DCHECK(found); if (!requesting_origin_settings_dictionary) continue; @@ -177,11 +177,11 @@ void GeolocationContentSettingsMap::GetOneOriginSettingsFromDictionary( OneOriginSettings* one_origin_settings) { for (DictionaryValue::key_iterator i(dictionary->begin_keys()); i != dictionary->end_keys(); ++i) { - const std::wstring& target(*i); + const std::string& target(*i); int setting = kDefaultSetting; bool found = dictionary->GetIntegerWithoutPathExpansion(target, &setting); DCHECK(found); - GURL target_url(WideToUTF8(target)); + GURL target_url(target); // An empty URL has a special meaning (wildcard), so only accept invalid // URLs if the original version was empty (avoids treating corrupted prefs // as the wildcard entry; see http://crbug.com/39685) diff --git a/chrome/browser/history/top_sites.cc b/chrome/browser/history/top_sites.cc index 324f207..2e4fbb0 100644 --- a/chrome/browser/history/top_sites.cc +++ b/chrome/browser/history/top_sites.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -730,7 +730,7 @@ bool TopSites::GetPinnedURLAtIndex(size_t index, GURL* url) { int current_index; if (pinned_urls_->GetIntegerWithoutPathExpansion(*it, ¤t_index)) { if (static_cast<size_t>(current_index) == index) { - *url = GURL(WideToASCII(*it)); + *url = GURL(*it); return true; } } diff --git a/chrome/browser/host_content_settings_map.cc b/chrome/browser/host_content_settings_map.cc index f09ac13..ce53c2d 100644 --- a/chrome/browser/host_content_settings_map.cc +++ b/chrome/browser/host_content_settings_map.cc @@ -152,11 +152,11 @@ HostContentSettingsMap::HostContentSettingsMap(Profile* profile) prefs->GetDictionary(prefs::kPerHostContentSettings); for (DictionaryValue::key_iterator i(all_settings_dictionary->begin_keys()); i != all_settings_dictionary->end_keys(); ++i) { - std::wstring wide_host(*i); - Pattern pattern(std::string(kDomainWildcard) + WideToUTF8(wide_host)); + const std::string& host(*i); + Pattern pattern(std::string(kDomainWildcard) + host); DictionaryValue* host_settings_dictionary = NULL; bool found = all_settings_dictionary->GetDictionaryWithoutPathExpansion( - wide_host, &host_settings_dictionary); + host, &host_settings_dictionary); DCHECK(found); ContentSettings settings; GetSettingsFromDictionary(host_settings_dictionary, &settings); @@ -570,14 +570,14 @@ void HostContentSettingsMap::GetSettingsFromDictionary( ContentSettings* settings) { for (DictionaryValue::key_iterator i(dictionary->begin_keys()); i != dictionary->end_keys(); ++i) { - std::wstring content_type(*i); + const std::string& content_type(*i); int setting = CONTENT_SETTING_DEFAULT; bool found = dictionary->GetIntegerWithoutPathExpansion(content_type, &setting); DCHECK(found); for (size_t type = 0; type < arraysize(kTypeNames); ++type) { if ((kTypeNames[type] != NULL) && - (std::wstring(kTypeNames[type]) == content_type)) { + (WideToUTF8(kTypeNames[type]) == content_type)) { settings->settings[type] = IntToContentSetting(setting); break; } @@ -634,16 +634,16 @@ void HostContentSettingsMap::ReadExceptions(bool overwrite) { if (all_settings_dictionary != NULL) { for (DictionaryValue::key_iterator i(all_settings_dictionary->begin_keys()); i != all_settings_dictionary->end_keys(); ++i) { - std::wstring wide_pattern(*i); - if (!Pattern(WideToUTF8(wide_pattern)).IsValid()) + const std::string& pattern(*i); + if (!Pattern(pattern).IsValid()) LOG(WARNING) << "Invalid pattern stored in content settings"; DictionaryValue* pattern_settings_dictionary = NULL; bool found = all_settings_dictionary->GetDictionaryWithoutPathExpansion( - wide_pattern, &pattern_settings_dictionary); + pattern, &pattern_settings_dictionary); DCHECK(found); ContentSettings settings; GetSettingsFromDictionary(pattern_settings_dictionary, &settings); - host_content_settings_[WideToUTF8(wide_pattern)] = settings; + host_content_settings_[pattern] = settings; } } } diff --git a/chrome/browser/host_zoom_map.cc b/chrome/browser/host_zoom_map.cc index 50e1519..512fdf0 100644 --- a/chrome/browser/host_zoom_map.cc +++ b/chrome/browser/host_zoom_map.cc @@ -42,12 +42,12 @@ void HostZoomMap::Load() { if (host_zoom_dictionary != NULL) { for (DictionaryValue::key_iterator i(host_zoom_dictionary->begin_keys()); i != host_zoom_dictionary->end_keys(); ++i) { - std::wstring wide_host(*i); + const std::string& host(*i); int zoom_level = 0; bool success = host_zoom_dictionary->GetIntegerWithoutPathExpansion( - wide_host, &zoom_level); + host, &zoom_level); DCHECK(success); - host_zoom_levels_[WideToUTF8(wide_host)] = zoom_level; + host_zoom_levels_[host] = zoom_level; } } } diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc index 7384a2a..9b51cfa 100644 --- a/chrome/browser/metrics/metrics_log.cc +++ b/chrome/browser/metrics/metrics_log.cc @@ -354,10 +354,10 @@ void MetricsLog::RecordEnvironment( void MetricsLog::WriteAllProfilesMetrics( const DictionaryValue& all_profiles_metrics) { - const std::wstring profile_prefix(prefs::kProfilePrefix); + const std::string profile_prefix(WideToUTF8(prefs::kProfilePrefix)); for (DictionaryValue::key_iterator i = all_profiles_metrics.begin_keys(); i != all_profiles_metrics.end_keys(); ++i) { - const std::wstring& key_name = *i; + const std::string& key_name = *i; if (key_name.compare(0, profile_prefix.size(), profile_prefix) == 0) { DictionaryValue* profile; if (all_profiles_metrics.GetDictionaryWithoutPathExpansion(key_name, @@ -367,21 +367,21 @@ void MetricsLog::WriteAllProfilesMetrics( } } -void MetricsLog::WriteProfileMetrics(const std::wstring& profileidhash, +void MetricsLog::WriteProfileMetrics(const std::string& profileidhash, const DictionaryValue& profile_metrics) { OPEN_ELEMENT_FOR_SCOPE("userprofile"); - WriteAttribute("profileidhash", WideToUTF8(profileidhash)); + WriteAttribute("profileidhash", profileidhash); for (DictionaryValue::key_iterator i = profile_metrics.begin_keys(); i != profile_metrics.end_keys(); ++i) { Value* value; if (profile_metrics.GetWithoutPathExpansion(*i, &value)) { - DCHECK(*i != L"id"); + DCHECK(*i != "id"); switch (value->GetType()) { case Value::TYPE_STRING: { std::string string_value; if (value->GetAsString(&string_value)) { OPEN_ELEMENT_FOR_SCOPE("profileparam"); - WriteAttribute("name", WideToUTF8(*i)); + WriteAttribute("name", *i); WriteAttribute("value", string_value); } break; @@ -391,7 +391,7 @@ void MetricsLog::WriteProfileMetrics(const std::wstring& profileidhash, bool bool_value; if (value->GetAsBoolean(&bool_value)) { OPEN_ELEMENT_FOR_SCOPE("profileparam"); - WriteAttribute("name", WideToUTF8(*i)); + WriteAttribute("name", *i); WriteIntAttribute("value", bool_value ? 1 : 0); } break; @@ -401,7 +401,7 @@ void MetricsLog::WriteProfileMetrics(const std::wstring& profileidhash, int int_value; if (value->GetAsInteger(&int_value)) { OPEN_ELEMENT_FOR_SCOPE("profileparam"); - WriteAttribute("name", WideToUTF8(*i)); + WriteAttribute("name", *i); WriteIntAttribute("value", int_value); } break; diff --git a/chrome/browser/metrics/metrics_log.h b/chrome/browser/metrics/metrics_log.h index eb8e67f..081d4b1 100644 --- a/chrome/browser/metrics/metrics_log.h +++ b/chrome/browser/metrics/metrics_log.h @@ -93,7 +93,7 @@ class MetricsLog : public MetricsLogBase { // Writes metrics for the profile identified by key. This writes all // key/value pairs in profile_metrics. - void WriteProfileMetrics(const std::wstring& key, + void WriteProfileMetrics(const std::string& key, const DictionaryValue& profile_metrics); DISALLOW_COPY_AND_ASSIGN(MetricsLog); diff --git a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc index 48b766a..779faad 100644 --- a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc +++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc @@ -222,7 +222,7 @@ WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs( std::string value; if (inspector_settings->GetStringWithoutPathExpansion(*iter, &value)) web_prefs.inspector_settings.push_back( - std::make_pair(WideToUTF8(*iter), value)); + std::make_pair(*iter, value)); } } web_prefs.tabs_to_links = prefs->GetBoolean(prefs::kWebkitTabsToLinks); diff --git a/chrome/browser/webdata/web_database_unittest.cc b/chrome/browser/webdata/web_database_unittest.cc index 59a2cfa6..d17d8e8 100644 --- a/chrome/browser/webdata/web_database_unittest.cc +++ b/chrome/browser/webdata/web_database_unittest.cc @@ -128,7 +128,7 @@ class WebDatabaseTest : public testing::Test { int b_count = GetKeyCount(b); DictionaryValue::key_iterator i(a.begin_keys()); DictionaryValue::key_iterator e(a.end_keys()); - std::wstring av, bv; + std::string av, bv; while (i != e) { if (!(a.GetStringWithoutPathExpansion(*i, &av)) || !(b.GetStringWithoutPathExpansion(*i, &bv)) || |