diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-12 05:54:34 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-12 05:54:34 +0000 |
commit | e2194749382acb33e16f9cb312feea67ab8a61f5 (patch) | |
tree | b7f3ab1cf6dece5b8b47993ac5f2e2a1961f5986 /chrome/browser/extensions | |
parent | 0c71e930267d4542ea1b05636773927a79f5bab4 (diff) | |
download | chromium_src-e2194749382acb33e16f9cb312feea67ab8a61f5.zip chromium_src-e2194749382acb33e16f9cb312feea67ab8a61f5.tar.gz chromium_src-e2194749382acb33e16f9cb312feea67ab8a61f5.tar.bz2 |
Remove wchar_t* methods from prefs.
BUG=23581
TEST=builds and passes tests
Review URL: http://codereview.chromium.org/3136004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55848 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r-- | chrome/browser/extensions/extension_dom_ui.cc | 4 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_dom_ui.h | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_override_apitest.cc | 6 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_prefs.cc | 68 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_prefs.h | 6 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_service_unittest.cc | 184 |
6 files changed, 131 insertions, 139 deletions
diff --git a/chrome/browser/extensions/extension_dom_ui.cc b/chrome/browser/extensions/extension_dom_ui.cc index 4a5f24c..b23d12c 100644 --- a/chrome/browser/extensions/extension_dom_ui.cc +++ b/chrome/browser/extensions/extension_dom_ui.cc @@ -117,8 +117,8 @@ class ExtensionDOMUIImageLoadingTracker : public ImageLoadingTracker::Observer { } // namespace -const wchar_t ExtensionDOMUI::kExtensionURLOverrides[] = - L"extensions.chrome_url_overrides"; +const char ExtensionDOMUI::kExtensionURLOverrides[] = + "extensions.chrome_url_overrides"; ExtensionDOMUI::ExtensionDOMUI(TabContents* tab_contents) : DOMUI(tab_contents) { diff --git a/chrome/browser/extensions/extension_dom_ui.h b/chrome/browser/extensions/extension_dom_ui.h index 343a486..e0698e7 100644 --- a/chrome/browser/extensions/extension_dom_ui.h +++ b/chrome/browser/extensions/extension_dom_ui.h @@ -27,7 +27,7 @@ class ExtensionDOMUI : public DOMUI, public ExtensionFunctionDispatcher::Delegate { public: - static const wchar_t kExtensionURLOverrides[]; + static const char kExtensionURLOverrides[]; explicit ExtensionDOMUI(TabContents* tab_contents); diff --git a/chrome/browser/extensions/extension_override_apitest.cc b/chrome/browser/extensions/extension_override_apitest.cc index 3063975..3e5369a 100644 --- a/chrome/browser/extensions/extension_override_apitest.cc +++ b/chrome/browser/extensions/extension_override_apitest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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. @@ -22,7 +22,7 @@ class ExtensionOverrideTest : public ExtensionApiTest { ExtensionDOMUI::kExtensionURLOverrides); ListValue* values = NULL; - if (!overrides->GetList(L"history", &values)) + if (!overrides->GetList("history", &values)) return false; std::set<std::string> seen_overrides; @@ -120,7 +120,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, ShouldCleanUpDuplicateEntries) { list->Append(Value::CreateStringValue("http://www.google.com/")); browser()->profile()->GetPrefs()->GetMutableDictionary( - ExtensionDOMUI::kExtensionURLOverrides)->Set(L"history", list); + ExtensionDOMUI::kExtensionURLOverrides)->Set("history", list); ASSERT_FALSE(CheckHistoryOverridesContainsNoDupes()); diff --git a/chrome/browser/extensions/extension_prefs.cc b/chrome/browser/extensions/extension_prefs.cc index f8dbc59..e987065 100644 --- a/chrome/browser/extensions/extension_prefs.cc +++ b/chrome/browser/extensions/extension_prefs.cc @@ -18,67 +18,68 @@ namespace { // A preference that keeps track of per-extension settings. This is a dictionary // object read from the Preferences file, keyed off of extension id's. -const wchar_t kExtensionsPref[] = L"extensions.settings"; +const char kExtensionsPref[] = "extensions.settings"; // Where an extension was installed from. (see Extension::Location) -const wchar_t kPrefLocation[] = L"location"; +const char kPrefLocation[] = "location"; // Enabled, disabled, killed, etc. (see Extension::State) -const wchar_t kPrefState[] = L"state"; +const char kPrefState[] = "state"; // The path to the current version's manifest file. -const wchar_t kPrefPath[] = L"path"; +const char kPrefPath[] = "path"; // The dictionary containing the extension's manifest. -const wchar_t kPrefManifest[] = L"manifest"; +const char kPrefManifest[] = "manifest"; // The version number. -const wchar_t kPrefVersion[] = L"manifest.version"; +const char kPrefVersion[] = "manifest.version"; // Indicates if an extension is blacklisted: -const wchar_t kPrefBlacklist[] = L"blacklist"; +const char kPrefBlacklist[] = "blacklist"; // Indicates whether to show an install warning when the user enables. -const wchar_t kExtensionDidEscalatePermissions[] = L"install_warning_on_enable"; +const char kExtensionDidEscalatePermissions[] = "install_warning_on_enable"; // A preference that tracks extension shelf configuration. This is a list // object read from the Preferences file, containing a list of toolstrip URLs. -const wchar_t kExtensionShelf[] = L"extensions.shelf"; +const char kExtensionShelf[] = "extensions.shelf"; // A preference that tracks admin policy regarding which extensions the user // can and can not install. This preference is a list object, containing // strings that list extension ids. Denylist can contain "*" meaning all // extensions. -const wchar_t kExtensionInstallAllowList[] = L"extensions.install.allowlist"; -const wchar_t kExtensionInstallDenyList[] = L"extensions.install.denylist"; +const char kExtensionInstallAllowList[] = "extensions.install.allowlist"; +const char kExtensionInstallDenyList[] = "extensions.install.denylist"; // A preference that tracks browser action toolbar configuration. This is a list // object stored in the Preferences file. The extensions are stored by ID. -const wchar_t kExtensionToolbar[] = L"extensions.toolbar"; +const char kExtensionToolbar[] = "extensions.toolbar"; // The key for a serialized Time value indicating the start of the day (from the // server's perspective) an extension last included a "ping" parameter during // its update check. -const wchar_t kLastPingDay[] = L"lastpingday"; +const char kLastPingDay[] = "lastpingday"; // Path for settings specific to blacklist update. -const wchar_t kExtensionsBlacklistUpdate[] = L"extensions.blacklistupdate"; +const char kExtensionsBlacklistUpdate[] = "extensions.blacklistupdate"; // Path and sub-keys for the idle install info dictionary preference. -const wchar_t kIdleInstallInfo[] = L"idle_install_info"; -const wchar_t kIdleInstallInfoCrxPath[] = L"crx_path"; -const wchar_t kIdleInstallInfoVersion[] = L"version"; -const wchar_t kIdleInstallInfoFetchTime[] = L"fetch_time"; +const char kIdleInstallInfo[] = "idle_install_info"; +const char kIdleInstallInfoCrxPath[] = "crx_path"; +const char kIdleInstallInfoVersion[] = "version"; +const char kIdleInstallInfoFetchTime[] = "fetch_time"; // A preference that, if true, will allow this extension to run in incognito // mode. -const wchar_t kPrefIncognitoEnabled[] = L"incognito"; +const char kPrefIncognitoEnabled[] = "incognito"; // A preference to control whether an extension is allowed to inject script in // pages with file URLs. -const wchar_t kPrefAllowFileAccess[] = L"allowFileAccess"; -} +const char kPrefAllowFileAccess[] = "allowFileAccess"; + +} // namespace //////////////////////////////////////////////////////////////////////////////// @@ -207,7 +208,7 @@ DictionaryValue* ExtensionPrefs::CopyCurrentExtensions() { } bool ExtensionPrefs::ReadBooleanFromPref( - DictionaryValue* ext, const std::wstring& pref_key) { + DictionaryValue* ext, const std::string& pref_key) { if (!ext->HasKey(pref_key)) return false; bool bool_value = false; if (!ext->GetBoolean(pref_key, &bool_value)) { @@ -219,7 +220,7 @@ bool ExtensionPrefs::ReadBooleanFromPref( } bool ExtensionPrefs::ReadExtensionPrefBoolean( - const std::string& extension_id, const std::wstring& pref_key) { + const std::string& extension_id, const std::string& pref_key) { const DictionaryValue* extensions = prefs_->GetDictionary(kExtensionsPref); if (!extensions) return false; @@ -574,15 +575,15 @@ FilePath ExtensionPrefs::GetExtensionPath(const std::string& extension_id) { if (!dict || dict->empty()) return FilePath(); - std::wstring path; - if (!dict->GetString(ASCIIToWide(extension_id) + L"." + kPrefPath, &path)) + std::string path; + if (!dict->GetString(extension_id + "." + kPrefPath, &path)) return FilePath(); - return install_directory_.Append(FilePath::FromWStringHack(path)); + return install_directory_.Append(FilePath::FromWStringHack(UTF8ToWide(path))); } void ExtensionPrefs::UpdateExtensionPref(const std::string& extension_id, - const std::wstring& key, + const std::string& key, Value* data_value) { if (!Extension::IdIsValid(extension_id)) { NOTREACHED() << "Invalid extension_id " << extension_id; @@ -593,10 +594,9 @@ void ExtensionPrefs::UpdateExtensionPref(const std::string& extension_id, } void ExtensionPrefs::DeleteExtensionPrefs(const std::string& extension_id) { - std::wstring id = ASCIIToWide(extension_id); DictionaryValue* dict = prefs_->GetMutableDictionary(kExtensionsPref); - if (dict->HasKey(id)) { - dict->Remove(id, NULL); + if (dict->HasKey(extension_id)) { + dict->Remove(extension_id, NULL); prefs_->ScheduleSavePersistentPrefs(); } } @@ -606,11 +606,10 @@ DictionaryValue* ExtensionPrefs::GetOrCreateExtensionPref( DCHECK(Extension::IdIsValid(extension_id)); DictionaryValue* dict = prefs_->GetMutableDictionary(kExtensionsPref); DictionaryValue* extension = NULL; - std::wstring id = ASCIIToWide(extension_id); - if (!dict->GetDictionary(id, &extension)) { + if (!dict->GetDictionary(extension_id, &extension)) { // Extension pref does not exist, create it. extension = new DictionaryValue(); - dict->Set(id, extension); + dict->Set(extension_id, extension); } return extension; } @@ -621,8 +620,7 @@ DictionaryValue* ExtensionPrefs::GetExtensionPref( if (!dict) return NULL; DictionaryValue* extension = NULL; - std::wstring id = ASCIIToWide(extension_id); - dict->GetDictionary(id, &extension); + dict->GetDictionary(extension_id, &extension); return extension; } diff --git a/chrome/browser/extensions/extension_prefs.h b/chrome/browser/extensions/extension_prefs.h index f61cdc1..de900fe 100644 --- a/chrome/browser/extensions/extension_prefs.h +++ b/chrome/browser/extensions/extension_prefs.h @@ -163,7 +163,7 @@ class ExtensionPrefs { // Sets the pref |key| for extension |id| to |value|. void UpdateExtensionPref(const std::string& id, - const std::wstring& key, + const std::string& key, Value* value); // Deletes the pref dictionary for extension |id|. @@ -171,11 +171,11 @@ class ExtensionPrefs { // Reads a boolean pref from |ext| with key |pref_key|. // Return false if the value is false or kPrefBlacklist does not exist. - bool ReadBooleanFromPref(DictionaryValue* ext, const std::wstring& pref_key); + bool ReadBooleanFromPref(DictionaryValue* ext, const std::string& pref_key); // Reads a boolean pref |pref_key| from extension with id |extension_id|. bool ReadExtensionPrefBoolean(const std::string& extension_id, - const std::wstring& pref_key); + const std::string& pref_key); // Ensures and returns a mutable dictionary for extension |id|'s prefs. DictionaryValue* GetOrCreateExtensionPref(const std::string& id); diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc index 15e5eef..c23f451 100644 --- a/chrome/browser/extensions/extensions_service_unittest.cc +++ b/chrome/browser/extensions/extensions_service_unittest.cc @@ -159,7 +159,7 @@ class MockProviderVisitor : public ExternalExtensionProvider::Visitor { Value* json_value = serializer.Deserialize(NULL, NULL); if (!json_value || !json_value->IsType(Value::TYPE_DICTIONARY)) { - NOTREACHED() << L"Unable to deserialize json data"; + NOTREACHED() << "Unable to deserialize json data"; return -1; } else { DictionaryValue* external_extensions = @@ -185,8 +185,8 @@ class MockProviderVisitor : public ExternalExtensionProvider::Visitor { // This tests is to make sure that the provider only notifies us of the // values we gave it. So if the id we doesn't exist in our internal // dictionary then something is wrong. - EXPECT_TRUE(prefs_->GetDictionary(ASCIIToWide(id), &pref)) - << L"Got back ID (" << id.c_str() << ") we weren't expecting"; + EXPECT_TRUE(prefs_->GetDictionary(id, &pref)) + << "Got back ID (" << id.c_str() << ") we weren't expecting"; if (pref) { // Ask provider if the extension we got back is registered. @@ -198,7 +198,7 @@ class MockProviderVisitor : public ExternalExtensionProvider::Visitor { EXPECT_EQ(Extension::EXTERNAL_PREF, location); // Remove it so we won't count it ever again. - prefs_->Remove(ASCIIToWide(id), NULL); + prefs_->Remove(id, NULL); } } @@ -485,26 +485,25 @@ class ExtensionsServiceTest void ValidatePrefKeyCount(size_t count) { DictionaryValue* dict = - prefs_->GetMutableDictionary(L"extensions.settings"); + prefs_->GetMutableDictionary("extensions.settings"); ASSERT_TRUE(dict != NULL); EXPECT_EQ(count, dict->size()); } void ValidateBooleanPref(const std::string& extension_id, - const std::wstring& pref_path, + const std::string& pref_path, bool expected_val) { - std::wstring msg = L" while checking: "; - msg += ASCIIToWide(extension_id); - msg += L" "; + std::string msg = " while checking: "; + msg += extension_id; + msg += " "; msg += pref_path; - msg += L" == "; - msg += expected_val ? L"true" : L"false"; + msg += " == "; + msg += expected_val ? "true" : "false"; - const DictionaryValue* dict = - prefs_->GetDictionary(L"extensions.settings"); + const DictionaryValue* dict = prefs_->GetDictionary("extensions.settings"); ASSERT_TRUE(dict != NULL) << msg; DictionaryValue* pref = NULL; - ASSERT_TRUE(dict->GetDictionary(ASCIIToWide(extension_id), &pref)) << msg; + ASSERT_TRUE(dict->GetDictionary(extension_id, &pref)) << msg; EXPECT_TRUE(pref != NULL) << msg; bool val; ASSERT_TRUE(pref->GetBoolean(pref_path, &val)) << msg; @@ -512,12 +511,11 @@ class ExtensionsServiceTest } bool IsPrefExist(const std::string& extension_id, - const std::wstring& pref_path) { - const DictionaryValue* dict = - prefs_->GetDictionary(L"extensions.settings"); + const std::string& pref_path) { + const DictionaryValue* dict = prefs_->GetDictionary("extensions.settings"); if (dict == NULL) return false; DictionaryValue* pref = NULL; - if (!dict->GetDictionary(ASCIIToWide(extension_id), &pref)) { + if (!dict->GetDictionary(extension_id, &pref)) { return false; } if (pref == NULL) { @@ -531,20 +529,19 @@ class ExtensionsServiceTest } void ValidateIntegerPref(const std::string& extension_id, - const std::wstring& pref_path, + const std::string& pref_path, int expected_val) { - std::wstring msg = L" while checking: "; - msg += ASCIIToWide(extension_id); - msg += L" "; + std::string msg = " while checking: "; + msg += extension_id; + msg += " "; msg += pref_path; - msg += L" == "; - msg += UTF8ToWide(base::IntToString(expected_val)); + msg += " == "; + msg += base::IntToString(expected_val); - const DictionaryValue* dict = - prefs_->GetDictionary(L"extensions.settings"); + const DictionaryValue* dict = prefs_->GetDictionary("extensions.settings"); ASSERT_TRUE(dict != NULL) << msg; DictionaryValue* pref = NULL; - ASSERT_TRUE(dict->GetDictionary(ASCIIToWide(extension_id), &pref)) << msg; + ASSERT_TRUE(dict->GetDictionary(extension_id, &pref)) << msg; EXPECT_TRUE(pref != NULL) << msg; int val; ASSERT_TRUE(pref->GetInteger(pref_path, &val)) << msg; @@ -552,21 +549,20 @@ class ExtensionsServiceTest } void ValidateStringPref(const std::string& extension_id, - const std::wstring& pref_path, + const std::string& pref_path, const std::string& expected_val) { - std::wstring msg = L" while checking: "; - msg += ASCIIToWide(extension_id); - msg += L".manifest."; + std::string msg = " while checking: "; + msg += extension_id; + msg += ".manifest."; msg += pref_path; - msg += L" == "; - msg += ASCIIToWide(expected_val); + msg += " == "; + msg += expected_val; - const DictionaryValue* dict = - prefs_->GetDictionary(L"extensions.settings"); + const DictionaryValue* dict = prefs_->GetDictionary("extensions.settings"); ASSERT_TRUE(dict != NULL) << msg; DictionaryValue* pref = NULL; std::string manifest_path = extension_id + ".manifest"; - ASSERT_TRUE(dict->GetDictionary(ASCIIToWide(manifest_path), &pref)) << msg; + ASSERT_TRUE(dict->GetDictionary(manifest_path, &pref)) << msg; EXPECT_TRUE(pref != NULL) << msg; std::string val; ASSERT_TRUE(pref->GetString(pref_path, &val)) << msg; @@ -574,20 +570,20 @@ class ExtensionsServiceTest } void SetPrefInteg(const std::string& extension_id, - const std::wstring& pref_path, + const std::string& pref_path, int value) { - std::wstring msg = L" while setting: "; - msg += ASCIIToWide(extension_id); - msg += L" "; + std::string msg = " while setting: "; + msg += extension_id; + msg += " "; msg += pref_path; - msg += L" = "; - msg += UTF8ToWide(base::IntToString(value)); + msg += " = "; + msg += base::IntToString(value); const DictionaryValue* dict = - prefs_->GetMutableDictionary(L"extensions.settings"); + prefs_->GetMutableDictionary("extensions.settings"); ASSERT_TRUE(dict != NULL) << msg; DictionaryValue* pref = NULL; - ASSERT_TRUE(dict->GetDictionary(ASCIIToWide(extension_id), &pref)) << msg; + ASSERT_TRUE(dict->GetDictionary(extension_id, &pref)) << msg; EXPECT_TRUE(pref != NULL) << msg; pref->SetInteger(pref_path, value); } @@ -680,12 +676,12 @@ TEST_F(ExtensionsServiceTest, LoadAllExtensionsFromDirectorySuccess) { EXPECT_EQ(3u, service_->extensions()->size()); ValidatePrefKeyCount(3); - ValidateIntegerPref(good0, L"state", Extension::ENABLED); - ValidateIntegerPref(good0, L"location", Extension::INTERNAL); - ValidateIntegerPref(good1, L"state", Extension::ENABLED); - ValidateIntegerPref(good1, L"location", Extension::INTERNAL); - ValidateIntegerPref(good2, L"state", Extension::ENABLED); - ValidateIntegerPref(good2, L"location", Extension::INTERNAL); + ValidateIntegerPref(good0, "state", Extension::ENABLED); + ValidateIntegerPref(good0, "location", Extension::INTERNAL); + ValidateIntegerPref(good1, "state", Extension::ENABLED); + ValidateIntegerPref(good1, "location", Extension::INTERNAL); + ValidateIntegerPref(good2, "state", Extension::ENABLED); + ValidateIntegerPref(good2, "location", Extension::INTERNAL); Extension* extension = loaded_[0]; const UserScriptList& scripts = extension->content_scripts(); @@ -811,9 +807,9 @@ TEST_F(ExtensionsServiceTest, CleanupOnStartup) { InitializeInstalledExtensionsService(pref_path, source_install_dir); // Simulate that one of them got partially deleted by clearing its pref. - DictionaryValue* dict = prefs_->GetMutableDictionary(L"extensions.settings"); + DictionaryValue* dict = prefs_->GetMutableDictionary("extensions.settings"); ASSERT_TRUE(dict != NULL); - dict->Remove(L"behllobkkfkfnphdnhnkndlbkcpglgmj", NULL); + dict->Remove("behllobkkfkfnphdnhnkndlbkcpglgmj", NULL); service_->Init(); loop_.RunAllPending(); @@ -858,15 +854,15 @@ TEST_F(ExtensionsServiceTest, InstallExtension) { int pref_count = 0; ValidatePrefKeyCount(++pref_count); - ValidateIntegerPref(good_crx, L"state", Extension::ENABLED); - ValidateIntegerPref(good_crx, L"location", Extension::INTERNAL); + ValidateIntegerPref(good_crx, "state", Extension::ENABLED); + ValidateIntegerPref(good_crx, "location", Extension::INTERNAL); // An extension with page actions. path = extensions_path.AppendASCII("page_action.crx"); InstallExtension(path, true); ValidatePrefKeyCount(++pref_count); - ValidateIntegerPref(page_action, L"state", Extension::ENABLED); - ValidateIntegerPref(page_action, L"location", Extension::INTERNAL); + ValidateIntegerPref(page_action, "state", Extension::ENABLED); + ValidateIntegerPref(page_action, "location", Extension::INTERNAL); // Bad signature. path = extensions_path.AppendASCII("bad_signature.crx"); @@ -1095,8 +1091,8 @@ TEST_F(ExtensionsServiceTest, InstallTheme) { InstallExtension(path, true); int pref_count = 0; ValidatePrefKeyCount(++pref_count); - ValidateIntegerPref(theme_crx, L"state", Extension::ENABLED); - ValidateIntegerPref(theme_crx, L"location", Extension::INTERNAL); + ValidateIntegerPref(theme_crx, "state", Extension::ENABLED); + ValidateIntegerPref(theme_crx, "location", Extension::INTERNAL); // A theme when extensions are disabled. Themes can be installed, even when // extensions are disabled. @@ -1104,8 +1100,8 @@ TEST_F(ExtensionsServiceTest, InstallTheme) { path = extensions_path.AppendASCII("theme2.crx"); InstallExtension(path, true); ValidatePrefKeyCount(++pref_count); - ValidateIntegerPref(theme2_crx, L"state", Extension::ENABLED); - ValidateIntegerPref(theme2_crx, L"location", Extension::INTERNAL); + ValidateIntegerPref(theme2_crx, "state", Extension::ENABLED); + ValidateIntegerPref(theme2_crx, "location", Extension::INTERNAL); // A theme with extension elements. Themes cannot have extension elements so // this test should fail. @@ -1166,8 +1162,8 @@ TEST_F(ExtensionsServiceTest, InstallApps) { ValidatePrefKeyCount(++pref_count); ASSERT_EQ(1u, service_->extensions()->size()); std::string id = service_->extensions()->at(0)->id(); - ValidateIntegerPref(id, L"state", Extension::ENABLED); - ValidateIntegerPref(id, L"location", Extension::INTERNAL); + ValidateIntegerPref(id, "state", Extension::ENABLED); + ValidateIntegerPref(id, "location", Extension::INTERNAL); // Another app with non-overlapping extent. Should succeed. PackAndInstallExtension(extensions_path.AppendASCII("app2"), true); @@ -1195,8 +1191,8 @@ TEST_F(ExtensionsServiceTest, Reinstall) { ASSERT_EQ(1u, loaded_.size()); ASSERT_EQ(0u, GetErrors().size()); ValidatePrefKeyCount(1); - ValidateIntegerPref(good_crx, L"state", Extension::ENABLED); - ValidateIntegerPref(good_crx, L"location", Extension::INTERNAL); + ValidateIntegerPref(good_crx, "state", Extension::ENABLED); + ValidateIntegerPref(good_crx, "location", Extension::INTERNAL); installed_ = NULL; loaded_.clear(); @@ -1210,8 +1206,8 @@ TEST_F(ExtensionsServiceTest, Reinstall) { ASSERT_EQ(1u, loaded_.size()); ASSERT_EQ(0u, GetErrors().size()); ValidatePrefKeyCount(1); - ValidateIntegerPref(good_crx, L"state", Extension::ENABLED); - ValidateIntegerPref(good_crx, L"location", Extension::INTERNAL); + ValidateIntegerPref(good_crx, "state", Extension::ENABLED); + ValidateIntegerPref(good_crx, "location", Extension::INTERNAL); } // Test upgrading a signed extension. @@ -1526,10 +1522,10 @@ TEST_F(ExtensionsServiceTest, SetUnsetBlacklistInPrefs) { loop_.RunAllPending(); // blacklist is set for good0,1,2 - ValidateBooleanPref(good0, L"blacklist", true); - ValidateBooleanPref(good1, L"blacklist", true); + ValidateBooleanPref(good0, "blacklist", true); + ValidateBooleanPref(good1, "blacklist", true); // invalid_id should not be inserted to pref. - EXPECT_FALSE(IsPrefExist("invalid_id", L"blacklist")); + EXPECT_FALSE(IsPrefExist("invalid_id", "blacklist")); // remove good1, add good2 blacklist.pop_back(); @@ -1537,10 +1533,10 @@ TEST_F(ExtensionsServiceTest, SetUnsetBlacklistInPrefs) { service_->UpdateExtensionBlacklist(blacklist); // only good0 and good1 should be set - ValidateBooleanPref(good0, L"blacklist", true); - EXPECT_FALSE(IsPrefExist(good1, L"blacklist")); - ValidateBooleanPref(good2, L"blacklist", true); - EXPECT_FALSE(IsPrefExist("invalid_id", L"blacklist")); + ValidateBooleanPref(good0, "blacklist", true); + EXPECT_FALSE(IsPrefExist(good1, "blacklist")); + ValidateBooleanPref(good2, "blacklist", true); + EXPECT_FALSE(IsPrefExist("invalid_id", "blacklist")); } // Unload installed extension from blacklist. @@ -1564,7 +1560,7 @@ TEST_F(ExtensionsServiceTest, UnloadBlacklistedExtension) { loop_.RunAllPending(); // Now, the good_crx is blacklisted. - ValidateBooleanPref(good_crx, L"blacklist", true); + ValidateBooleanPref(good_crx, "blacklist", true); EXPECT_EQ(0u, service_->extensions()->size()); // Remove good_crx from blacklist @@ -1573,7 +1569,7 @@ TEST_F(ExtensionsServiceTest, UnloadBlacklistedExtension) { // Make sure pref is updated loop_.RunAllPending(); // blacklist value should not be set for good_crx - EXPECT_FALSE(IsPrefExist(good_crx, L"blacklist")); + EXPECT_FALSE(IsPrefExist(good_crx, "blacklist")); } // Unload installed extension from blacklist. @@ -1586,7 +1582,7 @@ TEST_F(ExtensionsServiceTest, BlacklistedExtensionWillNotInstall) { loop_.RunAllPending(); // Now, the good_crx is blacklisted. - ValidateBooleanPref(good_crx, L"blacklist", true); + ValidateBooleanPref(good_crx, "blacklist", true); // We can not install good_crx. FilePath extensions_path; @@ -1596,7 +1592,7 @@ TEST_F(ExtensionsServiceTest, BlacklistedExtensionWillNotInstall) { service_->InstallExtension(path); loop_.RunAllPending(); EXPECT_EQ(0u, service_->extensions()->size()); - ValidateBooleanPref(good_crx, L"blacklist", true); + ValidateBooleanPref(good_crx, "blacklist", true); } // Test loading extensions from the profile directory, except @@ -1621,7 +1617,7 @@ TEST_F(ExtensionsServiceTest, WillNotLoadBlacklistedExtensionsFromDirectory) { // Make sure pref is updated loop_.RunAllPending(); - ValidateBooleanPref(good0, L"blacklist", true); + ValidateBooleanPref(good0, "blacklist", true); // Load extensions. service_->Init(); @@ -1642,10 +1638,8 @@ TEST_F(ExtensionsServiceTest, WillNotLoadBlacklistedExtensionsFromDirectory) { TEST_F(ExtensionsServiceTest, BlacklistedByPolicyWillNotInstall) { InitializeEmptyExtensionsService(); - ListValue* whitelist = prefs_->GetMutableList( - L"extensions.install.allowlist"); - ListValue* blacklist = prefs_->GetMutableList( - L"extensions.install.denylist"); + ListValue* whitelist = prefs_->GetMutableList("extensions.install.allowlist"); + ListValue* blacklist = prefs_->GetMutableList("extensions.install.denylist"); ASSERT_TRUE(whitelist != NULL && blacklist != NULL); // Blacklist everything. @@ -1750,8 +1744,8 @@ TEST_F(ExtensionsServiceTest, UninstallExtension) { EXPECT_TRUE(file_util::PathExists(extension_path)); ValidatePrefKeyCount(1); - ValidateIntegerPref(good_crx, L"state", Extension::ENABLED); - ValidateIntegerPref(good_crx, L"location", Extension::INTERNAL); + ValidateIntegerPref(good_crx, "state", Extension::ENABLED); + ValidateIntegerPref(good_crx, "location", Extension::INTERNAL); // Uninstall it. service_->UninstallExtension(extension_id, false); @@ -1932,8 +1926,8 @@ void ExtensionsServiceTest::TestExternalProvider( ASSERT_EQ(location, loaded_[0]->location()); ASSERT_EQ("1.0.0.0", loaded_[0]->version()->GetString()); ValidatePrefKeyCount(1); - ValidateIntegerPref(good_crx, L"state", Extension::ENABLED); - ValidateIntegerPref(good_crx, L"location", location); + ValidateIntegerPref(good_crx, "state", Extension::ENABLED); + ValidateIntegerPref(good_crx, "location", location); // Reload extensions without changing anything. The extension should be // loaded again. @@ -1943,8 +1937,8 @@ void ExtensionsServiceTest::TestExternalProvider( ASSERT_EQ(0u, GetErrors().size()); ASSERT_EQ(1u, loaded_.size()); ValidatePrefKeyCount(1); - ValidateIntegerPref(good_crx, L"state", Extension::ENABLED); - ValidateIntegerPref(good_crx, L"location", location); + ValidateIntegerPref(good_crx, "state", Extension::ENABLED); + ValidateIntegerPref(good_crx, "location", location); // Now update the extension with a new version. We should get upgraded. source_path = source_path.DirName().AppendASCII("good2.crx"); @@ -1957,8 +1951,8 @@ void ExtensionsServiceTest::TestExternalProvider( ASSERT_EQ(1u, loaded_.size()); ASSERT_EQ("1.0.0.1", loaded_[0]->version()->GetString()); ValidatePrefKeyCount(1); - ValidateIntegerPref(good_crx, L"state", Extension::ENABLED); - ValidateIntegerPref(good_crx, L"location", location); + ValidateIntegerPref(good_crx, "state", Extension::ENABLED); + ValidateIntegerPref(good_crx, "location", location); // Uninstall the extension and reload. Nothing should happen because the // preference should prevent us from reinstalling. @@ -1975,11 +1969,11 @@ void ExtensionsServiceTest::TestExternalProvider( loop_.RunAllPending(); ASSERT_EQ(0u, loaded_.size()); ValidatePrefKeyCount(1); - ValidateIntegerPref(good_crx, L"state", Extension::KILLBIT); - ValidateIntegerPref(good_crx, L"location", location); + ValidateIntegerPref(good_crx, "state", Extension::KILLBIT); + ValidateIntegerPref(good_crx, "location", location); // Now clear the preference and reinstall. - SetPrefInteg(good_crx, L"state", Extension::ENABLED); + SetPrefInteg(good_crx, "state", Extension::ENABLED); prefs_->ScheduleSavePersistentPrefs(); loaded_.clear(); @@ -1987,8 +1981,8 @@ void ExtensionsServiceTest::TestExternalProvider( loop_.RunAllPending(); ASSERT_EQ(1u, loaded_.size()); ValidatePrefKeyCount(1); - ValidateIntegerPref(good_crx, L"state", Extension::ENABLED); - ValidateIntegerPref(good_crx, L"location", location); + ValidateIntegerPref(good_crx, "state", Extension::ENABLED); + ValidateIntegerPref(good_crx, "location", location); // Now test an externally triggered uninstall (deleting the registry key or // the pref entry). |