summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-30 19:47:47 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-30 19:47:47 +0000
commite7b418bc2ddad0832b849de9e9594745ee180d03 (patch)
tree16ad06a92cbfc71e1bc5a4e3254abcb54c40f3c3 /chrome/common/extensions
parent813fd51fbd13972fb52b46ef7c1606be80af0fd4 (diff)
downloadchromium_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/common/extensions')
-rw-r--r--chrome/common/extensions/extension.cc13
-rw-r--r--chrome/common/extensions/extension_message_bundle.cc15
-rw-r--r--chrome/common/extensions/extension_message_bundle.h4
3 files changed, 17 insertions, 15 deletions
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index d32ef66..6d6c05d 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -514,11 +514,12 @@ ExtensionAction* Extension::LoadExtensionActionHelper(
bool Extension::ContainsNonThemeKeys(const DictionaryValue& source) {
// Generate a map of allowable keys
- static std::map<std::wstring, bool> theme_keys;
+ static std::map<std::string, bool> theme_keys;
static bool theme_key_mapped = false;
if (!theme_key_mapped) {
for (size_t i = 0; i < arraysize(kValidThemeKeys); ++i) {
- theme_keys[kValidThemeKeys[i]] = true;
+ // TODO(viettrungluu): Make the constants |char*|s and avoid converting.
+ theme_keys[WideToUTF8(kValidThemeKeys[i])] = true;
}
theme_key_mapped = true;
}
@@ -1454,7 +1455,7 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key,
// Validate that the overrides are all strings
for (DictionaryValue::key_iterator iter = overrides->begin_keys();
iter != overrides->end_keys(); ++iter) {
- std::string page = WideToUTF8(*iter);
+ std::string page = *iter;
std::string val;
// Restrict override pages to a list of supported URLs.
if ((page != chrome::kChromeUINewTabHost &&
@@ -1529,6 +1530,8 @@ GURL Extension::GalleryUrl() const {
std::set<FilePath> Extension::GetBrowserImages() {
std::set<FilePath> image_paths;
+ // TODO(viettrungluu): These |FilePath::FromWStringHack(UTF8ToWide())|
+ // indicate that we're doing something wrong.
// Extension icons.
for (std::map<int, std::string>::iterator iter = icons_.begin();
@@ -1541,9 +1544,9 @@ std::set<FilePath> Extension::GetBrowserImages() {
if (theme_images) {
for (DictionaryValue::key_iterator it = theme_images->begin_keys();
it != theme_images->end_keys(); ++it) {
- std::wstring val;
+ std::string val;
if (theme_images->GetStringWithoutPathExpansion(*it, &val))
- image_paths.insert(FilePath::FromWStringHack(val));
+ image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(val)));
}
}
diff --git a/chrome/common/extensions/extension_message_bundle.cc b/chrome/common/extensions/extension_message_bundle.cc
index 6b001b1..04022cd 100644
--- a/chrome/common/extensions/extension_message_bundle.cc
+++ b/chrome/common/extensions/extension_message_bundle.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.
@@ -73,7 +73,7 @@ bool ExtensionMessageBundle::Init(const CatalogVector& locale_catalogs,
DictionaryValue* catalog = (*it).get();
for (DictionaryValue::key_iterator key_it = catalog->begin_keys();
key_it != catalog->end_keys(); ++key_it) {
- std::string key(StringToLowerASCII(WideToUTF8(*key_it)));
+ std::string key(StringToLowerASCII(*key_it));
if (!IsValidName(*key_it))
return BadKeyMessage(key, error);
std::string value;
@@ -126,14 +126,13 @@ bool ExtensionMessageBundle::AppendReservedMessagesForLocale(
return true;
}
-bool ExtensionMessageBundle::GetMessageValue(const std::wstring& wkey,
+bool ExtensionMessageBundle::GetMessageValue(const std::string& key,
const DictionaryValue& catalog,
std::string* value,
std::string* error) const {
- std::string key(WideToUTF8(wkey));
// Get the top level tree for given key (name part).
DictionaryValue* name_tree;
- if (!catalog.GetDictionaryWithoutPathExpansion(wkey, &name_tree)) {
+ if (!catalog.GetDictionaryWithoutPathExpansion(key, &name_tree)) {
*error = StringPrintf("Not a valid tree for key %s.", key.c_str());
return false;
}
@@ -176,10 +175,10 @@ bool ExtensionMessageBundle::GetPlaceholders(const DictionaryValue& name_tree,
for (DictionaryValue::key_iterator key_it = placeholders_tree->begin_keys();
key_it != placeholders_tree->end_keys(); ++key_it) {
DictionaryValue* placeholder;
- std::string content_key = WideToUTF8(*key_it);
- if (!IsValidName(*key_it))
+ const std::string& content_key(*key_it);
+ if (!IsValidName(content_key))
return BadKeyMessage(content_key, error);
- if (!placeholders_tree->GetDictionaryWithoutPathExpansion(*key_it,
+ if (!placeholders_tree->GetDictionaryWithoutPathExpansion(content_key,
&placeholder)) {
*error = StringPrintf("Invalid placeholder %s for key %s",
content_key.c_str(),
diff --git a/chrome/common/extensions/extension_message_bundle.h b/chrome/common/extensions/extension_message_bundle.h
index 2e62649..3c80356 100644
--- a/chrome/common/extensions/extension_message_bundle.h
+++ b/chrome/common/extensions/extension_message_bundle.h
@@ -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.
@@ -133,7 +133,7 @@ class ExtensionMessageBundle {
// Helper methods that navigate JSON tree and return simplified message.
// They replace all $PLACEHOLDERS$ with their value, and return just key/value
// of the message.
- bool GetMessageValue(const std::wstring& wkey,
+ bool GetMessageValue(const std::string& key,
const DictionaryValue& catalog,
std::string* value,
std::string* error) const;