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/common/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/common/extensions')
-rw-r--r-- | chrome/common/extensions/extension.cc | 27 | ||||
-rw-r--r-- | chrome/common/extensions/extension.h | 4 | ||||
-rw-r--r-- | chrome/common/extensions/extension_constants.cc | 118 | ||||
-rw-r--r-- | chrome/common/extensions/extension_constants.h | 120 | ||||
-rw-r--r-- | chrome/common/extensions/extension_l10n_util.cc | 8 | ||||
-rw-r--r-- | chrome/common/extensions/extension_l10n_util_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/common/extensions/extension_unittest.cc | 8 |
7 files changed, 144 insertions, 145 deletions
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index acb88f4..f494c67 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -81,7 +81,7 @@ const FilePath::CharType Extension::kMessagesFilename[] = FILE_PATH_LITERAL("messages.json"); // A list of all the keys allowed by themes. -static const wchar_t* kValidThemeKeys[] = { +static const char* kValidThemeKeys[] = { keys::kCurrentLocale, keys::kDefaultLocale, keys::kDescription, @@ -362,7 +362,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script, bool Extension::LoadGlobsHelper( const DictionaryValue* content_script, int content_script_index, - const wchar_t* globs_property_name, + const char* globs_property_name, std::string* error, void(UserScript::*add_method)(const std::string& glob), UserScript *instance) { @@ -373,7 +373,7 @@ bool Extension::LoadGlobsHelper( if (!content_script->GetList(globs_property_name, &list)) { *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidGlobList, base::IntToString(content_script_index), - WideToUTF8(globs_property_name)); + globs_property_name); return false; } @@ -382,7 +382,7 @@ bool Extension::LoadGlobsHelper( if (!list->GetString(i, &glob)) { *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidGlob, base::IntToString(content_script_index), - WideToUTF8(globs_property_name), + globs_property_name, base::IntToString(i)); return false; } @@ -457,7 +457,7 @@ ExtensionAction* Extension::LoadExtensionActionHelper( result->SetTitle(ExtensionAction::kDefaultTabId, title); // Read the action's |popup| (optional). - const wchar_t* popup_key = NULL; + const char* popup_key = NULL; if (extension_action->HasKey(keys::kPageActionDefaultPopup)) popup_key = keys::kPageActionDefaultPopup; @@ -467,8 +467,8 @@ ExtensionAction* Extension::LoadExtensionActionHelper( if (popup_key) { *error = ExtensionErrorUtils::FormatErrorMessage( errors::kInvalidPageActionOldAndNewKeys, - WideToASCII(keys::kPageActionDefaultPopup), - WideToASCII(keys::kPageActionPopup)); + keys::kPageActionDefaultPopup, + keys::kPageActionPopup); return NULL; } popup_key = keys::kPageActionPopup; @@ -517,8 +517,7 @@ bool Extension::ContainsNonThemeKeys(const DictionaryValue& source) { static bool theme_key_mapped = false; if (!theme_key_mapped) { for (size_t i = 0; i < arraysize(kValidThemeKeys); ++i) { - // TODO(viettrungluu): Make the constants |char*|s and avoid converting. - theme_keys[WideToUTF8(kValidThemeKeys[i])] = true; + theme_keys[kValidThemeKeys[i]] = true; } theme_key_mapped = true; } @@ -549,7 +548,7 @@ bool Extension::LoadIsApp(const DictionaryValue* manifest, } bool Extension::LoadExtent(const DictionaryValue* manifest, - const wchar_t* key, + const char* key, ExtensionExtent* extent, const char* list_error, const char* value_error, @@ -996,13 +995,13 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key, } // Initialize name. - std::wstring localized_name; + string16 localized_name; if (!source.GetString(keys::kName, &localized_name)) { *error = errors::kInvalidName; return false; } base::i18n::AdjustStringForLocaleDirection(localized_name, &localized_name); - name_ = WideToUTF8(localized_name); + name_ = UTF16ToUTF8(localized_name); // Initialize description (if present). if (source.HasKey(keys::kDescription)) { @@ -1081,12 +1080,12 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key, } for (size_t i = 0; i < arraysize(kIconSizes); ++i) { - std::wstring key = ASCIIToWide(base::IntToString(kIconSizes[i])); + std::string key = base::IntToString(kIconSizes[i]); if (icons_value->HasKey(key)) { std::string icon_path; if (!icons_value->GetString(key, &icon_path)) { *error = ExtensionErrorUtils::FormatErrorMessage( - errors::kInvalidIconPath, WideToASCII(key)); + errors::kInvalidIconPath, key); return false; } icons_[kIconSizes[i]] = icon_path; diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h index 9f3ca6c..d4ffbdb 100644 --- a/chrome/common/extensions/extension.h +++ b/chrome/common/extensions/extension.h @@ -410,14 +410,14 @@ class Extension { // from an entry in the content_script lists of the manifest. bool LoadGlobsHelper(const DictionaryValue* content_script, int content_script_index, - const wchar_t* globs_property_name, + const char* globs_property_name, std::string* error, void(UserScript::*add_method)(const std::string& glob), UserScript *instance); // Helpers to load various chunks of the manifest. bool LoadIsApp(const DictionaryValue* manifest, std::string* error); - bool LoadExtent(const DictionaryValue* manifest, const wchar_t* key, + bool LoadExtent(const DictionaryValue* manifest, const char* key, ExtensionExtent* extent, const char* list_error, const char* value_error, std::string* error); bool LoadLaunchContainer(const DictionaryValue* manifest, std::string* error); diff --git a/chrome/common/extensions/extension_constants.cc b/chrome/common/extensions/extension_constants.cc index ce4d74f..8c306c7 100644 --- a/chrome/common/extensions/extension_constants.cc +++ b/chrome/common/extensions/extension_constants.cc @@ -6,65 +6,65 @@ namespace extension_manifest_keys { -const wchar_t* kAllFrames = L"all_frames"; -const wchar_t* kApp = L"app"; -const wchar_t* kBackground = L"background_page"; -const wchar_t* kBrowserAction = L"browser_action"; -const wchar_t* kBrowseURLs = L"app.browse_urls"; -const wchar_t* kChromeURLOverrides = L"chrome_url_overrides"; -const wchar_t* kContentScripts = L"content_scripts"; -const wchar_t* kConvertedFromUserScript = L"converted_from_user_script"; -const wchar_t* kCss = L"css"; -const wchar_t* kCurrentLocale = L"current_locale"; -const wchar_t* kDefaultLocale = L"default_locale"; -const wchar_t* kDescription = L"description"; -const wchar_t* kDevToolsPage = L"devtools_page"; -const wchar_t* kExcludeGlobs = L"exclude_globs"; -const wchar_t* kIcons = L"icons"; -const wchar_t* kIncludeGlobs = L"include_globs"; -const wchar_t* kJs = L"js"; -const wchar_t* kLaunch = L"app.launch"; -const wchar_t* kLaunchContainer = L"app.launch.container"; -const wchar_t* kLaunchFullscreen = L"app.launch.fullscreen"; -const wchar_t* kLaunchHeight = L"app.launch.height"; -const wchar_t* kLaunchLocalPath = L"app.launch.local_path"; -const wchar_t* kLaunchWebURL = L"app.launch.web_url"; -const wchar_t* kLaunchWidth = L"app.launch.width"; -const wchar_t* kMatches = L"matches"; -const wchar_t* kMinimumChromeVersion = L"minimum_chrome_version"; -const wchar_t* kName = L"name"; -const wchar_t* kOmniboxKeyword = L"omnibox_keyword"; -const wchar_t* kOptionsPage = L"options_page"; -const wchar_t* kPageAction = L"page_action"; -const wchar_t* kPageActionDefaultIcon = L"default_icon"; -const wchar_t* kPageActionDefaultPopup = L"default_popup"; -const wchar_t* kPageActionDefaultTitle = L"default_title"; -const wchar_t* kPageActionIcons = L"icons"; -const wchar_t* kPageActionId = L"id"; -const wchar_t* kPageActionPopup = L"popup"; -const wchar_t* kPageActionPopupHeight = L"height"; -const wchar_t* kPageActionPopupPath = L"path"; -const wchar_t* kPageActions = L"page_actions"; -const wchar_t* kPermissions = L"permissions"; -const wchar_t* kPlugins = L"plugins"; -const wchar_t* kPluginsPath = L"path"; -const wchar_t* kPluginsPublic = L"public"; -const wchar_t* kPublicKey = L"key"; -const wchar_t* kRunAt = L"run_at"; -const wchar_t* kSignature = L"signature"; -const wchar_t* kTheme = L"theme"; -const wchar_t* kThemeColors = L"colors"; -const wchar_t* kThemeDisplayProperties = L"properties"; -const wchar_t* kThemeImages = L"images"; -const wchar_t* kThemeTints = L"tints"; -const wchar_t* kToolstripMoleHeight = L"mole_height"; -const wchar_t* kToolstripMolePath = L"mole"; -const wchar_t* kToolstripPath = L"path"; -const wchar_t* kToolstrips = L"toolstrips"; -const wchar_t* kType = L"type"; -const wchar_t* kUpdateURL = L"update_url"; -const wchar_t* kVersion = L"version"; -const wchar_t* kWebURLs = L"app.urls"; +const char* kAllFrames = "all_frames"; +const char* kApp = "app"; +const char* kBackground = "background_page"; +const char* kBrowserAction = "browser_action"; +const char* kBrowseURLs = "app.browse_urls"; +const char* kChromeURLOverrides = "chrome_url_overrides"; +const char* kContentScripts = "content_scripts"; +const char* kConvertedFromUserScript = "converted_from_user_script"; +const char* kCss = "css"; +const char* kCurrentLocale = "current_locale"; +const char* kDefaultLocale = "default_locale"; +const char* kDescription = "description"; +const char* kDevToolsPage = "devtools_page"; +const char* kExcludeGlobs = "exclude_globs"; +const char* kIcons = "icons"; +const char* kIncludeGlobs = "include_globs"; +const char* kJs = "js"; +const char* kLaunch = "app.launch"; +const char* kLaunchContainer = "app.launch.container"; +const char* kLaunchFullscreen = "app.launch.fullscreen"; +const char* kLaunchHeight = "app.launch.height"; +const char* kLaunchLocalPath = "app.launch.local_path"; +const char* kLaunchWebURL = "app.launch.web_url"; +const char* kLaunchWidth = "app.launch.width"; +const char* kMatches = "matches"; +const char* kMinimumChromeVersion = "minimum_chrome_version"; +const char* kName = "name"; +const char* kOmniboxKeyword = "omnibox_keyword"; +const char* kOptionsPage = "options_page"; +const char* kPageAction = "page_action"; +const char* kPageActionDefaultIcon = "default_icon"; +const char* kPageActionDefaultPopup = "default_popup"; +const char* kPageActionDefaultTitle = "default_title"; +const char* kPageActionIcons = "icons"; +const char* kPageActionId = "id"; +const char* kPageActionPopup = "popup"; +const char* kPageActionPopupHeight = "height"; +const char* kPageActionPopupPath = "path"; +const char* kPageActions = "page_actions"; +const char* kPermissions = "permissions"; +const char* kPlugins = "plugins"; +const char* kPluginsPath = "path"; +const char* kPluginsPublic = "public"; +const char* kPublicKey = "key"; +const char* kRunAt = "run_at"; +const char* kSignature = "signature"; +const char* kTheme = "theme"; +const char* kThemeColors = "colors"; +const char* kThemeDisplayProperties = "properties"; +const char* kThemeImages = "images"; +const char* kThemeTints = "tints"; +const char* kToolstripMoleHeight = "mole_height"; +const char* kToolstripMolePath = "mole"; +const char* kToolstripPath = "path"; +const char* kToolstrips = "toolstrips"; +const char* kType = "type"; +const char* kUpdateURL = "update_url"; +const char* kVersion = "version"; +const char* kWebURLs = "app.urls"; } // namespace extension_manifest_keys namespace extension_manifest_values { diff --git a/chrome/common/extensions/extension_constants.h b/chrome/common/extensions/extension_constants.h index bc85b3c..2b04abe 100644 --- a/chrome/common/extensions/extension_constants.h +++ b/chrome/common/extensions/extension_constants.h @@ -8,66 +8,66 @@ // Keys used in JSON representation of extensions. namespace extension_manifest_keys { - extern const wchar_t* kAllFrames; - extern const wchar_t* kApp; - extern const wchar_t* kBackground; - extern const wchar_t* kBrowserAction; - extern const wchar_t* kBrowseURLs; - extern const wchar_t* kChromeURLOverrides; - extern const wchar_t* kContentScripts; - extern const wchar_t* kConvertedFromUserScript; - extern const wchar_t* kCss; - extern const wchar_t* kCurrentLocale; - extern const wchar_t* kDefaultLocale; - extern const wchar_t* kDescription; - extern const wchar_t* kDevToolsPage; - extern const wchar_t* kExcludeGlobs; - extern const wchar_t* kIcons; - extern const wchar_t* kIncludeGlobs; - extern const wchar_t* kJs; - extern const wchar_t* kLaunch; - extern const wchar_t* kLaunchContainer; - extern const wchar_t* kLaunchFullscreen; - extern const wchar_t* kLaunchHeight; - extern const wchar_t* kLaunchLocalPath; - extern const wchar_t* kLaunchWebURL; - extern const wchar_t* kLaunchWidth; - extern const wchar_t* kMatches; - extern const wchar_t* kMinimumChromeVersion; - extern const wchar_t* kName; - extern const wchar_t* kOmniboxKeyword; - extern const wchar_t* kOptionsPage; - extern const wchar_t* kPageAction; - extern const wchar_t* kPageActionDefaultIcon; - extern const wchar_t* kPageActionDefaultPopup; - extern const wchar_t* kPageActionDefaultTitle; - extern const wchar_t* kPageActionIcons; - extern const wchar_t* kPageActionId; - extern const wchar_t* kPageActionPopup; - extern const wchar_t* kPageActionPopupHeight; - extern const wchar_t* kPageActionPopupPath; - extern const wchar_t* kPageActions; - extern const wchar_t* kPermissions; - extern const wchar_t* kPlugins; - extern const wchar_t* kPluginsPath; - extern const wchar_t* kPluginsPublic; - extern const wchar_t* kPublicKey; - extern const wchar_t* kRunAt; - extern const wchar_t* kSignature; - extern const wchar_t* kTheme; - extern const wchar_t* kThemeColors; - extern const wchar_t* kThemeDisplayProperties; - extern const wchar_t* kThemeImages; - extern const wchar_t* kThemeTints; - extern const wchar_t* kToolstripMoleHeight; - extern const wchar_t* kToolstripMolePath; - extern const wchar_t* kToolstripPath; - extern const wchar_t* kToolstrips; - extern const wchar_t* kType; - extern const wchar_t* kUpdateURL; - extern const wchar_t* kVersion; - extern const wchar_t* kWebLaunchUrl; - extern const wchar_t* kWebURLs; + extern const char* kAllFrames; + extern const char* kApp; + extern const char* kBackground; + extern const char* kBrowserAction; + extern const char* kBrowseURLs; + extern const char* kChromeURLOverrides; + extern const char* kContentScripts; + extern const char* kConvertedFromUserScript; + extern const char* kCss; + extern const char* kCurrentLocale; + extern const char* kDefaultLocale; + extern const char* kDescription; + extern const char* kDevToolsPage; + extern const char* kExcludeGlobs; + extern const char* kIcons; + extern const char* kIncludeGlobs; + extern const char* kJs; + extern const char* kLaunch; + extern const char* kLaunchContainer; + extern const char* kLaunchFullscreen; + extern const char* kLaunchHeight; + extern const char* kLaunchLocalPath; + extern const char* kLaunchWebURL; + extern const char* kLaunchWidth; + extern const char* kMatches; + extern const char* kMinimumChromeVersion; + extern const char* kName; + extern const char* kOmniboxKeyword; + extern const char* kOptionsPage; + extern const char* kPageAction; + extern const char* kPageActionDefaultIcon; + extern const char* kPageActionDefaultPopup; + extern const char* kPageActionDefaultTitle; + extern const char* kPageActionIcons; + extern const char* kPageActionId; + extern const char* kPageActionPopup; + extern const char* kPageActionPopupHeight; + extern const char* kPageActionPopupPath; + extern const char* kPageActions; + extern const char* kPermissions; + extern const char* kPlugins; + extern const char* kPluginsPath; + extern const char* kPluginsPublic; + extern const char* kPublicKey; + extern const char* kRunAt; + extern const char* kSignature; + extern const char* kTheme; + extern const char* kThemeColors; + extern const char* kThemeDisplayProperties; + extern const char* kThemeImages; + extern const char* kThemeTints; + extern const char* kToolstripMoleHeight; + extern const char* kToolstripMolePath; + extern const char* kToolstripPath; + extern const char* kToolstrips; + extern const char* kType; + extern const char* kUpdateURL; + extern const char* kVersion; + extern const char* kWebLaunchUrl; + extern const char* kWebURLs; } // namespace extension_manifest_keys // Some values expected in manifests. diff --git a/chrome/common/extensions/extension_l10n_util.cc b/chrome/common/extensions/extension_l10n_util.cc index b9c2b1c..4187689 100644 --- a/chrome/common/extensions/extension_l10n_util.cc +++ b/chrome/common/extensions/extension_l10n_util.cc @@ -61,7 +61,7 @@ bool ShouldRelocalizeManifest(const ExtensionInfo& info) { } // Localizes manifest value for a given key. -static bool LocalizeManifestValue(const std::wstring& key, +static bool LocalizeManifestValue(const std::string& key, const ExtensionMessageBundle& messages, DictionaryValue* manifest, std::string* error) { @@ -94,15 +94,15 @@ bool LocalizeManifest(const ExtensionMessageBundle& messages, return false; // Initialize browser_action.default_title - std::wstring key(keys::kBrowserAction); - key.append(L"."); + std::string key(keys::kBrowserAction); + key.append("."); key.append(keys::kPageActionDefaultTitle); if (!LocalizeManifestValue(key, messages, manifest, error)) return false; // Initialize page_action.default_title key.assign(keys::kPageAction); - key.append(L"."); + key.append("."); key.append(keys::kPageActionDefaultTitle); if (!LocalizeManifestValue(key, messages, manifest, error)) return false; diff --git a/chrome/common/extensions/extension_l10n_util_unittest.cc b/chrome/common/extensions/extension_l10n_util_unittest.cc index aa83e05..b00044c 100644 --- a/chrome/common/extensions/extension_l10n_util_unittest.cc +++ b/chrome/common/extensions/extension_l10n_util_unittest.cc @@ -323,8 +323,8 @@ TEST(ExtensionL10nUtil, LocalizeManifestWithNameDescriptionDefaultTitleMsgs) { DictionaryValue manifest; manifest.SetString(keys::kName, "__MSG_name__"); manifest.SetString(keys::kDescription, "__MSG_description__"); - std::wstring action_title(keys::kBrowserAction); - action_title.append(L"."); + std::string action_title(keys::kBrowserAction); + action_title.append("."); action_title.append(keys::kPageActionDefaultTitle); manifest.SetString(action_title, "__MSG_title__"); diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc index acb1f95..5a3a3c0 100644 --- a/chrome/common/extensions/extension_unittest.cc +++ b/chrome/common/extensions/extension_unittest.cc @@ -370,7 +370,7 @@ TEST(ExtensionTest, InitFromValueValidNameInRTL) { input_value.SetString(keys::kVersion, "1.0.0.0"); // No strong RTL characters in name. std::wstring name(L"Dictionary (by Google)"); - input_value.SetString(keys::kName, name); + input_value.SetString(keys::kName, WideToUTF16Hack(name)); EXPECT_TRUE(extension.InitFromValue(input_value, false, &error)); EXPECT_EQ("", error); std::wstring localized_name(name); @@ -379,7 +379,7 @@ TEST(ExtensionTest, InitFromValueValidNameInRTL) { // Strong RTL characters in name. name = L"Dictionary (\x05D1\x05D2"L" Google)"; - input_value.SetString(keys::kName, name); + input_value.SetString(keys::kName, WideToUTF16Hack(name)); EXPECT_TRUE(extension.InitFromValue(input_value, false, &error)); EXPECT_EQ("", error); localized_name = name; @@ -556,8 +556,8 @@ TEST(ExtensionTest, LoadPageActionHelper) { ASSERT_STREQ( ExtensionErrorUtils::FormatErrorMessage( errors::kInvalidPageActionOldAndNewKeys, - WideToASCII(keys::kPageActionDefaultPopup), - WideToASCII(keys::kPageActionPopup)).c_str(), + keys::kPageActionDefaultPopup, + keys::kPageActionPopup).c_str(), error_msg.c_str()); error_msg = ""; |