summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-19 13:32:16 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-19 13:32:16 +0000
commit9430e4bae7a8faa17b353f66ed572b72cf393c05 (patch)
treef19b02c0477d30aaf70203872739607afec657a2 /base
parent76b24b56f8c5d78bc5c32fbdd81102ba9ed82dcb (diff)
downloadchromium_src-9430e4bae7a8faa17b353f66ed572b72cf393c05.zip
chromium_src-9430e4bae7a8faa17b353f66ed572b72cf393c05.tar.gz
chromium_src-9430e4bae7a8faa17b353f66ed572b72cf393c05.tar.bz2
importer: use FilePath instead of wstring in some places
Added API to DictionaryValue to use ASCII where appropriate. BUG=24672 TEST=profile import still got my bookmarks Review URL: http://codereview.chromium.org/647016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39441 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/values.cc24
-rw-r--r--base/values.h7
2 files changed, 31 insertions, 0 deletions
diff --git a/base/values.cc b/base/values.cc
index 7e55739..f78f474 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -354,6 +354,10 @@ bool DictionaryValue::HasKey(const std::wstring& key) const {
return current_entry != dictionary_.end();
}
+bool DictionaryValue::HasKeyASCII(const std::string& key) const {
+ return HasKey(ASCIIToWide(key));
+}
+
void DictionaryValue::Clear() {
ValueMap::iterator dict_iterator = dictionary_.begin();
while (dict_iterator != dictionary_.end()) {
@@ -471,6 +475,26 @@ bool DictionaryValue::GetReal(const std::wstring& path,
return value->GetAsReal(out_value);
}
+bool DictionaryValue::GetString(const std::string& path,
+ string16* out_value) const {
+ return GetStringAsUTF16(ASCIIToWide(path), out_value);
+}
+
+bool DictionaryValue::GetStringASCII(const std::string& path,
+ std::string* out_value) const {
+ std::string out;
+ if (!GetString(ASCIIToWide(path), &out))
+ return false;
+
+ if (!IsStringASCII(out)) {
+ NOTREACHED();
+ return false;
+ }
+
+ out_value->assign(out);
+ return true;
+}
+
bool DictionaryValue::GetString(const std::wstring& path,
std::string* out_value) const {
Value* value;
diff --git a/base/values.h b/base/values.h
index e000508..ac6307a 100644
--- a/base/values.h
+++ b/base/values.h
@@ -214,6 +214,9 @@ class DictionaryValue : public Value {
virtual bool Equals(const Value* other) const;
// Returns true if the current dictionary has a value for the given key.
+ bool HasKeyASCII(const std::string& key) const;
+ // Deprecated version of the above. TODO: add a string16 version for Unicode.
+ // http://code.google.com/p/chromium/issues/detail?id=23581
bool HasKey(const std::wstring& key) const;
// Returns the number of Values in this dictionary.
@@ -264,6 +267,10 @@ class DictionaryValue : public Value {
bool GetBoolean(const std::wstring& path, bool* out_value) const;
bool GetInteger(const std::wstring& path, int* out_value) const;
bool GetReal(const std::wstring& path, double* out_value) const;
+ bool GetString(const std::string& path, string16* out_value) const;
+ bool GetStringASCII(const std::string& path, std::string* out_value) const;
+ // TODO: deprecate wstring accessors.
+ // http://code.google.com/p/chromium/issues/detail?id=23581
bool GetString(const std::wstring& path, std::string* out_value) const;
bool GetString(const std::wstring& path, std::wstring* out_value) const;
bool GetStringAsUTF16(const std::wstring& path, string16* out_value) const;