diff options
author | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-09 05:45:17 +0000 |
---|---|---|
committer | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-09 05:45:17 +0000 |
commit | e59558b78e8c6a1b0bd916a724724b638c3c91b6 (patch) | |
tree | 712268a7e9e1cd552f309d89641b2bed5ad06322 /chrome/common/extensions | |
parent | 31fcd34da3797bc49160620ef8c94a38652c0587 (diff) | |
download | chromium_src-e59558b78e8c6a1b0bd916a724724b638c3c91b6.zip chromium_src-e59558b78e8c6a1b0bd916a724724b638c3c91b6.tar.gz chromium_src-e59558b78e8c6a1b0bd916a724724b638c3c91b6.tar.bz2 |
Rewrite std::string("") to std::string(), Linux edition.
This patch was generated by running the empty_string clang tool
across the Chromium Linux compilation database. Implicitly or
explicitly constructing std::string() with a "" argument is
inefficient as the caller needs to emit extra instructions to
pass an argument, and the constructor needlessly copies a byte
into internal storage. Rewriting these instances to simply call
the default constructor appears to save ~14-18 kilobytes on an
optimized release build.
BUG=none
Review URL: https://codereview.chromium.org/13145003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193020 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions')
27 files changed, 210 insertions, 137 deletions
diff --git a/chrome/common/extensions/api/commands/commands_handler.cc b/chrome/common/extensions/api/commands/commands_handler.cc index 309a204..b5ed3c4 100644 --- a/chrome/common/extensions/api/commands/commands_handler.cc +++ b/chrome/common/extensions/api/commands/commands_handler.cc @@ -137,8 +137,10 @@ void CommandsHandler::MaybeSetBrowserActionDefault(const Extension* extension, CommandsInfo* info) { if (extension->manifest()->HasKey(keys::kBrowserAction) && !info->browser_action_command.get()) { - info->browser_action_command.reset(new Command( - extension_manifest_values::kBrowserActionCommandEvent, string16(), "")); + info->browser_action_command.reset( + new Command(extension_manifest_values::kBrowserActionCommandEvent, + string16(), + std::string())); } } diff --git a/chrome/common/extensions/api/extension_action/browser_action_manifest_unittest.cc b/chrome/common/extensions/api/extension_action/browser_action_manifest_unittest.cc index 84277176..ac5040c 100644 --- a/chrome/common/extensions/api/extension_action/browser_action_manifest_unittest.cc +++ b/chrome/common/extensions/api/extension_action/browser_action_manifest_unittest.cc @@ -100,15 +100,13 @@ TEST_F(BrowserActionManifestTest, TEST_F(BrowserActionManifestTest, BrowserActionManifestIcons_InvalidDefaultIcon) { scoped_ptr<DictionaryValue> manifest_value = DictionaryBuilder() - .Set("name", "Invalid default icon") - .Set("version", "1.0.0") + .Set("name", "Invalid default icon").Set("version", "1.0.0") .Set("manifest_version", 2) - .Set("browser_action", DictionaryBuilder() - .Set("default_icon", DictionaryBuilder() - .Set("19", "") // Invalid value. - .Set("24", "icon24.png") - .Set("38", "icon38.png"))) - .Build(); + .Set("browser_action", + DictionaryBuilder().Set( + "default_icon", + DictionaryBuilder().Set("19", std::string()) // Invalid value. + .Set("24", "icon24.png").Set("38", "icon38.png"))).Build(); string16 error = ErrorUtils::FormatErrorMessageUTF16( errors::kInvalidIconPath, "19"); diff --git a/chrome/common/extensions/api/extension_api.cc b/chrome/common/extensions/api/extension_api.cc index b1095a4..97a2fdd 100644 --- a/chrome/common/extensions/api/extension_api.cc +++ b/chrome/common/extensions/api/extension_api.cc @@ -426,10 +426,11 @@ Feature::Availability ExtensionAPI::IsAvailable(const std::string& full_name, // Check APIs not using the feature system first. if (!feature) { - return IsNonFeatureAPIAvailable(api_name, context, extension, url) ? - Feature::CreateAvailability(Feature::IS_AVAILABLE, "") : - Feature::CreateAvailability(Feature::INVALID_CONTEXT, - kUnavailableMessage); + return IsNonFeatureAPIAvailable(api_name, context, extension, url) + ? Feature::CreateAvailability(Feature::IS_AVAILABLE, + std::string()) + : Feature::CreateAvailability(Feature::INVALID_CONTEXT, + kUnavailableMessage); } Feature::Availability availability = @@ -445,7 +446,7 @@ Feature::Availability ExtensionAPI::IsAvailable(const std::string& full_name, return dependency_availability; } - return Feature::CreateAvailability(Feature::IS_AVAILABLE, ""); + return Feature::CreateAvailability(Feature::IS_AVAILABLE, std::string()); } bool ExtensionAPI::IsPrivileged(const std::string& full_name) { @@ -634,7 +635,7 @@ std::string ExtensionAPI::GetAPINameFromFullName(const std::string& full_name, } *child_name = ""; - return ""; + return std::string(); } bool ExtensionAPI::IsAPIAllowed(const std::string& name, diff --git a/chrome/common/extensions/api/extension_api_unittest.cc b/chrome/common/extensions/api/extension_api_unittest.cc index 98830ea..f980b57 100644 --- a/chrome/common/extensions/api/extension_api_unittest.cc +++ b/chrome/common/extensions/api/extension_api_unittest.cc @@ -97,7 +97,7 @@ TEST_F(ExtensionAPITest, IsPrivileged) { EXPECT_TRUE(extension_api->IsPrivileged("runtime.lastError")); // Default unknown names to privileged for paranoia's sake. - EXPECT_TRUE(extension_api->IsPrivileged("")); + EXPECT_TRUE(extension_api->IsPrivileged(std::string())); EXPECT_TRUE(extension_api->IsPrivileged("<unknown-namespace>")); EXPECT_TRUE(extension_api->IsPrivileged("extension.<unknown-member>")); @@ -224,8 +224,8 @@ TEST(ExtensionAPI, APIFeatures) { TEST_F(ExtensionAPITest, LazyGetSchema) { scoped_ptr<ExtensionAPI> apis(ExtensionAPI::CreateWithDefaultConfiguration()); - EXPECT_EQ(NULL, apis->GetSchema("")); - EXPECT_EQ(NULL, apis->GetSchema("")); + EXPECT_EQ(NULL, apis->GetSchema(std::string())); + EXPECT_EQ(NULL, apis->GetSchema(std::string())); EXPECT_EQ(NULL, apis->GetSchema("experimental")); EXPECT_EQ(NULL, apis->GetSchema("experimental")); EXPECT_EQ(NULL, apis->GetSchema("foo")); diff --git a/chrome/common/extensions/csp_validator_unittest.cc b/chrome/common/extensions/csp_validator_unittest.cc index e96c42d..13cbfe8 100644 --- a/chrome/common/extensions/csp_validator_unittest.cc +++ b/chrome/common/extensions/csp_validator_unittest.cc @@ -23,10 +23,10 @@ TEST(ExtensionCSPValidator, IsLegal) { } TEST(ExtensionCSPValidator, IsSecure) { - EXPECT_FALSE(ContentSecurityPolicyIsSecure( - "", Manifest::TYPE_EXTENSION)); - EXPECT_FALSE(ContentSecurityPolicyIsSecure( - "img-src https://google.com", Manifest::TYPE_EXTENSION)); + EXPECT_FALSE( + ContentSecurityPolicyIsSecure(std::string(), Manifest::TYPE_EXTENSION)); + EXPECT_FALSE(ContentSecurityPolicyIsSecure("img-src https://google.com", + Manifest::TYPE_EXTENSION)); EXPECT_FALSE(ContentSecurityPolicyIsSecure( "default-src *", Manifest::TYPE_EXTENSION)); @@ -146,9 +146,10 @@ TEST(ExtensionCSPValidator, IsSecure) { } TEST(ExtensionCSPValidator, IsSandboxed) { - EXPECT_FALSE(ContentSecurityPolicyIsSandboxed("", Manifest::TYPE_EXTENSION)); - EXPECT_FALSE(ContentSecurityPolicyIsSandboxed( - "img-src https://google.com", Manifest::TYPE_EXTENSION)); + EXPECT_FALSE(ContentSecurityPolicyIsSandboxed(std::string(), + Manifest::TYPE_EXTENSION)); + EXPECT_FALSE(ContentSecurityPolicyIsSandboxed("img-src https://google.com", + Manifest::TYPE_EXTENSION)); // Sandbox directive is required. EXPECT_TRUE(ContentSecurityPolicyIsSandboxed( diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index a941208..42407b8 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -437,8 +437,8 @@ bool Extension::ParsePermissions(const char* key, if (manifest_->HasKey(key)) { const ListValue* permissions = NULL; if (!manifest_->GetList(key, &permissions)) { - *error = ErrorUtils::FormatErrorMessageUTF16( - errors::kInvalidPermissions, ""); + *error = ErrorUtils::FormatErrorMessageUTF16(errors::kInvalidPermissions, + std::string()); return false; } diff --git a/chrome/common/extensions/extension_file_util_unittest.cc b/chrome/common/extensions/extension_file_util_unittest.cc index cb9260f..3f34f6e 100644 --- a/chrome/common/extensions/extension_file_util_unittest.cc +++ b/chrome/common/extensions/extension_file_util_unittest.cc @@ -304,7 +304,7 @@ TEST_F(ExtensionFileUtilTest, ExtensionResourceURLToFilePath) { // Setup filesystem for testing. base::FilePath root_path; ASSERT_TRUE(file_util::CreateNewTempDirectory( - FILE_PATH_LITERAL(""), &root_path)); + FILE_PATH_LITERAL(std::string()), &root_path)); ASSERT_TRUE(file_util::AbsolutePath(&root_path)); base::FilePath api_path = root_path.Append(FILE_PATH_LITERAL("apiname")); diff --git a/chrome/common/extensions/extension_icon_set_unittest.cc b/chrome/common/extensions/extension_icon_set_unittest.cc index 1202cda..c7300a7 100644 --- a/chrome/common/extensions/extension_icon_set_unittest.cc +++ b/chrome/common/extensions/extension_icon_set_unittest.cc @@ -62,7 +62,7 @@ TEST(ExtensionIconSet, Values) { EXPECT_TRUE(icons.ContainsPath("foo")); EXPECT_TRUE(icons.ContainsPath("bar")); EXPECT_FALSE(icons.ContainsPath("baz")); - EXPECT_FALSE(icons.ContainsPath("")); + EXPECT_FALSE(icons.ContainsPath(std::string())); icons.Clear(); EXPECT_FALSE(icons.ContainsPath("foo")); @@ -83,7 +83,7 @@ TEST(ExtensionIconSet, FindSize) { EXPECT_EQ(extension_misc::EXTENSION_ICON_INVALID, icons.GetIconSizeFromPath("baz")); EXPECT_EQ(extension_misc::EXTENSION_ICON_INVALID, - icons.GetIconSizeFromPath("")); + icons.GetIconSizeFromPath(std::string())); icons.Clear(); EXPECT_EQ(extension_misc::EXTENSION_ICON_INVALID, diff --git a/chrome/common/extensions/extension_l10n_util.cc b/chrome/common/extensions/extension_l10n_util.cc index b86ab49..d2dada0 100644 --- a/chrome/common/extensions/extension_l10n_util.cc +++ b/chrome/common/extensions/extension_l10n_util.cc @@ -44,7 +44,7 @@ std::string GetDefaultLocaleFromManifest(const DictionaryValue& manifest, return default_locale; *error = errors::kInvalidDefaultLocale; - return ""; + return std::string(); } diff --git a/chrome/common/extensions/extension_localization_peer_unittest.cc b/chrome/common/extensions/extension_localization_peer_unittest.cc index 92085ed..df74791 100644 --- a/chrome/common/extensions/extension_localization_peer_unittest.cc +++ b/chrome/common/extensions/extension_localization_peer_unittest.cc @@ -144,8 +144,8 @@ TEST_F(ExtensionLocalizationPeerTest, OnCompletedRequestBadURLRequestStatus) { EXPECT_CALL(*original_peer_, OnCompletedRequest( net::ERR_ABORTED, false, "", base::TimeTicks())); - filter_peer->OnCompletedRequest(net::ERR_FAILED, false, "", - base::TimeTicks()); + filter_peer->OnCompletedRequest( + net::ERR_FAILED, false, std::string(), base::TimeTicks()); } TEST_F(ExtensionLocalizationPeerTest, OnCompletedRequestEmptyData) { @@ -159,7 +159,8 @@ TEST_F(ExtensionLocalizationPeerTest, OnCompletedRequestEmptyData) { EXPECT_CALL(*original_peer_, OnCompletedRequest( net::OK, false, "", base::TimeTicks())); - filter_peer->OnCompletedRequest(net::OK, false, "", base::TimeTicks()); + filter_peer->OnCompletedRequest( + net::OK, false, std::string(), base::TimeTicks()); } TEST_F(ExtensionLocalizationPeerTest, OnCompletedRequestNoCatalogs) { @@ -178,14 +179,16 @@ TEST_F(ExtensionLocalizationPeerTest, OnCompletedRequestNoCatalogs) { EXPECT_CALL(*original_peer_, OnCompletedRequest( net::OK, false, "", base::TimeTicks())).Times(2); - filter_peer->OnCompletedRequest(net::OK, false, "", base::TimeTicks()); + filter_peer->OnCompletedRequest( + net::OK, false, std::string(), base::TimeTicks()); // Test if Send gets called again (it shouldn't be) when first call returned // an empty dictionary. filter_peer = CreateExtensionLocalizationPeer("text/css", GURL(kExtensionUrl_1)); SetData(filter_peer, "some text"); - filter_peer->OnCompletedRequest(net::OK, false, "", base::TimeTicks()); + filter_peer->OnCompletedRequest( + net::OK, false, std::string(), base::TimeTicks()); } TEST_F(ExtensionLocalizationPeerTest, OnCompletedRequestWithCatalogs) { @@ -213,7 +216,8 @@ TEST_F(ExtensionLocalizationPeerTest, OnCompletedRequestWithCatalogs) { EXPECT_CALL(*original_peer_, OnCompletedRequest( net::OK, false, "", base::TimeTicks())); - filter_peer->OnCompletedRequest(net::OK, false, "", base::TimeTicks()); + filter_peer->OnCompletedRequest( + net::OK, false, std::string(), base::TimeTicks()); } TEST_F(ExtensionLocalizationPeerTest, OnCompletedRequestReplaceMessagesFails) { @@ -241,5 +245,6 @@ TEST_F(ExtensionLocalizationPeerTest, OnCompletedRequestReplaceMessagesFails) { EXPECT_CALL(*original_peer_, OnCompletedRequest( net::OK, false, "", base::TimeTicks())); - filter_peer->OnCompletedRequest(net::OK, false, "", base::TimeTicks()); + filter_peer->OnCompletedRequest( + net::OK, false, std::string(), base::TimeTicks()); } diff --git a/chrome/common/extensions/extension_set.cc b/chrome/common/extensions/extension_set.cc index 84872b8..8b68fb6 100644 --- a/chrome/common/extensions/extension_set.cc +++ b/chrome/common/extensions/extension_set.cc @@ -77,11 +77,11 @@ std::string ExtensionSet::GetExtensionOrAppIDByURL( DCHECK(!info.origin().isNull()); if (info.url().SchemeIs(extensions::kExtensionScheme)) - return info.origin().isUnique() ? "" : info.url().host(); + return info.origin().isUnique() ? std::string() : info.url().host(); const Extension* extension = GetExtensionOrAppByURL(info); if (!extension) - return ""; + return std::string(); return extension->id(); } diff --git a/chrome/common/extensions/extension_set_unittest.cc b/chrome/common/extensions/extension_set_unittest.cc index 1703966..c27b0a9 100644 --- a/chrome/common/extensions/extension_set_unittest.cc +++ b/chrome/common/extensions/extension_set_unittest.cc @@ -59,7 +59,8 @@ TEST(ExtensionSetTest, ExtensionSet) { scoped_refptr<Extension> ext3(CreateTestExtension( "b", "http://dev.chromium.org/", "http://dev.chromium.org/")); - scoped_refptr<Extension> ext4(CreateTestExtension("c", "", "")); + scoped_refptr<Extension> ext4( + CreateTestExtension("c", std::string(), std::string())); ASSERT_TRUE(ext1 && ext2 && ext3 && ext4); @@ -118,8 +119,10 @@ TEST(ExtensionSetTest, ExtensionSet) { EXPECT_FALSE(extensions.GetByID(ext2->id())); // Make a union of a set with 3 more extensions (only 2 are new). - scoped_refptr<Extension> ext5(CreateTestExtension("d", "", "")); - scoped_refptr<Extension> ext6(CreateTestExtension("e", "", "")); + scoped_refptr<Extension> ext5( + CreateTestExtension("d", std::string(), std::string())); + scoped_refptr<Extension> ext6( + CreateTestExtension("e", std::string(), std::string())); ASSERT_TRUE(ext5 && ext6); scoped_ptr<ExtensionSet> to_add(new ExtensionSet()); diff --git a/chrome/common/extensions/extension_sync_type_unittest.cc b/chrome/common/extensions/extension_sync_type_unittest.cc index 3256c8d..b25e197 100644 --- a/chrome/common/extensions/extension_sync_type_unittest.cc +++ b/chrome/common/extensions/extension_sync_type_unittest.cc @@ -56,7 +56,7 @@ class ExtensionSyncTypeTest : public ExtensionTest { ListValue* plugins = new ListValue(); for (int i = 0; i < num_plugins; ++i) { DictionaryValue* plugin = new DictionaryValue(); - plugin->SetString(keys::kPluginsPath, ""); + plugin->SetString(keys::kPluginsPath, std::string()); plugins->Set(i, plugin); } source.Set(keys::kPlugins, plugins); @@ -158,7 +158,7 @@ TEST_F(ExtensionSyncTypeTest, DisplayInXManifestProperties) { manifest.SetString(keys::kName, "TestComponentApp"); manifest.SetString(keys::kVersion, "0.0.0.0"); manifest.SetString(keys::kApp, "true"); - manifest.SetString(keys::kPlatformAppBackgroundPage, ""); + manifest.SetString(keys::kPlatformAppBackgroundPage, std::string()); std::string error; scoped_refptr<Extension> app; diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc index 6a3c80d..edf24c4 100644 --- a/chrome/common/extensions/extension_unittest.cc +++ b/chrome/common/extensions/extension_unittest.cc @@ -233,16 +233,22 @@ TEST_F(ExtensionTest, MimeTypeSniffing) { ASSERT_TRUE(file_util::ReadFileToString(path, &data)); std::string result; - EXPECT_TRUE(net::SniffMimeType(data.c_str(), data.size(), - GURL("http://www.example.com/foo.crx"), "", &result)); + EXPECT_TRUE(net::SniffMimeType(data.c_str(), + data.size(), + GURL("http://www.example.com/foo.crx"), + std::string(), + &result)); EXPECT_EQ(std::string(Extension::kMimeType), result); data.clear(); result.clear(); path = path.DirName().AppendASCII("bad_magic.crx"); ASSERT_TRUE(file_util::ReadFileToString(path, &data)); - EXPECT_TRUE(net::SniffMimeType(data.c_str(), data.size(), - GURL("http://www.example.com/foo.crx"), "", &result)); + EXPECT_TRUE(net::SniffMimeType(data.c_str(), + data.size(), + GURL("http://www.example.com/foo.crx"), + std::string(), + &result)); EXPECT_EQ("application/octet-stream", result); } diff --git a/chrome/common/extensions/features/api_feature.cc b/chrome/common/extensions/features/api_feature.cc index 0020632..f6d826e 100644 --- a/chrome/common/extensions/features/api_feature.cc +++ b/chrome/common/extensions/features/api_feature.cc @@ -26,7 +26,7 @@ std::string APIFeature::Parse(const DictionaryValue* value) { if (GetContexts()->empty()) return name() + ": API features must specify at least one context."; - return ""; + return std::string(); } } // namespace diff --git a/chrome/common/extensions/features/complex_feature.cc b/chrome/common/extensions/features/complex_feature.cc index f6f1c11..a4515d0e4 100644 --- a/chrome/common/extensions/features/complex_feature.cc +++ b/chrome/common/extensions/features/complex_feature.cc @@ -76,7 +76,7 @@ std::string ComplexFeature::GetAvailabilityMessage(AvailabilityResult result, Manifest::Type type, const GURL& url) const { if (result == IS_AVAILABLE) - return ""; + return std::string(); // TODO(justinlin): Form some kind of combined availabilities/messages from // SimpleFeatures. diff --git a/chrome/common/extensions/features/manifest_feature.cc b/chrome/common/extensions/features/manifest_feature.cc index cd4a53f..5196b52 100644 --- a/chrome/common/extensions/features/manifest_feature.cc +++ b/chrome/common/extensions/features/manifest_feature.cc @@ -47,7 +47,7 @@ std::string ManifestFeature::Parse(const DictionaryValue* value) { if (!GetContexts()->empty()) return name() + ": Manifest features do not support contexts."; - return ""; + return std::string(); } } // namespace diff --git a/chrome/common/extensions/features/permission_feature.cc b/chrome/common/extensions/features/permission_feature.cc index 72b261f..4681aa2 100644 --- a/chrome/common/extensions/features/permission_feature.cc +++ b/chrome/common/extensions/features/permission_feature.cc @@ -49,7 +49,7 @@ std::string PermissionFeature::Parse(const DictionaryValue* value) { if (!GetContexts()->empty()) return name() + ": Permission features do not support contexts."; - return ""; + return std::string(); } } // namespace diff --git a/chrome/common/extensions/features/simple_feature.cc b/chrome/common/extensions/features/simple_feature.cc index 13c8573..4b08c60 100644 --- a/chrome/common/extensions/features/simple_feature.cc +++ b/chrome/common/extensions/features/simple_feature.cc @@ -168,7 +168,7 @@ std::string GetDisplayTypeName(Manifest::Type type) { } NOTREACHED(); - return ""; + return std::string(); } } // namespace @@ -229,7 +229,7 @@ std::string SimpleFeature::Parse(const DictionaryValue* value) { return name() + ": Allowing web_page contexts requires supplying a value " + "for matches."; } - return ""; + return std::string(); } Feature::Availability SimpleFeature::IsAvailableToManifest( @@ -313,7 +313,7 @@ std::string SimpleFeature::GetAvailabilityMessage( AvailabilityResult result, Manifest::Type type, const GURL& url) const { switch (result) { case IS_AVAILABLE: - return ""; + return std::string(); case NOT_FOUND_IN_WHITELIST: return base::StringPrintf( "'%s' is not allowed for specified extension ID.", @@ -381,7 +381,7 @@ std::string SimpleFeature::GetAvailabilityMessage( } NOTREACHED(); - return ""; + return std::string(); } Feature::Availability SimpleFeature::CreateAvailability( diff --git a/chrome/common/extensions/features/simple_feature_unittest.cc b/chrome/common/extensions/features/simple_feature_unittest.cc index 443b152..4f92a34 100644 --- a/chrome/common/extensions/features/simple_feature_unittest.cc +++ b/chrome/common/extensions/features/simple_feature_unittest.cc @@ -91,9 +91,13 @@ TEST_F(ExtensionSimpleFeatureTest, Whitelist) { EXPECT_EQ(Feature::NOT_FOUND_IN_WHITELIST, feature.IsAvailableToManifest( kIdBaz, Manifest::TYPE_UNKNOWN, Feature::UNSPECIFIED_LOCATION, -1, Feature::UNSPECIFIED_PLATFORM).result()); - EXPECT_EQ(Feature::NOT_FOUND_IN_WHITELIST, feature.IsAvailableToManifest( - "", Manifest::TYPE_UNKNOWN, Feature::UNSPECIFIED_LOCATION, -1, - Feature::UNSPECIFIED_PLATFORM).result()); + EXPECT_EQ( + Feature::NOT_FOUND_IN_WHITELIST, + feature.IsAvailableToManifest(std::string(), + Manifest::TYPE_UNKNOWN, + Feature::UNSPECIFIED_LOCATION, + -1, + Feature::UNSPECIFIED_PLATFORM).result()); feature.extension_types()->insert(Manifest::TYPE_LEGACY_PACKAGED_APP); EXPECT_EQ(Feature::NOT_FOUND_IN_WHITELIST, feature.IsAvailableToManifest( @@ -133,19 +137,35 @@ TEST_F(ExtensionSimpleFeatureTest, PackageType) { feature.extension_types()->insert(Manifest::TYPE_EXTENSION); feature.extension_types()->insert(Manifest::TYPE_LEGACY_PACKAGED_APP); - EXPECT_EQ(Feature::IS_AVAILABLE, feature.IsAvailableToManifest( - "", Manifest::TYPE_EXTENSION, Feature::UNSPECIFIED_LOCATION, -1, - Feature::UNSPECIFIED_PLATFORM).result()); - EXPECT_EQ(Feature::IS_AVAILABLE, feature.IsAvailableToManifest( - "", Manifest::TYPE_LEGACY_PACKAGED_APP, Feature::UNSPECIFIED_LOCATION, - -1, Feature::UNSPECIFIED_PLATFORM).result()); - - EXPECT_EQ(Feature::INVALID_TYPE, feature.IsAvailableToManifest( - "", Manifest::TYPE_UNKNOWN, Feature::UNSPECIFIED_LOCATION, -1, - Feature::UNSPECIFIED_PLATFORM).result()); - EXPECT_EQ(Feature::INVALID_TYPE, feature.IsAvailableToManifest( - "", Manifest::TYPE_THEME, Feature::UNSPECIFIED_LOCATION, -1, - Feature::UNSPECIFIED_PLATFORM).result()); + EXPECT_EQ( + Feature::IS_AVAILABLE, + feature.IsAvailableToManifest(std::string(), + Manifest::TYPE_EXTENSION, + Feature::UNSPECIFIED_LOCATION, + -1, + Feature::UNSPECIFIED_PLATFORM).result()); + EXPECT_EQ( + Feature::IS_AVAILABLE, + feature.IsAvailableToManifest(std::string(), + Manifest::TYPE_LEGACY_PACKAGED_APP, + Feature::UNSPECIFIED_LOCATION, + -1, + Feature::UNSPECIFIED_PLATFORM).result()); + + EXPECT_EQ( + Feature::INVALID_TYPE, + feature.IsAvailableToManifest(std::string(), + Manifest::TYPE_UNKNOWN, + Feature::UNSPECIFIED_LOCATION, + -1, + Feature::UNSPECIFIED_PLATFORM).result()); + EXPECT_EQ( + Feature::INVALID_TYPE, + feature.IsAvailableToManifest(std::string(), + Manifest::TYPE_THEME, + Feature::UNSPECIFIED_LOCATION, + -1, + Feature::UNSPECIFIED_PLATFORM).result()); } TEST_F(ExtensionSimpleFeatureTest, Context) { @@ -220,64 +240,107 @@ TEST_F(ExtensionSimpleFeatureTest, Location) { // If the feature specifies "component" as its location, then only component // extensions can access it. feature.set_location(Feature::COMPONENT_LOCATION); - EXPECT_EQ(Feature::IS_AVAILABLE, feature.IsAvailableToManifest( - "", Manifest::TYPE_UNKNOWN, Feature::COMPONENT_LOCATION, -1, - Feature::UNSPECIFIED_PLATFORM).result()); - EXPECT_EQ(Feature::INVALID_LOCATION, feature.IsAvailableToManifest( - "", Manifest::TYPE_UNKNOWN, Feature::UNSPECIFIED_LOCATION, -1, - Feature::UNSPECIFIED_PLATFORM).result()); + EXPECT_EQ( + Feature::IS_AVAILABLE, + feature.IsAvailableToManifest(std::string(), + Manifest::TYPE_UNKNOWN, + Feature::COMPONENT_LOCATION, + -1, + Feature::UNSPECIFIED_PLATFORM).result()); + EXPECT_EQ( + Feature::INVALID_LOCATION, + feature.IsAvailableToManifest(std::string(), + Manifest::TYPE_UNKNOWN, + Feature::UNSPECIFIED_LOCATION, + -1, + Feature::UNSPECIFIED_PLATFORM).result()); // But component extensions can access anything else, whatever their location. feature.set_location(Feature::UNSPECIFIED_LOCATION); - EXPECT_EQ(Feature::IS_AVAILABLE, feature.IsAvailableToManifest( - "", Manifest::TYPE_UNKNOWN, Feature::COMPONENT_LOCATION, -1, - Feature::UNSPECIFIED_PLATFORM).result()); + EXPECT_EQ( + Feature::IS_AVAILABLE, + feature.IsAvailableToManifest(std::string(), + Manifest::TYPE_UNKNOWN, + Feature::COMPONENT_LOCATION, + -1, + Feature::UNSPECIFIED_PLATFORM).result()); } TEST_F(ExtensionSimpleFeatureTest, Platform) { SimpleFeature feature; feature.set_platform(Feature::CHROMEOS_PLATFORM); - EXPECT_EQ(Feature::IS_AVAILABLE, feature.IsAvailableToManifest( - "", Manifest::TYPE_UNKNOWN, Feature::UNSPECIFIED_LOCATION, -1, - Feature::CHROMEOS_PLATFORM).result()); - EXPECT_EQ(Feature::INVALID_PLATFORM, feature.IsAvailableToManifest( - "", Manifest::TYPE_UNKNOWN, Feature::UNSPECIFIED_LOCATION, -1, - Feature::UNSPECIFIED_PLATFORM).result()); + EXPECT_EQ(Feature::IS_AVAILABLE, + feature.IsAvailableToManifest(std::string(), + Manifest::TYPE_UNKNOWN, + Feature::UNSPECIFIED_LOCATION, + -1, + Feature::CHROMEOS_PLATFORM).result()); + EXPECT_EQ( + Feature::INVALID_PLATFORM, + feature.IsAvailableToManifest(std::string(), + Manifest::TYPE_UNKNOWN, + Feature::UNSPECIFIED_LOCATION, + -1, + Feature::UNSPECIFIED_PLATFORM).result()); } TEST_F(ExtensionSimpleFeatureTest, Version) { SimpleFeature feature; feature.set_min_manifest_version(5); - EXPECT_EQ(Feature::INVALID_MIN_MANIFEST_VERSION, - feature.IsAvailableToManifest( - "", Manifest::TYPE_UNKNOWN, Feature::UNSPECIFIED_LOCATION, - 0, Feature::UNSPECIFIED_PLATFORM).result()); - EXPECT_EQ(Feature::INVALID_MIN_MANIFEST_VERSION, - feature.IsAvailableToManifest( - "", Manifest::TYPE_UNKNOWN, Feature::UNSPECIFIED_LOCATION, - 4, Feature::UNSPECIFIED_PLATFORM).result()); - - EXPECT_EQ(Feature::IS_AVAILABLE, feature.IsAvailableToManifest( - "", Manifest::TYPE_UNKNOWN, Feature::UNSPECIFIED_LOCATION, - 5, Feature::UNSPECIFIED_PLATFORM).result()); - EXPECT_EQ(Feature::IS_AVAILABLE, feature.IsAvailableToManifest( - "", Manifest::TYPE_UNKNOWN, Feature::UNSPECIFIED_LOCATION, - 10, Feature::UNSPECIFIED_PLATFORM).result()); + EXPECT_EQ( + Feature::INVALID_MIN_MANIFEST_VERSION, + feature.IsAvailableToManifest(std::string(), + Manifest::TYPE_UNKNOWN, + Feature::UNSPECIFIED_LOCATION, + 0, + Feature::UNSPECIFIED_PLATFORM).result()); + EXPECT_EQ( + Feature::INVALID_MIN_MANIFEST_VERSION, + feature.IsAvailableToManifest(std::string(), + Manifest::TYPE_UNKNOWN, + Feature::UNSPECIFIED_LOCATION, + 4, + Feature::UNSPECIFIED_PLATFORM).result()); + + EXPECT_EQ( + Feature::IS_AVAILABLE, + feature.IsAvailableToManifest(std::string(), + Manifest::TYPE_UNKNOWN, + Feature::UNSPECIFIED_LOCATION, + 5, + Feature::UNSPECIFIED_PLATFORM).result()); + EXPECT_EQ( + Feature::IS_AVAILABLE, + feature.IsAvailableToManifest(std::string(), + Manifest::TYPE_UNKNOWN, + Feature::UNSPECIFIED_LOCATION, + 10, + Feature::UNSPECIFIED_PLATFORM).result()); feature.set_max_manifest_version(8); - EXPECT_EQ(Feature::INVALID_MAX_MANIFEST_VERSION, - feature.IsAvailableToManifest( - "", Manifest::TYPE_UNKNOWN, Feature::UNSPECIFIED_LOCATION, - 10, Feature::UNSPECIFIED_PLATFORM).result()); - EXPECT_EQ(Feature::IS_AVAILABLE, - feature.IsAvailableToManifest( - "", Manifest::TYPE_UNKNOWN, Feature::UNSPECIFIED_LOCATION, - 8, Feature::UNSPECIFIED_PLATFORM).result()); - EXPECT_EQ(Feature::IS_AVAILABLE, feature.IsAvailableToManifest( - "", Manifest::TYPE_UNKNOWN, Feature::UNSPECIFIED_LOCATION, - 7, Feature::UNSPECIFIED_PLATFORM).result()); + EXPECT_EQ( + Feature::INVALID_MAX_MANIFEST_VERSION, + feature.IsAvailableToManifest(std::string(), + Manifest::TYPE_UNKNOWN, + Feature::UNSPECIFIED_LOCATION, + 10, + Feature::UNSPECIFIED_PLATFORM).result()); + EXPECT_EQ( + Feature::IS_AVAILABLE, + feature.IsAvailableToManifest(std::string(), + Manifest::TYPE_UNKNOWN, + Feature::UNSPECIFIED_LOCATION, + 8, + Feature::UNSPECIFIED_PLATFORM).result()); + EXPECT_EQ( + Feature::IS_AVAILABLE, + feature.IsAvailableToManifest(std::string(), + Manifest::TYPE_UNKNOWN, + Feature::UNSPECIFIED_LOCATION, + 7, + Feature::UNSPECIFIED_PLATFORM).result()); } TEST_F(ExtensionSimpleFeatureTest, ParseNull) { @@ -549,15 +612,15 @@ TEST_F(ExtensionSimpleFeatureTest, SupportedChannel) { // Default supported channel (trunk). EXPECT_EQ(Feature::IS_AVAILABLE, - IsAvailableInChannel("", VersionInfo::CHANNEL_UNKNOWN)); + IsAvailableInChannel(std::string(), VersionInfo::CHANNEL_UNKNOWN)); EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, - IsAvailableInChannel("", VersionInfo::CHANNEL_CANARY)); + IsAvailableInChannel(std::string(), VersionInfo::CHANNEL_CANARY)); EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, - IsAvailableInChannel("", VersionInfo::CHANNEL_DEV)); + IsAvailableInChannel(std::string(), VersionInfo::CHANNEL_DEV)); EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, - IsAvailableInChannel("", VersionInfo::CHANNEL_BETA)); + IsAvailableInChannel(std::string(), VersionInfo::CHANNEL_BETA)); EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, - IsAvailableInChannel("", VersionInfo::CHANNEL_STABLE)); + IsAvailableInChannel(std::string(), VersionInfo::CHANNEL_STABLE)); } } // namespace diff --git a/chrome/common/extensions/manifest_tests/extension_manifest_test.cc b/chrome/common/extensions/manifest_tests/extension_manifest_test.cc index b61d5f7..4e72588 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifest_test.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifest_test.cc @@ -217,20 +217,16 @@ ExtensionManifestTest::Testcase::Testcase(std::string manifest_filename, ExtensionManifestTest::Testcase::Testcase(std::string manifest_filename) : manifest_filename_(manifest_filename), - expected_error_(""), location_(extensions::Manifest::INTERNAL), - flags_(Extension::NO_FLAGS) { -} + flags_(Extension::NO_FLAGS) {} ExtensionManifestTest::Testcase::Testcase( std::string manifest_filename, extensions::Manifest::Location location, int flags) : manifest_filename_(manifest_filename), - expected_error_(""), location_(location), - flags_(flags) { -} + flags_(flags) {} void ExtensionManifestTest::RunTestcases(const Testcase* testcases, size_t num_testcases, diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc index 1fdab49..bb93903 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc @@ -98,7 +98,7 @@ TEST_F(PlatformAppsManifestTest, PlatformAppContentSecurityPolicy) { EXPECT_TRUE(extension->is_platform_app()); EXPECT_EQ( "default-src 'self' https://www.google.com", - CSPInfo::GetResourceContentSecurityPolicy(extension, "")); + CSPInfo::GetResourceContentSecurityPolicy(extension, std::string())); // But even whitelisted ones must specify a secure policy. LoadAndExpectError( diff --git a/chrome/common/extensions/manifest_url_handler.cc b/chrome/common/extensions/manifest_url_handler.cc index 2e18eb1..690cc03 100644 --- a/chrome/common/extensions/manifest_url_handler.cc +++ b/chrome/common/extensions/manifest_url_handler.cc @@ -125,8 +125,8 @@ bool HomepageURLHandler::Parse(Extension* extension, string16* error) { std::string homepage_url_str; if (!extension->manifest()->GetString(keys::kHomepageURL, &homepage_url_str)) { - *error = ErrorUtils::FormatErrorMessageUTF16( - errors::kInvalidHomepageURL, ""); + *error = ErrorUtils::FormatErrorMessageUTF16(errors::kInvalidHomepageURL, + std::string()); return false; } manifest_url->url_ = GURL(homepage_url_str); @@ -156,8 +156,8 @@ bool UpdateURLHandler::Parse(Extension* extension, string16* error) { std::string tmp_update_url; if (!extension->manifest()->GetString(keys::kUpdateURL, &tmp_update_url)) { - *error = ErrorUtils::FormatErrorMessageUTF16( - errors::kInvalidUpdateURL, ""); + *error = ErrorUtils::FormatErrorMessageUTF16(errors::kInvalidUpdateURL, + std::string()); return false; } diff --git a/chrome/common/extensions/message_bundle.cc b/chrome/common/extensions/message_bundle.cc index 708e2e4..bb7d547 100644 --- a/chrome/common/extensions/message_bundle.cc +++ b/chrome/common/extensions/message_bundle.cc @@ -303,7 +303,7 @@ std::string MessageBundle::GetL10nMessage(const std::string& name, return it->second; } - return ""; + return std::string(); } /////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/common/extensions/permissions/bluetooth_device_permission_data.cc b/chrome/common/extensions/permissions/bluetooth_device_permission_data.cc index 3698ebf..82c5acd 100644 --- a/chrome/common/extensions/permissions/bluetooth_device_permission_data.cc +++ b/chrome/common/extensions/permissions/bluetooth_device_permission_data.cc @@ -18,9 +18,7 @@ const char* kDeviceAddressKey = "deviceAddress"; namespace extensions { -BluetoothDevicePermissionData::BluetoothDevicePermissionData() - : device_address_("") { -} +BluetoothDevicePermissionData::BluetoothDevicePermissionData() {} BluetoothDevicePermissionData::BluetoothDevicePermissionData( const std::string& device_address) : device_address_(device_address) { diff --git a/chrome/common/extensions/permissions/socket_permission_unittest.cc b/chrome/common/extensions/permissions/socket_permission_unittest.cc index 6bb07be..05e7d3d 100644 --- a/chrome/common/extensions/permissions/socket_permission_unittest.cc +++ b/chrome/common/extensions/permissions/socket_permission_unittest.cc @@ -48,7 +48,7 @@ TEST_F(SocketPermissionTest, General) { TEST_F(SocketPermissionTest, Parse) { SocketPermissionData data; - EXPECT_FALSE(data.ParseForTest("")); + EXPECT_FALSE(data.ParseForTest(std::string())); EXPECT_FALSE(data.ParseForTest("*")); EXPECT_FALSE(data.ParseForTest("\00\00*")); EXPECT_FALSE(data.ParseForTest("\01*")); diff --git a/chrome/common/extensions/update_manifest_unittest.cc b/chrome/common/extensions/update_manifest_unittest.cc index 9af11df..2a16b9c 100644 --- a/chrome/common/extensions/update_manifest_unittest.cc +++ b/chrome/common/extensions/update_manifest_unittest.cc @@ -120,7 +120,7 @@ TEST(ExtensionUpdateManifestTest, TestUpdateManifest) { UpdateManifest parser; // Test parsing of a number of invalid xml cases - EXPECT_FALSE(parser.Parse("")); + EXPECT_FALSE(parser.Parse(std::string())); EXPECT_FALSE(parser.errors().empty()); EXPECT_TRUE(parser.Parse(kMissingAppId)); |