diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-03 18:11:25 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-03 18:11:25 +0000 |
commit | 906690b746ff0bbc3eedc839fc7ae03936f3dc67 (patch) | |
tree | 6baea2966a1f5008bb06bf70f13e391ce8550ed7 /webkit/glue | |
parent | f889b65a91ed110ba84a75b3d6c6c87f77367c5e (diff) | |
download | chromium_src-906690b746ff0bbc3eedc839fc7ae03936f3dc67.zip chromium_src-906690b746ff0bbc3eedc839fc7ae03936f3dc67.tar.gz chromium_src-906690b746ff0bbc3eedc839fc7ae03936f3dc67.tar.bz2 |
wstrings: convert CppVariant and CppBoundClass to not use wstring
Confusingly, we had a ToString() that returned a UTF-8 string and
a ToStringVector() that returned wstrings. Since CppVariant is
a small wrapper around NPVariant I made them both use UTF-8; it
simplified most of the users anyway (which only dealt with ASCII
anyway).
BUG=23581
TEST=compiles
Review URL: http://codereview.chromium.org/5631002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68187 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/cpp_bound_class.cc | 4 | ||||
-rw-r--r-- | webkit/glue/cpp_bound_class.h | 3 | ||||
-rw-r--r-- | webkit/glue/cpp_bound_class_unittest.cc | 2 | ||||
-rw-r--r-- | webkit/glue/cpp_variant.cc | 9 | ||||
-rw-r--r-- | webkit/glue/cpp_variant.h | 2 |
5 files changed, 9 insertions, 11 deletions
diff --git a/webkit/glue/cpp_bound_class.cc b/webkit/glue/cpp_bound_class.cc index d58fc4e..c5d15b6 100644 --- a/webkit/glue/cpp_bound_class.cc +++ b/webkit/glue/cpp_bound_class.cc @@ -319,7 +319,7 @@ CppVariant* CppBoundClass::GetAsCppVariant() { } void CppBoundClass::BindToJavascript(WebFrame* frame, - const std::wstring& classname) { + const std::string& classname) { #if WEBKIT_USING_JSC #error "This is not going to work anymore...but it's not clear what the solution is...or if it's still necessary." JSC::JSLock lock(false); @@ -328,7 +328,7 @@ void CppBoundClass::BindToJavascript(WebFrame* frame, // BindToWindowObject will take its own reference to the NPObject, and clean // up after itself. It will also (indirectly) register the object with V8, // so we must remember this so we can unregister it when we're destroyed. - frame->bindToWindowObject(WideToUTF16Hack(classname), + frame->bindToWindowObject(ASCIIToUTF16(classname), NPVARIANT_TO_OBJECT(*GetAsCppVariant())); bound_to_frame_ = true; } diff --git a/webkit/glue/cpp_bound_class.h b/webkit/glue/cpp_bound_class.h index a446386..06662ce 100644 --- a/webkit/glue/cpp_bound_class.h +++ b/webkit/glue/cpp_bound_class.h @@ -65,8 +65,7 @@ class CppBoundClass { // as window.<classname>. The owner of the CppBoundObject is responsible for // keeping the object around while the frame is alive, and for destroying it // afterwards. - void BindToJavascript( - WebKit::WebFrame* frame, const std::wstring& classname); + void BindToJavascript(WebKit::WebFrame* frame, const std::string& classname); // The type of callbacks. typedef Callback2<const CppArgumentList&, CppVariant*>::Type Callback; diff --git a/webkit/glue/cpp_bound_class_unittest.cc b/webkit/glue/cpp_bound_class_unittest.cc index 283b807..2f53c47 100644 --- a/webkit/glue/cpp_bound_class_unittest.cc +++ b/webkit/glue/cpp_bound_class_unittest.cc @@ -63,7 +63,7 @@ class ExampleTestShell : public TestShell { // When called by WebViewDelegate::WindowObjectCleared method, this binds a // CppExampleObject to window.example. virtual void BindJSObjectsToWindow(WebFrame* frame) { - example_bound_class_.BindToJavascript(frame, L"example"); + example_bound_class_.BindToJavascript(frame, "example"); // We use the layoutTestController binding for notifyDone. TestShell::BindJSObjectsToWindow(frame); } diff --git a/webkit/glue/cpp_variant.cc b/webkit/glue/cpp_variant.cc index 8545bc1..0d16cdd 100644 --- a/webkit/glue/cpp_variant.cc +++ b/webkit/glue/cpp_variant.cc @@ -211,10 +211,9 @@ bool CppVariant::ToBoolean() const { return value.boolValue; } -std::vector<std::wstring> CppVariant::ToStringVector() const { - +std::vector<std::string> CppVariant::ToStringVector() const { DCHECK(isObject()); - std::vector<std::wstring> wstring_vector; + std::vector<std::string> string_vector; NPObject* np_value = value.objectValue; NPIdentifier length_id = WebBindings::getStringIdentifier("length"); @@ -242,7 +241,7 @@ std::vector<std::wstring> CppVariant::ToStringVector() const { std::string string( NPVARIANT_TO_STRING(index_value).UTF8Characters, NPVARIANT_TO_STRING(index_value).UTF8Length); - wstring_vector.push_back(UTF8ToWide(string)); + string_vector.push_back(string); } WebBindings::releaseVariantValue(&index_value); } @@ -250,7 +249,7 @@ std::vector<std::wstring> CppVariant::ToStringVector() const { } } } - return wstring_vector; + return string_vector; } bool CppVariant::Invoke(const std::string& method, const CppVariant* args, diff --git a/webkit/glue/cpp_variant.h b/webkit/glue/cpp_variant.h index 71b3166..34f843a 100644 --- a/webkit/glue/cpp_variant.h +++ b/webkit/glue/cpp_variant.h @@ -96,7 +96,7 @@ class CppVariant : public NPVariant { bool ToBoolean() const; // Returns a vector of strings for the specified argument. This is useful // for converting a JavaScript array of strings into a vector of strings. - std::vector<std::wstring> ToStringVector() const; + std::vector<std::string> ToStringVector() const; // Invoke method of the given name on an object with the supplied arguments. // The first argument should be the object on which the method is to be |