diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-03 01:34:14 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-03 01:34:14 +0000 |
commit | 4172081a0e4cbb694293dad2d5ed4ba4f2cd26b4 (patch) | |
tree | 77cdae20592a241afafa8f86a3f75d4be87c42bf /webkit/tools | |
parent | 313f73ea0b7fd817741ed866770dcbebd9d6a66a (diff) | |
download | chromium_src-4172081a0e4cbb694293dad2d5ed4ba4f2cd26b4.zip chromium_src-4172081a0e4cbb694293dad2d5ed4ba4f2cd26b4.tar.gz chromium_src-4172081a0e4cbb694293dad2d5ed4ba4f2cd26b4.tar.bz2 |
Reland r129998: When input is "" (or " " with trim_whitespace true), SplitString() should return an empty vector, not a vector of one empty string.
Brett and I discussed this for a while and felt this would be wise, whereas dropping all empty segments entirely (e.g. converting "a,,b" to a vector of two elements instead of three) was probably unwise.
This also simplifies the code some.
Fixing this also required changing the code in mime_util.cc to handle empty vectors to "are codecs valid" oracle functions (in which case we return false). I also fixed some style issues there. It also required avoiding passing the empty string in a test in extension_api_unittest.cc; Aaron assures me that this code is not expected to be defensive against such inputs, but at his suggestion I also added some CHECK()s to the API.
BUG=none
TEST=none
Review URL: https://chromiumcodereview.appspot.com/9958076
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130285 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools')
-rw-r--r-- | webkit/tools/test_shell/test_shell_webmimeregistry_impl.cc | 20 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_webmimeregistry_impl.h | 5 |
2 files changed, 12 insertions, 13 deletions
diff --git a/webkit/tools/test_shell/test_shell_webmimeregistry_impl.cc b/webkit/tools/test_shell/test_shell_webmimeregistry_impl.cc index a411c21..d0989dd 100644 --- a/webkit/tools/test_shell/test_shell_webmimeregistry_impl.cc +++ b/webkit/tools/test_shell/test_shell_webmimeregistry_impl.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -16,9 +16,7 @@ namespace { // Convert a WebString to ASCII, falling back on an empty string in the case // of a non-ASCII string. std::string ToASCIIOrEmpty(const WebString& string) { - if (!IsStringASCII(string)) - return std::string(); - return UTF16ToASCII(string); + return IsStringASCII(string) ? UTF16ToASCII(string) : std::string(); } } // namespace @@ -40,15 +38,16 @@ TestShellWebMimeRegistryImpl::TestShellWebMimeRegistryImpl() { TestShellWebMimeRegistryImpl::~TestShellWebMimeRegistryImpl() {} WebMimeRegistry::SupportsType -TestShellWebMimeRegistryImpl::supportsMediaMIMEType( - const WebString& mime_type, const WebString& codecs) { + TestShellWebMimeRegistryImpl::supportsMediaMIMEType( + const WebString& mime_type, + const WebString& codecs) { // Not supporting the container is a flat-out no. - if (!IsSupportedMediaMimeType(ToASCIIOrEmpty(mime_type).c_str())) + if (!IsSupportedMediaMimeType(ToASCIIOrEmpty(mime_type))) return IsNotSupported; // If we don't recognize the codec, it's possible we support it. std::vector<std::string> parsed_codecs; - net::ParseCodecString(ToASCIIOrEmpty(codecs).c_str(), &parsed_codecs, true); + net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true); if (!AreSupportedMediaCodecs(parsed_codecs)) return MayBeSupported; @@ -64,9 +63,8 @@ bool TestShellWebMimeRegistryImpl::IsSupportedMediaMimeType( bool TestShellWebMimeRegistryImpl::AreSupportedMediaCodecs( const std::vector<std::string>& codecs) { for (size_t i = 0; i < codecs.size(); ++i) { - if (codecs_map_.find(codecs[i]) == codecs_map_.end()) { + if (codecs_map_.find(codecs[i]) == codecs_map_.end()) return false; - } } - return true; + return !codecs.empty(); } diff --git a/webkit/tools/test_shell/test_shell_webmimeregistry_impl.h b/webkit/tools/test_shell/test_shell_webmimeregistry_impl.h index 2c8ad6c..ecf7d4d 100644 --- a/webkit/tools/test_shell/test_shell_webmimeregistry_impl.h +++ b/webkit/tools/test_shell/test_shell_webmimeregistry_impl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -26,7 +26,8 @@ class TestShellWebMimeRegistryImpl // generated against ogg/vorbis/theora content we need to lock down how // canPlayType() behaves when running layout tests. virtual WebKit::WebMimeRegistry::SupportsType supportsMediaMIMEType( - const WebKit::WebString&, const WebKit::WebString&) OVERRIDE; + const WebKit::WebString&, + const WebKit::WebString&) OVERRIDE; private: bool IsSupportedMediaMimeType(const std::string& mime_type); |