Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2098)

Unified Diff: base/values.cc

Issue 6193003: Get rid of FromWStringHack in select_file_dialog.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/values.cc
diff --git a/base/values.cc b/base/values.cc
index 35225698c54d56eb83be645256a80b04dabb0341..ddce121d5bc94c5e993f126a872ceae1c15a484d 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -119,6 +119,10 @@ bool Value::GetAsString(string16* out_value) const {
return false;
}
+bool Value::GetAsFilePath(FilePath* out_value) const {
+ return false;
+}
+
bool Value::GetAsList(ListValue** out_value) {
return false;
}
@@ -261,6 +265,29 @@ bool StringValue::Equals(const Value* other) const {
return GetAsString(&lhs) && other->GetAsString(&rhs) && lhs == rhs;
}
+///////////////////// FilePathValue ////////////////////////////////////////////
+
+FilePathValue::FilePathValue(const FilePath& in_value)
+ : Value(TYPE_PATH),
+ value_(in_value) {
+}
+
+FilePathValue::~FilePathValue() {
+}
+
+bool FilePathValue::GetAsFilePath(FilePath* out_value) const {
+ if (out_value)
+ *out_value = value_;
+ return true;
+}
+
+bool FilePathValue::Equals(const Value* other) const {
+ if (other->GetType() != GetType())
+ return false;
+ FilePath lhs, rhs;
+ return GetAsFilePath(&lhs) && other->GetAsFilePath(&rhs) && lhs == rhs;
+}
+
///////////////////// BinaryValue ////////////////////
BinaryValue::~BinaryValue() {
@@ -511,6 +538,15 @@ bool DictionaryValue::GetList(const std::string& path,
return true;
}
+bool DictionaryValue::GetFilePath(const std::string& path,
+ FilePath* out_value) const {
+ Value* value;
+ if (!Get(path, &value))
+ return false;
+
+ return value->GetAsFilePath(out_value);
+}
+
bool DictionaryValue::GetWithoutPathExpansion(const std::string& key,
Value** out_value) const {
DCHECK(IsStringUTF8(key));
@@ -802,6 +838,14 @@ bool ListValue::GetList(size_t index, ListValue** out_value) const {
return true;
}
+bool ListValue::GetFilePath(size_t index, FilePath* out_value) const {
+ Value* value;
+ if (!Get(index, &value))
+ return false;
+
+ return value->GetAsFilePath(out_value);
+}
+
bool ListValue::Remove(size_t index, Value** out_value) {
if (index >= list_.size())
return false;

Powered by Google App Engine
This is Rietveld 408576698