diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-11 03:02:51 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-11 03:02:51 +0000 |
commit | 57ecc4bf4069cb869e5fb0a7d922eec2384bac25 (patch) | |
tree | 1b4668fa59d6b6a072144b4ddab8d5f6faba3fa4 /chrome/browser | |
parent | 1af19cfd7b1ef9924516dbe811db495315feaefe (diff) | |
download | chromium_src-57ecc4bf4069cb869e5fb0a7d922eec2384bac25.zip chromium_src-57ecc4bf4069cb869e5fb0a7d922eec2384bac25.tar.gz chromium_src-57ecc4bf4069cb869e5fb0a7d922eec2384bac25.tar.bz2 |
Make prefs use std::string for keys rather than wstrings.
Much remains to be converted.
BUG=23581
TEST=builds and passes tests
Review URL: http://codereview.chromium.org/3076037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55660 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
122 files changed, 923 insertions, 681 deletions
diff --git a/chrome/browser/autofill/autofill_dialog_gtk.cc b/chrome/browser/autofill/autofill_dialog_gtk.cc index 0616d27..d832e69 100644 --- a/chrome/browser/autofill/autofill_dialog_gtk.cc +++ b/chrome/browser/autofill/autofill_dialog_gtk.cc @@ -234,7 +234,7 @@ void AutoFillDialog::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { DCHECK_EQ(NotificationType::PREF_CHANGED, type.value); - const std::wstring* pref_name = Details<std::wstring>(details).ptr(); + const std::string* pref_name = Details<std::string>(details).ptr(); if (!pref_name || *pref_name == prefs::kAutoFillEnabled) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(form_autofill_enable_check_), diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index fdca465..2d44ff5 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -2200,10 +2200,10 @@ void AutomationProvider::GetPrefsInfo(Browser* browser, void AutomationProvider::SetPrefs(Browser* browser, DictionaryValue* args, IPC::Message* reply_message) { - std::wstring path; + std::string path; Value* val; AutomationJSONReply reply(this, reply_message); - if (args->GetString(L"path", &path) && args->Get("value", &val)) { + if (args->GetString("path", &path) && args->Get("value", &val)) { PrefService* pref_service = profile_->GetPrefs(); const PrefService::Preference* pref = pref_service->FindPreference(path.c_str()); @@ -2933,7 +2933,7 @@ void AutomationProvider::WaitUntilTranslateComplete( scoped_ptr<DictionaryValue> return_value(new DictionaryValue); if (!translate_bar) { - return_value->SetBoolean(L"translation_success", false); + return_value->SetBoolean("translation_success", false); AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); return; } @@ -2947,7 +2947,7 @@ void AutomationProvider::WaitUntilTranslateComplete( // Otherwise send back the success or failure of the attempted translation. return_value->SetBoolean( - L"translation_success", + "translation_success", translate_bar->type() == TranslateInfoBarDelegate::AFTER_TRANSLATE); AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); } @@ -3937,7 +3937,7 @@ void AutomationProvider::WaitForNavigation(int handle, } void AutomationProvider::SetIntPreference(int handle, - const std::wstring& name, + const std::string& name, int value, bool* success) { *success = false; @@ -3949,7 +3949,7 @@ void AutomationProvider::SetIntPreference(int handle, } void AutomationProvider::SetStringPreference(int handle, - const std::wstring& name, + const std::string& name, const std::string& value, bool* success) { *success = false; @@ -3961,7 +3961,7 @@ void AutomationProvider::SetStringPreference(int handle, } void AutomationProvider::GetBooleanPreference(int handle, - const std::wstring& name, + const std::string& name, bool* success, bool* value) { *success = false; @@ -3974,7 +3974,7 @@ void AutomationProvider::GetBooleanPreference(int handle, } void AutomationProvider::SetBooleanPreference(int handle, - const std::wstring& name, + const std::string& name, bool value, bool* success) { *success = false; diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index f693d89..9ff8753 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -738,25 +738,25 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, // Sets the int value for preference with name |name|. void SetIntPreference(int handle, - const std::wstring& name, + const std::string& name, int value, bool* success); // Sets the string value for preference with name |name|. void SetStringPreference(int handle, - const std::wstring& name, + const std::string& name, const std::string& value, bool* success); // Gets the bool value for preference with name |name|. void GetBooleanPreference(int handle, - const std::wstring& name, + const std::string& name, bool* success, bool* value); // Sets the bool value for preference with name |name|. void SetBooleanPreference(int handle, - const std::wstring& name, + const std::string& name, bool value, bool* success); diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 7118ebf..83c6c48 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -312,7 +312,7 @@ Browser* Browser::CreateForType(Type type, Profile* profile) { } // static -Browser* Browser::CreateForApp(const std::wstring& app_name, +Browser* Browser::CreateForApp(const std::string& app_name, Extension* extension, Profile* profile, bool is_panel) { @@ -360,7 +360,7 @@ void Browser::CreateBrowserWindow() { // name. See http://crbug.com/7028. win_util::SetAppIdForWindow( type_ & TYPE_APP ? - ShellIntegration::GetAppId(app_name_, profile_->GetPath()) : + ShellIntegration::GetAppId(UTF8ToWide(app_name_), profile_->GetPath()) : ShellIntegration::GetChromiumAppId(profile_->GetPath()), window()->GetNativeHandle()); #endif @@ -571,7 +571,7 @@ TabContents* Browser::OpenApplicationWindow( } // TODO(erikkay) this can't be correct for extensions - std::wstring app_name = web_app::GenerateApplicationNameFromURL(url); + std::string app_name = web_app::GenerateApplicationNameFromURL(url); RegisterAppPrefs(app_name); bool as_panel = extension && (container == Extension::LAUNCH_PANEL); @@ -673,10 +673,10 @@ void Browser::OpenExtensionsWindow(Profile* profile) { /////////////////////////////////////////////////////////////////////////////// // Browser, State Storage and Retrieval for UI: -std::wstring Browser::GetWindowPlacementKey() const { - std::wstring name(prefs::kBrowserWindowPlacement); +std::string Browser::GetWindowPlacementKey() const { + std::string name(prefs::kBrowserWindowPlacement); if (!app_name_.empty()) { - name.append(L"_"); + name.append("_"); name.append(app_name_); } return name; @@ -775,8 +775,7 @@ string16 Browser::GetWindowTitleForCurrentTab() const { void Browser::FormatTitleForDisplay(string16* title) { size_t current_index = 0; size_t match_index; - while ((match_index = title->find(L'\n', current_index)) != - std::wstring::npos) { + while ((match_index = title->find(L'\n', current_index)) != string16::npos) { title->replace(match_index, 1, string16()); current_index = match_index; } @@ -2748,7 +2747,7 @@ bool Browser::IsApplication() const { void Browser::ConvertContentsToApplication(TabContents* contents) { const GURL& url = contents->controller().GetActiveEntry()->url(); - std::wstring app_name = web_app::GenerateApplicationNameFromURL(url); + std::string app_name = web_app::GenerateApplicationNameFromURL(url); RegisterAppPrefs(app_name); DetachContents(contents); @@ -3085,7 +3084,7 @@ void Browser::Observe(NotificationType type, } case NotificationType::PREF_CHANGED: { - if (*(Details<std::wstring>(details).ptr()) == prefs::kUseVerticalTabs) + if (*(Details<std::string>(details).ptr()) == prefs::kUseVerticalTabs) UseVerticalTabsChanged(); else NOTREACHED(); @@ -4026,12 +4025,12 @@ void Browser::TabDetachedAtImpl(TabContents* contents, int index, } // static -void Browser::RegisterAppPrefs(const std::wstring& app_name) { +void Browser::RegisterAppPrefs(const std::string& app_name) { // A set of apps that we've already started. - static std::set<std::wstring>* g_app_names = NULL; + static std::set<std::string>* g_app_names = NULL; if (!g_app_names) - g_app_names = new std::set<std::wstring>; + g_app_names = new std::set<std::string>; // Only register once for each app name. if (g_app_names->find(app_name) != g_app_names->end()) @@ -4039,8 +4038,8 @@ void Browser::RegisterAppPrefs(const std::wstring& app_name) { g_app_names->insert(app_name); // We need to register the window position pref. - std::wstring window_pref(prefs::kBrowserWindowPlacement); - window_pref.append(L"_"); + std::string window_pref(prefs::kBrowserWindowPlacement); + window_pref.append("_"); window_pref.append(app_name); PrefService* prefs = g_browser_process->local_state(); DCHECK(prefs); diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h index 4a7c9fa..1041735 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -126,7 +126,7 @@ class Browser : public TabStripModelDelegate, // app. |app_name| is required and is used to identify the window to the // shell. |extension| is optional. If supplied, we create a window with // a bigger icon and title text, that supports tabs. - static Browser* CreateForApp(const std::wstring& app_name, + static Browser* CreateForApp(const std::string& app_name, Extension* extension, Profile* profile, bool is_panel); @@ -261,7 +261,7 @@ class Browser : public TabStripModelDelegate, // State Storage and Retrieval for UI /////////////////////////////////////// // Save and restore the window position. - std::wstring GetWindowPlacementKey() const; + std::string GetWindowPlacementKey() const; bool ShouldSaveWindowPlacement() const; void SaveWindowPlacement(const gfx::Rect& bounds, bool maximized); gfx::Rect GetSavedWindowBounds() const; @@ -901,7 +901,7 @@ class Browser : public TabStripModelDelegate, // Create a preference dictionary for the provided application name. This is // done only once per application name / per session. - static void RegisterAppPrefs(const std::wstring& app_name); + static void RegisterAppPrefs(const std::string& app_name); // Shared code between Reload() and ReloadIgnoringCache(). void ReloadInternal(WindowOpenDisposition disposition, bool ignore_cache); @@ -969,7 +969,7 @@ class Browser : public TabStripModelDelegate, // An optional application name which is used to retrieve and save window // positions. - std::wstring app_name_; + std::string app_name_; // Unique identifier of this browser for session restore. This id is only // unique within the current session, and is not guaranteed to be unique diff --git a/chrome/browser/browser_encoding_uitest.cc b/chrome/browser/browser_encoding_uitest.cc index ac3ac5d..e232c5e 100644 --- a/chrome/browser/browser_encoding_uitest.cc +++ b/chrome/browser/browser_encoding_uitest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-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. #include <string> diff --git a/chrome/browser/chromeos/cros_settings.cc b/chrome/browser/chromeos/cros_settings.cc index d299c4f..84499b8 100644 --- a/chrome/browser/chromeos/cros_settings.cc +++ b/chrome/browser/chromeos/cros_settings.cc @@ -17,28 +17,28 @@ CrosSettings* CrosSettings::Get() { return Singleton<CrosSettings>::get(); } -bool CrosSettings::IsCrosSettings(const std::wstring& path) { - return StartsWith(path, kCrosSettingsPrefix, true); +bool CrosSettings::IsCrosSettings(const std::string& path) { + return StartsWithASCII(path, kCrosSettingsPrefix, true); } -void CrosSettings::SetBoolean(const std::wstring& path, bool in_value) { +void CrosSettings::SetBoolean(const std::string& path, bool in_value) { Set(path, Value::CreateBooleanValue(in_value)); } -void CrosSettings::SetInteger(const std::wstring& path, int in_value) { +void CrosSettings::SetInteger(const std::string& path, int in_value) { Set(path, Value::CreateIntegerValue(in_value)); } -void CrosSettings::SetReal(const std::wstring& path, double in_value) { +void CrosSettings::SetReal(const std::string& path, double in_value) { Set(path, Value::CreateRealValue(in_value)); } -void CrosSettings::SetString(const std::wstring& path, +void CrosSettings::SetString(const std::string& path, const std::string& in_value) { Set(path, Value::CreateStringValue(in_value)); } -bool CrosSettings::GetBoolean(const std::wstring& path, +bool CrosSettings::GetBoolean(const std::string& path, bool* bool_value) const { Value* value; if (!Get(path, &value)) @@ -63,7 +63,7 @@ bool CrosSettings::RemoveProvider(CrosSettingsProvider* provider) { } CrosSettingsProvider* CrosSettings::GetProvider( - const std::wstring& path) const { + const std::string& path) const { for (size_t i = 0; i < providers_.size(); ++i) { if (providers_[i]->HandlesSetting(path)){ return providers_[i]; @@ -72,7 +72,7 @@ CrosSettingsProvider* CrosSettings::GetProvider( return NULL; } -void CrosSettings::Set(const std::wstring& path, Value* in_value) { +void CrosSettings::Set(const std::string& path, Value* in_value) { CrosSettingsProvider* provider; provider = GetProvider(path); if (provider) { @@ -80,7 +80,7 @@ void CrosSettings::Set(const std::wstring& path, Value* in_value) { } } -bool CrosSettings::Get(const std::wstring& path, Value** out_value) const { +bool CrosSettings::Get(const std::string& path, Value** out_value) const { CrosSettingsProvider* provider; provider = GetProvider(path); if (provider) { @@ -89,7 +89,7 @@ bool CrosSettings::Get(const std::wstring& path, Value** out_value) const { return false; } -bool CrosSettings::GetInteger(const std::wstring& path, +bool CrosSettings::GetInteger(const std::string& path, int* out_value) const { Value* value; if (!Get(path, &value)) @@ -98,7 +98,7 @@ bool CrosSettings::GetInteger(const std::wstring& path, return value->GetAsInteger(out_value); } -bool CrosSettings::GetReal(const std::wstring& path, +bool CrosSettings::GetReal(const std::string& path, double* out_value) const { Value* value; if (!Get(path, &value)) @@ -107,7 +107,7 @@ bool CrosSettings::GetReal(const std::wstring& path, return value->GetAsReal(out_value); } -bool CrosSettings::GetString(const std::wstring& path, +bool CrosSettings::GetString(const std::string& path, std::string* out_value) const { Value* value; if (!Get(path, &value)) diff --git a/chrome/browser/chromeos/cros_settings.h b/chrome/browser/chromeos/cros_settings.h index 1b20ad3..0cf52ab 100644 --- a/chrome/browser/chromeos/cros_settings.h +++ b/chrome/browser/chromeos/cros_settings.h @@ -25,30 +25,30 @@ class CrosSettings { static CrosSettings* Get(); // Helper function to test if given path is a value cros settings name. - static bool IsCrosSettings(const std::wstring& path); + static bool IsCrosSettings(const std::string& path); // Sets |in_value| to given |path| in cros settings. // Note that this takes ownership of |in_value|. - void Set(const std::wstring& path, Value* in_value); + void Set(const std::string& path, Value* in_value); // Gets settings value of given |path| to |out_value|. // Note that |out_value| is still owned by this class. - bool Get(const std::wstring& path, Value** out_value) const; + bool Get(const std::string& path, Value** out_value) const; // Convenience forms of Set(). These methods will replace any existing // value at that path, even if it has a different type. - void SetBoolean(const std::wstring& path, bool in_value); - void SetInteger(const std::wstring& path, int in_value); - void SetReal(const std::wstring& path, double in_value); - void SetString(const std::wstring& path, const std::string& in_value); + void SetBoolean(const std::string& path, bool in_value); + void SetInteger(const std::string& path, int in_value); + void SetReal(const std::string& path, double in_value); + void SetString(const std::string& path, const std::string& in_value); // These are convenience forms of Get(). The value will be retrieved // and the return value will be true if the path is valid and the value at // the end of the path can be returned in the form specified. - bool GetBoolean(const std::wstring& path, bool* out_value) const; - bool GetInteger(const std::wstring& path, int* out_value) const; - bool GetReal(const std::wstring& path, double* out_value) const; - bool GetString(const std::wstring& path, std::string* out_value) const; + bool GetBoolean(const std::string& path, bool* out_value) const; + bool GetInteger(const std::string& path, int* out_value) const; + bool GetReal(const std::string& path, double* out_value) const; + bool GetString(const std::string& path, std::string* out_value) const; private: // adding/removing of providers @@ -59,7 +59,7 @@ class CrosSettings { CrosSettings(); ~CrosSettings(); - CrosSettingsProvider* GetProvider(const std::wstring& path) const; + CrosSettingsProvider* GetProvider(const std::string& path) const; friend struct DefaultSingletonTraits<CrosSettings>; DISALLOW_COPY_AND_ASSIGN(CrosSettings); }; diff --git a/chrome/browser/chromeos/cros_settings_names.cc b/chrome/browser/chromeos/cros_settings_names.cc index 6cbd59a..d234514 100644 --- a/chrome/browser/chromeos/cros_settings_names.cc +++ b/chrome/browser/chromeos/cros_settings_names.cc @@ -6,12 +6,12 @@ namespace chromeos { -const wchar_t kCrosSettingsPrefix[] = L"cros."; +const char kCrosSettingsPrefix[] = "cros."; -const wchar_t kAccountsPrefAllowBWSI[] = L"cros.accounts.allowBWSI"; -const wchar_t kAccountsPrefAllowGuest[] = L"cros.accounts.allowGuest"; -const wchar_t kAccountsPrefShowUserNamesOnSignIn[] - = L"cros.accounts.showUserNamesOnSignIn"; -const wchar_t kAccountsPrefUsers[] = L"cros.accounts.users"; +const char kAccountsPrefAllowBWSI[] = "cros.accounts.allowBWSI"; +const char kAccountsPrefAllowGuest[] = "cros.accounts.allowGuest"; +const char kAccountsPrefShowUserNamesOnSignIn[] + = "cros.accounts.showUserNamesOnSignIn"; +const char kAccountsPrefUsers[] = "cros.accounts.users"; } // namespace chromeos diff --git a/chrome/browser/chromeos/cros_settings_names.h b/chrome/browser/chromeos/cros_settings_names.h index 7532fa4..21a7a1a 100644 --- a/chrome/browser/chromeos/cros_settings_names.h +++ b/chrome/browser/chromeos/cros_settings_names.h @@ -8,12 +8,12 @@ namespace chromeos { -extern const wchar_t kCrosSettingsPrefix[]; +extern const char kCrosSettingsPrefix[]; -extern const wchar_t kAccountsPrefAllowBWSI[]; -extern const wchar_t kAccountsPrefAllowGuest[]; -extern const wchar_t kAccountsPrefShowUserNamesOnSignIn[]; -extern const wchar_t kAccountsPrefUsers[]; +extern const char kAccountsPrefAllowBWSI[]; +extern const char kAccountsPrefAllowGuest[]; +extern const char kAccountsPrefShowUserNamesOnSignIn[]; +extern const char kAccountsPrefUsers[]; } // namespace chromeos diff --git a/chrome/browser/chromeos/cros_settings_provider.h b/chrome/browser/chromeos/cros_settings_provider.h index e4184ed7..c069ce1 100644 --- a/chrome/browser/chromeos/cros_settings_provider.h +++ b/chrome/browser/chromeos/cros_settings_provider.h @@ -17,14 +17,14 @@ class CrosSettingsProvider { // Sets |in_value| to given |path| in cros settings. // Note that this takes ownership of |in_value|. - virtual void Set(const std::wstring& path, Value* in_value) = 0; + virtual void Set(const std::string& path, Value* in_value) = 0; // Gets settings value of given |path| to |out_value|. // Note that |out_value| is still owned by this class. - virtual bool Get(const std::wstring& path, Value** out_value) const = 0; + virtual bool Get(const std::string& path, Value** out_value) const = 0; // Gets the namespace prefix provided by this provider - virtual bool HandlesSetting(const std::wstring& path) = 0; + virtual bool HandlesSetting(const std::string& path) = 0; }; } // namespace chromeos diff --git a/chrome/browser/chromeos/cros_settings_provider_user.cc b/chrome/browser/chromeos/cros_settings_provider_user.cc index 900427a..1cdde9f 100644 --- a/chrome/browser/chromeos/cros_settings_provider_user.cc +++ b/chrome/browser/chromeos/cros_settings_provider_user.cc @@ -33,17 +33,17 @@ UserCrosSettingsProvider::UserCrosSettingsProvider() Set(kAccountsPrefUsers, user_list); } -void UserCrosSettingsProvider::Set(const std::wstring& path, Value* in_value) { +void UserCrosSettingsProvider::Set(const std::string& path, Value* in_value) { dict_->Set(path, in_value); } -bool UserCrosSettingsProvider::Get(const std::wstring& path, +bool UserCrosSettingsProvider::Get(const std::string& path, Value** out_value) const { return dict_->Get(path, out_value); } -bool UserCrosSettingsProvider::HandlesSetting(const std::wstring& path) { - return ::StartsWith(path, std::wstring(L"cros.accounts"), true); +bool UserCrosSettingsProvider::HandlesSetting(const std::string& path) { + return ::StartsWithASCII(path, "cros.accounts", true); } } // namespace chromeos diff --git a/chrome/browser/chromeos/cros_settings_provider_user.h b/chrome/browser/chromeos/cros_settings_provider_user.h index de31493..42f2213 100644 --- a/chrome/browser/chromeos/cros_settings_provider_user.h +++ b/chrome/browser/chromeos/cros_settings_provider_user.h @@ -16,9 +16,9 @@ namespace chromeos { class UserCrosSettingsProvider : public CrosSettingsProvider { public: - virtual void Set(const std::wstring& path, Value* in_value); - virtual bool Get(const std::wstring& path, Value** out_value) const; - virtual bool HandlesSetting(const std::wstring& path); + virtual void Set(const std::string& path, Value* in_value); + virtual bool Get(const std::string& path, Value** out_value) const; + virtual bool HandlesSetting(const std::string& path); UserCrosSettingsProvider(); private: diff --git a/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.cc b/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.cc index 2f73048..8321ca6 100644 --- a/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.cc +++ b/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.cc @@ -10,7 +10,7 @@ namespace chromeos { -Value* CoreChromeOSOptionsHandler::FetchPref(const std::wstring& pref_name) { +Value* CoreChromeOSOptionsHandler::FetchPref(const std::string& pref_name) { if (!CrosSettings::IsCrosSettings(pref_name)) return ::CoreOptionsHandler::FetchPref(pref_name); @@ -19,14 +19,14 @@ Value* CoreChromeOSOptionsHandler::FetchPref(const std::wstring& pref_name) { return pref_value ? pref_value->DeepCopy() : Value::CreateNullValue(); } -void CoreChromeOSOptionsHandler::ObservePref(const std::wstring& pref_name) { +void CoreChromeOSOptionsHandler::ObservePref(const std::string& pref_name) { if (!CrosSettings::IsCrosSettings(pref_name)) return ::CoreOptionsHandler::ObservePref(pref_name); // TODO(xiyuan): Change this when CrosSettings supports observers. } -void CoreChromeOSOptionsHandler::SetPref(const std::wstring& pref_name, +void CoreChromeOSOptionsHandler::SetPref(const std::string& pref_name, Value::ValueType pref_type, const std::string& value_string) { if (!CrosSettings::IsCrosSettings(pref_name)) diff --git a/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.h b/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.h index 4004a90..f0d7956 100644 --- a/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.h +++ b/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.h @@ -16,9 +16,9 @@ class CoreChromeOSOptionsHandler : public ::CoreOptionsHandler { protected: // ::CoreOptionsHandler Implementation - virtual Value* FetchPref(const std::wstring& pref_name); - virtual void ObservePref(const std::wstring& pref_name); - virtual void SetPref(const std::wstring& pref_name, + virtual Value* FetchPref(const std::string& pref_name); + virtual void ObservePref(const std::string& pref_name); + virtual void SetPref(const std::string& pref_name, Value::ValueType pref_type, const std::string& value_string); diff --git a/chrome/browser/chromeos/language_preferences.h b/chrome/browser/chromeos/language_preferences.h index 55962b75..bc08750 100644 --- a/chrome/browser/chromeos/language_preferences.h +++ b/chrome/browser/chromeos/language_preferences.h @@ -15,7 +15,7 @@ namespace chromeos { template <typename DataType> struct LanguageMultipleChoicePreference { - const wchar_t* pref_name; // Chrome preference name. + const char* pref_name; // Chrome preference name. DataType default_pref_value; const char* ibus_config_name; // Currently we have 10 combobox items at most. @@ -28,14 +28,14 @@ struct LanguageMultipleChoicePreference { }; struct LanguageBooleanPrefs { - const wchar_t* pref_name; // Chrome preference name. + const char* pref_name; // Chrome preference name. bool default_pref_value; const char* ibus_config_name; int message_id; }; struct LanguageIntegerRangePreference { - const wchar_t* pref_name; // Chrome preference name. + const char* pref_name; // Chrome preference name. int default_pref_value; int min_pref_value; int max_pref_value; @@ -242,7 +242,7 @@ const LanguageMultipleChoicePreference<int> kPinyinDoublePinyinSchema = { }; const struct { - const wchar_t* pref_name; // Chrome preference name. + const char* pref_name; // Chrome preference name. int default_pref_value; const char* ibus_config_name; // TODO(yusukes): Add message_id if needed. @@ -421,7 +421,7 @@ const size_t kNumMozcIntegerPrefs = arraysize(kMozcIntegerPrefs); // A string Chrome preference (Local State) of the preferred keyboard layout in // the login screen. -const wchar_t kPreferredKeyboardLayout[] = L"PreferredKeyboardLayout"; +const char kPreferredKeyboardLayout[] = "PreferredKeyboardLayout"; // A input method name that corresponds the hardware keyboard layout. // TODO(yusukes): just assuming US qwerty keyboard is not always correct. diff --git a/chrome/browser/chromeos/options/system_page_view.cc b/chrome/browser/chromeos/options/system_page_view.cc index de6e4b8..416a474 100644 --- a/chrome/browser/chromeos/options/system_page_view.cc +++ b/chrome/browser/chromeos/options/system_page_view.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. @@ -214,7 +214,7 @@ class TouchpadSection : public SettingsPageSection, protected: // SettingsPageSection overrides: virtual void InitContents(GridLayout* layout); - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); private: // The View that contains the contents of the section. @@ -328,7 +328,7 @@ void TouchpadSection::InitContents(GridLayout* layout) { profile()->GetPrefs(), this); } -void TouchpadSection::NotifyPrefChanged(const std::wstring* pref_name) { +void TouchpadSection::NotifyPrefChanged(const std::string* pref_name) { if (!pref_name || *pref_name == prefs::kTapToClickEnabled) { bool enabled = tap_to_click_enabled_.GetValue(); enable_tap_to_click_checkbox_->SetChecked(enabled); @@ -364,7 +364,7 @@ class LanguageSection : public SettingsPageSection, }; // Overridden from SettingsPageSection: virtual void InitContents(GridLayout* layout); - void NotifyPrefChanged(const std::wstring* pref_name); + void NotifyPrefChanged(const std::string* pref_name); // Overridden from views::ButtonListener: virtual void ButtonPressed(views::Button* sender, @@ -424,7 +424,7 @@ void LanguageSection::ItemChanged(views::Combobox* sender, xkb_pref_.SetValue(new_index); } -void LanguageSection::NotifyPrefChanged(const std::wstring* pref_name) { +void LanguageSection::NotifyPrefChanged(const std::string* pref_name) { if (!pref_name || *pref_name == prefs::kLanguageXkbModifierRemap) { const int id = xkb_pref_.GetValue(); if (id >= 0) { @@ -450,7 +450,7 @@ class AccessibilitySection : public SettingsPageSection, // Overridden from SettingsPageSection: virtual void InitContents(GridLayout* layout); - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); private: // The View that contains the contents of the section. @@ -495,7 +495,7 @@ void AccessibilitySection::ButtonPressed( } } -void AccessibilitySection::NotifyPrefChanged(const std::wstring* pref_name) { +void AccessibilitySection::NotifyPrefChanged(const std::string* pref_name) { if (!pref_name || *pref_name == prefs::kAccessibilityEnabled) { bool enabled = accessibility_enabled_.GetValue(); accessibility_checkbox_->SetChecked(enabled); diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc index c950b3a..30a53d8 100644 --- a/chrome/browser/chromeos/preferences.cc +++ b/chrome/browser/chromeos/preferences.cc @@ -180,10 +180,10 @@ void Preferences::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { if (type == NotificationType::PREF_CHANGED) - NotifyPrefChanged(Details<std::wstring>(details).ptr()); + NotifyPrefChanged(Details<std::string>(details).ptr()); } -void Preferences::NotifyPrefChanged(const std::wstring* pref_name) { +void Preferences::NotifyPrefChanged(const std::string* pref_name) { if (!pref_name || *pref_name == prefs::kTapToClickEnabled) { CrosLibrary::Get()->GetSynapticsLibrary()->SetBoolParameter( PARAM_BOOL_TAP_TO_CLICK, diff --git a/chrome/browser/chromeos/preferences.h b/chrome/browser/chromeos/preferences.h index 60aa75e..b1b8649 100644 --- a/chrome/browser/chromeos/preferences.h +++ b/chrome/browser/chromeos/preferences.h @@ -41,7 +41,7 @@ class Preferences : public NotificationObserver { // This will set the OS settings when the preference changes. // If this method is called with NULL, it will set all OS settings to what's // stored in the preferences. - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); private: // Writes boolean |value| to the input method (IBus) configuration daemon. diff --git a/chrome/browser/cocoa/content_settings_dialog_controller.mm b/chrome/browser/cocoa/content_settings_dialog_controller.mm index 2befeaf..147895c 100644 --- a/chrome/browser/cocoa/content_settings_dialog_controller.mm +++ b/chrome/browser/cocoa/content_settings_dialog_controller.mm @@ -45,7 +45,7 @@ ContentSettingsDialogController* g_instance = nil; // Callback when preferences are changed. |prefName| is the name of the // pref that has changed. -- (void)prefChanged:(std::wstring*)prefName; +- (void)prefChanged:(std::string*)prefName; @end @@ -63,7 +63,7 @@ class PrefObserverBridge : public NotificationObserver { const NotificationSource& source, const NotificationDetails& details) { if (!disabled_ && type == NotificationType::PREF_CHANGED) { - [controller_ prefChanged:Details<std::wstring>(details).ptr()]; + [controller_ prefChanged:Details<std::string>(details).ptr()]; } } @@ -504,7 +504,7 @@ class PrefObserverDisabler { // Callback when preferences are changed. |prefName| is the name of the // pref that has changed and should not be NULL. -- (void)prefChanged:(std::wstring*)prefName { +- (void)prefChanged:(std::string*)prefName { DCHECK(prefName); if (!prefName) return; if (*prefName == prefs::kClearSiteDataOnExit) { diff --git a/chrome/browser/cocoa/preferences_window_controller.mm b/chrome/browser/cocoa/preferences_window_controller.mm index 03e2978..93489bc 100644 --- a/chrome/browser/cocoa/preferences_window_controller.mm +++ b/chrome/browser/cocoa/preferences_window_controller.mm @@ -321,7 +321,7 @@ CGFloat AutoSizeUnderTheHoodContent(NSView* view, @interface PreferencesWindowController(Private) // Callback when preferences are changed. |prefName| is the name of the // pref that has changed. -- (void)prefChanged:(std::wstring*)prefName; +- (void)prefChanged:(std::string*)prefName; // Callback when sync state has changed. syncService_ needs to be // queried to find out what happened. - (void)syncStateChanged; @@ -372,7 +372,7 @@ class PrefObserverBridge : public NotificationObserver, const NotificationSource& source, const NotificationDetails& details) { if (type == NotificationType::PREF_CHANGED) - [controller_ prefChanged:Details<std::wstring>(details).ptr()]; + [controller_ prefChanged:Details<std::string>(details).ptr()]; } // Overridden from ProfileSyncServiceObserver. @@ -877,7 +877,7 @@ class ManagedPrefsBannerState : public ManagedPrefsBannerBase { // Windows, we don't need to use this method for initializing, that's handled by // Cocoa Bindings. // Handles prefs for the "Basics" panel. -- (void)basicsPrefChanged:(std::wstring*)prefName { +- (void)basicsPrefChanged:(std::string*)prefName { if (*prefName == prefs::kRestoreOnStartup) { const SessionStartupPref startupPref = SessionStartupPref::GetStartupPref(prefs_); @@ -1201,7 +1201,7 @@ const int kDisabledIndex = 1; // that has changed. Unlike on Windows, we don't need to use this method for // initializing, that's handled by Cocoa Bindings. // Handles prefs for the "Personal Stuff" panel. -- (void)userDataPrefChanged:(std::wstring*)prefName { +- (void)userDataPrefChanged:(std::string*)prefName { if (*prefName == prefs::kPasswordManagerEnabled) { [self setPasswordManagerEnabledIndex:askSavePasswords_.GetValue() ? kEnabledIndex : kDisabledIndex]; @@ -1359,7 +1359,7 @@ const int kDisabledIndex = 1; // that has changed. Unlike on Windows, we don't need to use this method for // initializing, that's handled by Cocoa Bindings. // Handles prefs for the "Under the hood" panel. -- (void)underHoodPrefChanged:(std::wstring*)prefName { +- (void)underHoodPrefChanged:(std::string*)prefName { if (*prefName == prefs::kAlternateErrorPagesEnabled) { [self setShowAlternateErrorPages: alternateErrorPages_.GetValue() ? YES : NO]; @@ -1733,7 +1733,7 @@ const int kDisabledIndex = 1; // Callback when preferences are changed. |prefName| is the name of the // pref that has changed and should not be NULL. -- (void)prefChanged:(std::wstring*)prefName { +- (void)prefChanged:(std::string*)prefName { DCHECK(prefName); if (!prefName) return; [self basicsPrefChanged:prefName]; diff --git a/chrome/browser/cocoa/toolbar_controller.mm b/chrome/browser/cocoa/toolbar_controller.mm index f36dde5..db37585 100644 --- a/chrome/browser/cocoa/toolbar_controller.mm +++ b/chrome/browser/cocoa/toolbar_controller.mm @@ -80,7 +80,7 @@ const CGFloat kWrenchMenuLeftPadding = 3.0; @interface ToolbarController(Private) - (void)addAccessibilityDescriptions; - (void)initCommandStatus:(CommandUpdater*)commands; -- (void)prefChanged:(std::wstring*)prefName; +- (void)prefChanged:(std::string*)prefName; - (BackgroundGradientView*)backgroundGradientView; - (void)toolbarFrameChanged; - (void)pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate; @@ -166,7 +166,7 @@ class NotificationBridge : public NotificationObserver { const NotificationSource& source, const NotificationDetails& details) { if (type == NotificationType::PREF_CHANGED) - [controller_ prefChanged:Details<std::wstring>(details).ptr()]; + [controller_ prefChanged:Details<std::string>(details).ptr()]; else if (type == NotificationType::UPGRADE_RECOMMENDED) [controller_ badgeWrenchMenu]; } @@ -583,7 +583,7 @@ class NotificationBridge : public NotificationObserver { [wrenchMenuController_ insertUpdateAvailableItem]; } -- (void)prefChanged:(std::wstring*)prefName { +- (void)prefChanged:(std::string*)prefName { if (!prefName) return; if (*prefName == prefs::kShowHomeButton) { [self showOptionalHomeButton]; diff --git a/chrome/browser/cocoa/window_size_autosaver.h b/chrome/browser/cocoa/window_size_autosaver.h index f6fe2fd..be4dfc1 100644 --- a/chrome/browser/cocoa/window_size_autosaver.h +++ b/chrome/browser/cocoa/window_size_autosaver.h @@ -32,13 +32,13 @@ enum WindowSizeAutosaverState { @interface WindowSizeAutosaver : NSObject { NSWindow* window_; // weak PrefService* prefService_; // weak - const wchar_t* path_; + const char* path_; WindowSizeAutosaverState state_; } - (id)initWithWindow:(NSWindow*)window prefService:(PrefService*)prefs - path:(const wchar_t*)path + path:(const char*)path state:(WindowSizeAutosaverState)state; @end diff --git a/chrome/browser/cocoa/window_size_autosaver.mm b/chrome/browser/cocoa/window_size_autosaver.mm index a200090..581f6fc 100644 --- a/chrome/browser/cocoa/window_size_autosaver.mm +++ b/chrome/browser/cocoa/window_size_autosaver.mm @@ -25,7 +25,7 @@ const int kMinWindowHeight = 17; - (id)initWithWindow:(NSWindow*)window prefService:(PrefService*)prefs - path:(const wchar_t*)path + path:(const char*)path state:(WindowSizeAutosaverState)state { if ((self = [super init])) { window_ = window; @@ -58,17 +58,17 @@ const int kMinWindowHeight = 17; NSRect frame = [window_ frame]; if (state_ == kSaveWindowRect) { // Save the origin of the window. - windowPrefs->SetInteger(L"left", NSMinX(frame)); - windowPrefs->SetInteger(L"right", NSMaxX(frame)); + windowPrefs->SetInteger("left", NSMinX(frame)); + windowPrefs->SetInteger("right", NSMaxX(frame)); // windows's and linux's profiles have top < bottom due to having their // screen origin in the upper left, while cocoa's is in the lower left. To // keep the top < bottom invariant, store top in bottom and vice versa. - windowPrefs->SetInteger(L"top", NSMinY(frame)); - windowPrefs->SetInteger(L"bottom", NSMaxY(frame)); + windowPrefs->SetInteger("top", NSMinY(frame)); + windowPrefs->SetInteger("bottom", NSMaxY(frame)); } else if (state_ == kSaveWindowPos) { // Save the origin of the window. - windowPrefs->SetInteger(L"x", frame.origin.x); - windowPrefs->SetInteger(L"y", frame.origin.y); + windowPrefs->SetInteger("x", frame.origin.x); + windowPrefs->SetInteger("y", frame.origin.y); } else { NOTREACHED(); } @@ -79,18 +79,18 @@ const int kMinWindowHeight = 17; DictionaryValue* windowPrefs = prefService_->GetMutableDictionary(path_); if (state_ == kSaveWindowRect) { int x1, x2, y1, y2; - if (!windowPrefs->GetInteger(L"left", &x1) || - !windowPrefs->GetInteger(L"right", &x2) || - !windowPrefs->GetInteger(L"top", &y1) || - !windowPrefs->GetInteger(L"bottom", &y2)) { + if (!windowPrefs->GetInteger("left", &x1) || + !windowPrefs->GetInteger("right", &x2) || + !windowPrefs->GetInteger("top", &y1) || + !windowPrefs->GetInteger("bottom", &y2)) { return; } if (x2 - x1 < kMinWindowWidth || y2 - y1 < kMinWindowHeight) { // Windows should never be very small. - windowPrefs->Remove(L"left", NULL); - windowPrefs->Remove(L"right", NULL); - windowPrefs->Remove(L"top", NULL); - windowPrefs->Remove(L"bottom", NULL); + windowPrefs->Remove("left", NULL); + windowPrefs->Remove("right", NULL); + windowPrefs->Remove("top", NULL); + windowPrefs->Remove("bottom", NULL); } else { [window_ setFrame:NSMakeRect(x1, y1, x2 - x1, y2 - y1) display:YES]; @@ -99,8 +99,8 @@ const int kMinWindowHeight = 17; } } else if (state_ == kSaveWindowPos) { int x, y; - if (!windowPrefs->GetInteger(L"x", &x) || - !windowPrefs->GetInteger(L"y", &y)) + if (!windowPrefs->GetInteger("x", &x) || + !windowPrefs->GetInteger("y", &y)) return; // Nothing stored. // Turn the origin (lower-left) into an upper-left window point. NSPoint upperLeft = NSMakePoint(x, y + NSHeight([window_ frame])); diff --git a/chrome/browser/cocoa/window_size_autosaver_unittest.mm b/chrome/browser/cocoa/window_size_autosaver_unittest.mm index b3ce0d2..163b5a1 100644 --- a/chrome/browser/cocoa/window_size_autosaver_unittest.mm +++ b/chrome/browser/cocoa/window_size_autosaver_unittest.mm @@ -18,7 +18,7 @@ namespace { class WindowSizeAutosaverTest : public CocoaTest { virtual void SetUp() { CocoaTest::SetUp(); - path_ = L"WindowSizeAutosaverTest"; + path_ = "WindowSizeAutosaverTest"; window_ = [[NSWindow alloc] initWithContentRect:NSMakeRect(100, 101, 150, 151) styleMask:NSTitledWindowMask @@ -35,7 +35,7 @@ class WindowSizeAutosaverTest : public CocoaTest { public: BrowserTestHelper browser_helper_; NSWindow* window_; - const wchar_t* path_; + const char* path_; }; TEST_F(WindowSizeAutosaverTest, RestoresAndSavesPos) { @@ -87,12 +87,12 @@ TEST_F(WindowSizeAutosaverTest, RestoresAndSavesPos) { EXPECT_TRUE(pref->GetDictionary(path_) != NULL); int x, y; DictionaryValue* windowPref = pref->GetMutableDictionary(path_); - EXPECT_FALSE(windowPref->GetInteger(L"left", &x)); - EXPECT_FALSE(windowPref->GetInteger(L"right", &x)); - EXPECT_FALSE(windowPref->GetInteger(L"top", &x)); - EXPECT_FALSE(windowPref->GetInteger(L"bottom", &x)); - ASSERT_TRUE(windowPref->GetInteger(L"x", &x)); - ASSERT_TRUE(windowPref->GetInteger(L"y", &y)); + EXPECT_FALSE(windowPref->GetInteger("left", &x)); + EXPECT_FALSE(windowPref->GetInteger("right", &x)); + EXPECT_FALSE(windowPref->GetInteger("top", &x)); + EXPECT_FALSE(windowPref->GetInteger("bottom", &x)); + ASSERT_TRUE(windowPref->GetInteger("x", &x)); + ASSERT_TRUE(windowPref->GetInteger("y", &y)); EXPECT_EQ(300, x); EXPECT_EQ(310, y); } @@ -146,12 +146,12 @@ TEST_F(WindowSizeAutosaverTest, RestoresAndSavesRect) { EXPECT_TRUE(pref->GetDictionary(path_) != NULL); int x1, y1, x2, y2; DictionaryValue* windowPref = pref->GetMutableDictionary(path_); - EXPECT_FALSE(windowPref->GetInteger(L"x", &x1)); - EXPECT_FALSE(windowPref->GetInteger(L"y", &x1)); - ASSERT_TRUE(windowPref->GetInteger(L"left", &x1)); - ASSERT_TRUE(windowPref->GetInteger(L"right", &x2)); - ASSERT_TRUE(windowPref->GetInteger(L"top", &y1)); - ASSERT_TRUE(windowPref->GetInteger(L"bottom", &y2)); + EXPECT_FALSE(windowPref->GetInteger("x", &x1)); + EXPECT_FALSE(windowPref->GetInteger("y", &x1)); + ASSERT_TRUE(windowPref->GetInteger("left", &x1)); + ASSERT_TRUE(windowPref->GetInteger("right", &x2)); + ASSERT_TRUE(windowPref->GetInteger("top", &y1)); + ASSERT_TRUE(windowPref->GetInteger("bottom", &y2)); EXPECT_EQ(300, x1); EXPECT_EQ(310, y1); EXPECT_EQ(300 + 250, x2); @@ -164,10 +164,10 @@ TEST_F(WindowSizeAutosaverTest, DoesNotRestoreButClearsEmptyRect) { ASSERT_TRUE(pref != NULL); DictionaryValue* windowPref = pref->GetMutableDictionary(path_); - windowPref->SetInteger(L"left", 50); - windowPref->SetInteger(L"right", 50); - windowPref->SetInteger(L"top", 60); - windowPref->SetInteger(L"bottom", 60); + windowPref->SetInteger("left", 50); + windowPref->SetInteger("right", 50); + windowPref->SetInteger("top", 60); + windowPref->SetInteger("bottom", 60); { // Window rect shouldn't change... @@ -186,12 +186,12 @@ TEST_F(WindowSizeAutosaverTest, DoesNotRestoreButClearsEmptyRect) { // ...and it should be gone from the profile, too. EXPECT_TRUE(pref->GetDictionary(path_) != NULL); int x1, y1, x2, y2; - EXPECT_FALSE(windowPref->GetInteger(L"x", &x1)); - EXPECT_FALSE(windowPref->GetInteger(L"y", &x1)); - ASSERT_FALSE(windowPref->GetInteger(L"left", &x1)); - ASSERT_FALSE(windowPref->GetInteger(L"right", &x2)); - ASSERT_FALSE(windowPref->GetInteger(L"top", &y1)); - ASSERT_FALSE(windowPref->GetInteger(L"bottom", &y2)); + EXPECT_FALSE(windowPref->GetInteger("x", &x1)); + EXPECT_FALSE(windowPref->GetInteger("y", &x1)); + ASSERT_FALSE(windowPref->GetInteger("left", &x1)); + ASSERT_FALSE(windowPref->GetInteger("right", &x2)); + ASSERT_FALSE(windowPref->GetInteger("top", &y1)); + ASSERT_FALSE(windowPref->GetInteger("bottom", &y2)); } } // namespace diff --git a/chrome/browser/command_line_pref_store.h b/chrome/browser/command_line_pref_store.h index f577e00..5e92636 100644 --- a/chrome/browser/command_line_pref_store.h +++ b/chrome/browser/command_line_pref_store.h @@ -37,7 +37,7 @@ class CommandLinePrefStore : public PrefStore { struct StringSwitchToPreferenceMapEntry { const char* switch_name; - const wchar_t* preference_path; + const char* preference_path; }; static const StringSwitchToPreferenceMapEntry string_switch_map_[]; @@ -45,7 +45,7 @@ class CommandLinePrefStore : public PrefStore { // is present. struct BooleanSwitchToPreferenceMapEntry { const char* switch_name; - const wchar_t* preference_path; + const char* preference_path; bool set_value; }; static const BooleanSwitchToPreferenceMapEntry boolean_switch_map_[]; diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc index 91ace00..bf027c0 100644 --- a/chrome/browser/debugger/devtools_window.cc +++ b/chrome/browser/debugger/devtools_window.cc @@ -26,7 +26,7 @@ #include "chrome/common/url_constants.h" #include "grit/generated_resources.h" -const std::wstring DevToolsWindow::kDevToolsApp = L"DevToolsApp"; +const char DevToolsWindow::kDevToolsApp[] = "DevToolsApp"; // static TabContents* DevToolsWindow::GetDevToolsContents(TabContents* inspected_tab) { @@ -195,9 +195,9 @@ RenderViewHost* DevToolsWindow::GetRenderViewHost() { void DevToolsWindow::CreateDevToolsBrowser() { // TODO(pfeldman): Make browser's getter for this key static. - std::wstring wp_key = L""; + std::string wp_key; wp_key.append(prefs::kBrowserWindowPlacement); - wp_key.append(L"_"); + wp_key.append("_"); wp_key.append(kDevToolsApp); PrefService* prefs = g_browser_process->local_state(); diff --git a/chrome/browser/debugger/devtools_window.h b/chrome/browser/debugger/devtools_window.h index 5e9e08b..d69e7d5 100644 --- a/chrome/browser/debugger/devtools_window.h +++ b/chrome/browser/debugger/devtools_window.h @@ -31,7 +31,7 @@ class DevToolsWindow public NotificationObserver, public TabContentsDelegate { public: - static const std::wstring kDevToolsApp; + static const char kDevToolsApp[]; static TabContents* GetDevToolsContents(TabContents* inspected_tab); DevToolsWindow(Profile* profile, RenderViewHost* inspected_rvh, bool docked); diff --git a/chrome/browser/dom_ui/advanced_options_handler.cc b/chrome/browser/dom_ui/advanced_options_handler.cc index 64f0f60..464d7ff 100644 --- a/chrome/browser/dom_ui/advanced_options_handler.cc +++ b/chrome/browser/dom_ui/advanced_options_handler.cc @@ -179,7 +179,7 @@ void AdvancedOptionsHandler::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { if (type == NotificationType::PREF_CHANGED) { - std::wstring* pref_name = Details<std::wstring>(details).ptr(); + std::string* pref_name = Details<std::string>(details).ptr(); if (*pref_name == prefs::kDownloadDefaultDirectory) { SetupDownloadLocationPath(); } else if (*pref_name == prefs::kDownloadExtensionsToOpen) { diff --git a/chrome/browser/dom_ui/core_options_handler.cc b/chrome/browser/dom_ui/core_options_handler.cc index b556c82..f01a726 100644 --- a/chrome/browser/dom_ui/core_options_handler.cc +++ b/chrome/browser/dom_ui/core_options_handler.cc @@ -25,7 +25,7 @@ CoreOptionsHandler::~CoreOptionsHandler() { // Remove registered preference change notification observers. DCHECK(dom_ui_); PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs(); - std::wstring last_pref; + std::string last_pref; for (PreferenceCallbackMap::const_iterator iter = pref_callback_map_.begin(); iter != pref_callback_map_.end(); ++iter) { @@ -89,7 +89,7 @@ void CoreOptionsHandler::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { if (type == NotificationType::PREF_CHANGED) - NotifyPrefChanged(Details<std::wstring>(details).ptr()); + NotifyPrefChanged(Details<std::string>(details).ptr()); } void CoreOptionsHandler::RegisterMessages() { @@ -113,7 +113,7 @@ void CoreOptionsHandler::HandleInitialize(const Value* value) { (static_cast<OptionsUI*>(dom_ui_))->InitializeHandlers(); } -Value* CoreOptionsHandler::FetchPref(const std::wstring& pref_name) { +Value* CoreOptionsHandler::FetchPref(const std::string& pref_name) { DCHECK(dom_ui_); PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs(); @@ -123,14 +123,14 @@ Value* CoreOptionsHandler::FetchPref(const std::wstring& pref_name) { return pref ? pref->GetValue()->DeepCopy() : Value::CreateNullValue(); } -void CoreOptionsHandler::ObservePref(const std::wstring& pref_name) { +void CoreOptionsHandler::ObservePref(const std::string& pref_name) { DCHECK(dom_ui_); PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs(); pref_service->AddPrefObserver(pref_name.c_str(), this); } -void CoreOptionsHandler::SetPref(const std::wstring& pref_name, +void CoreOptionsHandler::SetPref(const std::string& pref_name, Value::ValueType pref_type, const std::string& value_string) { DCHECK(dom_ui_); @@ -185,7 +185,7 @@ void CoreOptionsHandler::HandleFetchPrefs(const Value* value) { if (!list_member->IsType(Value::TYPE_STRING)) continue; - std::wstring pref_name; + std::string pref_name; if (!list_member->GetAsString(&pref_name)) continue; @@ -219,7 +219,7 @@ void CoreOptionsHandler::HandleObservePrefs(const Value* value) { break; // Just ignore bad pref identifiers for now. - std::wstring pref_name; + std::string pref_name; if (!list_member->IsType(Value::TYPE_STRING) || !list_member->GetAsString(&pref_name)) continue; @@ -256,7 +256,7 @@ void CoreOptionsHandler::HandleSetPref(const Value* value, if (param_values->GetSize() != 2) return; - std::wstring pref_name; + std::string pref_name; if (!param_values->GetString(0, &pref_name)) return; @@ -267,7 +267,7 @@ void CoreOptionsHandler::HandleSetPref(const Value* value, SetPref(pref_name, type, value_string); } -void CoreOptionsHandler::NotifyPrefChanged(const std::wstring* pref_name) { +void CoreOptionsHandler::NotifyPrefChanged(const std::string* pref_name) { DCHECK(pref_name); DCHECK(dom_ui_); PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs(); diff --git a/chrome/browser/dom_ui/core_options_handler.h b/chrome/browser/dom_ui/core_options_handler.h index c88f01a..1e807b3 100644 --- a/chrome/browser/dom_ui/core_options_handler.h +++ b/chrome/browser/dom_ui/core_options_handler.h @@ -33,18 +33,18 @@ class CoreOptionsHandler : public OptionsPageUIHandler { protected: // Fetches a pref value of given |pref_name|. // Note that caller owns the returned Value. - virtual Value* FetchPref(const std::wstring& pref_name); + virtual Value* FetchPref(const std::string& pref_name); // Observes a pref of given |pref_name|. - virtual void ObservePref(const std::wstring& pref_name); + virtual void ObservePref(const std::string& pref_name); // Sets a pref value |value_string| of |pref_type| to given |pref_name|. - virtual void SetPref(const std::wstring& pref_name, + virtual void SetPref(const std::string& pref_name, Value::ValueType pref_type, const std::string& value_string); private: - typedef std::multimap<std::wstring, std::wstring> PreferenceCallbackMap; + typedef std::multimap<std::string, std::wstring> PreferenceCallbackMap; // Callback for the "coreOptionsInitialize" message. This message will // trigger the Initialize() method of all other handlers so that final // setup can be performed before the page is shown. @@ -70,7 +70,7 @@ class CoreOptionsHandler : public OptionsPageUIHandler { void HandleSetPref(const Value* value, Value::ValueType type); - void NotifyPrefChanged(const std::wstring* pref_name); + void NotifyPrefChanged(const std::string* pref_name); PreferenceCallbackMap pref_callback_map_; DISALLOW_COPY_AND_ASSIGN(CoreOptionsHandler); diff --git a/chrome/browser/dom_ui/font_settings_handler.cc b/chrome/browser/dom_ui/font_settings_handler.cc index e6402fe..67c46316 100644 --- a/chrome/browser/dom_ui/font_settings_handler.cc +++ b/chrome/browser/dom_ui/font_settings_handler.cc @@ -119,7 +119,7 @@ void FontSettingsHandler::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { if (type == NotificationType::PREF_CHANGED) { - std::wstring* pref_name = Details<std::wstring>(details).ptr(); + std::string* pref_name = Details<std::string>(details).ptr(); if (*pref_name == prefs::kWebKitSerifFontFamily || *pref_name == prefs::kWebKitDefaultFontSize) { SetupSerifFontPreview(); diff --git a/chrome/browser/dom_ui/font_settings_utils_mac.mm b/chrome/browser/dom_ui/font_settings_utils_mac.mm index 33eb468..01d4f76 100644 --- a/chrome/browser/dom_ui/font_settings_utils_mac.mm +++ b/chrome/browser/dom_ui/font_settings_utils_mac.mm @@ -12,7 +12,7 @@ #include "chrome/common/pref_names.h" static void ValidateFontFamily(PrefService* prefs, - const wchar_t* family_pref_name) { + const char* family_pref_name) { // The native font settings dialog saved fonts by the font name, rather // than the family name. This worked for the old dialog since // -[NSFont fontWithName:size] accepted a font or family name, but the diff --git a/chrome/browser/dom_ui/ntp_resource_cache.cc b/chrome/browser/dom_ui/ntp_resource_cache.cc index 94fff13..15a2016 100644 --- a/chrome/browser/dom_ui/ntp_resource_cache.cc +++ b/chrome/browser/dom_ui/ntp_resource_cache.cc @@ -176,7 +176,7 @@ void NTPResourceCache::Observe(NotificationType type, new_tab_incognito_css_ = NULL; new_tab_css_ = NULL; } else if (NotificationType::PREF_CHANGED == type) { - std::wstring* pref_name = Details<std::wstring>(details).ptr(); + std::string* pref_name = Details<std::string>(details).ptr(); if (*pref_name == prefs::kShowBookmarkBar || *pref_name == prefs::kHomePageIsNewTabPage || *pref_name == prefs::kNTPShownSections) { diff --git a/chrome/browser/dom_ui/shown_sections_handler.cc b/chrome/browser/dom_ui/shown_sections_handler.cc index b1ae3c8..e78f05b 100644 --- a/chrome/browser/dom_ui/shown_sections_handler.cc +++ b/chrome/browser/dom_ui/shown_sections_handler.cc @@ -61,7 +61,7 @@ void ShownSectionsHandler::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { DCHECK(NotificationType::PREF_CHANGED == type); - std::wstring* pref_name = Details<std::wstring>(details).ptr(); + std::string* pref_name = Details<std::string>(details).ptr(); DCHECK(*pref_name == prefs::kNTPShownSections); int sections = pref_service_->GetInteger(prefs::kNTPShownSections); diff --git a/chrome/browser/extensions/extension_pref_store.cc b/chrome/browser/extensions/extension_pref_store.cc index 5d20cae..dbac8cc 100644 --- a/chrome/browser/extensions/extension_pref_store.cc +++ b/chrome/browser/extensions/extension_pref_store.cc @@ -24,7 +24,7 @@ ExtensionPrefStore::~ExtensionPrefStore() { } void ExtensionPrefStore::InstallExtensionPref(Extension* extension, - const wchar_t* new_pref_path, + const char* new_pref_path, Value* new_pref_value) { ExtensionStack::iterator i; for (i = extension_stack_.begin(); i != extension_stack_.end(); ++i) { @@ -84,7 +84,7 @@ void ExtensionPrefStore::GetExtensionIDs(std::vector<std::string>* result) { // a given preference, among other optimizations. But probably fewer than 10 // installed extensions will be trying to control any preferences, so stick // with this simpler algorithm until it causes a problem. -void ExtensionPrefStore::UpdateOnePref(const wchar_t* path) { +void ExtensionPrefStore::UpdateOnePref(const char* path) { scoped_ptr<Value> old_value; PrefService* pref_service = GetPrefService(); diff --git a/chrome/browser/extensions/extension_pref_store.h b/chrome/browser/extensions/extension_pref_store.h index 98a2b00..47eac8d 100644 --- a/chrome/browser/extensions/extension_pref_store.h +++ b/chrome/browser/extensions/extension_pref_store.h @@ -38,7 +38,7 @@ class ExtensionPrefStore : public PrefStore, // must be called each time an extension API tries to set a preference. // The ExtensionPrefStore will take ownership of the |pref_value|. virtual void InstallExtensionPref(Extension* extension, - const wchar_t* pref_path, + const char* pref_path, Value* pref_value); // Removes an extension and all its preference settings from this PrefStore. @@ -54,7 +54,7 @@ class ExtensionPrefStore : public PrefStore, // The nested pairs are <extension, <pref_path, pref_value> >. This is here, // rather than in (say) notification_type.h, to keep the dependency on // std::pair out of the many places that include notification_type.h. - typedef std::pair<Extension*, std::pair<const wchar_t*, Value*> > + typedef std::pair<Extension*, std::pair<const char*, Value*> > ExtensionPrefDetails; protected: @@ -69,12 +69,12 @@ class ExtensionPrefStore : public PrefStore, private: // Maps preference paths to their values. - typedef std::map<const wchar_t*, Value*> PrefValueMap; + typedef std::map<const char*, Value*> PrefValueMap; // Applies the highest-priority extension's setting for the given preference // path to the |prefs_| store, or clears the setting there if no extensions // wish to control it. - void UpdateOnePref(const wchar_t* path); + void UpdateOnePref(const char* path); // Updates each preference in the key set of the |pref_values| map. void UpdatePrefs(const PrefValueMap* pref_values); diff --git a/chrome/browser/extensions/extension_pref_store_unittest.cc b/chrome/browser/extensions/extension_pref_store_unittest.cc index 55d300e2..05cd322 100644 --- a/chrome/browser/extensions/extension_pref_store_unittest.cc +++ b/chrome/browser/extensions/extension_pref_store_unittest.cc @@ -83,7 +83,7 @@ class MockPrefService : public PrefService { fired_observers_(false) {} // Tracks whether the observers would have been notified. - virtual void FireObserversIfChanged(const wchar_t* pref_name, + virtual void FireObserversIfChanged(const char* pref_name, const Value* old_value) { fired_observers_ = PrefIsChanged(pref_name, old_value); } @@ -92,10 +92,10 @@ class MockPrefService : public PrefService { }; // Use static constants to avoid confusing std::map with hard-coded strings. -static const wchar_t* kPref1 = L"path1.subpath"; -static const wchar_t* kPref2 = L"path2"; -static const wchar_t* kPref3 = L"path3"; -static const wchar_t* kPref4 = L"path4"; +static const char* kPref1 = "path1.subpath"; +static const char* kPref2 = "path2"; +static const char* kPref3 = "path3"; +static const char* kPref4 = "path4"; } // namespace diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index d7bfc8d..cf15d02 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -314,7 +314,7 @@ bool CreateWindowFunction::RunImpl() { // // NOTE(rafaelw): It's ok if GetCurrentBrowser() returns NULL here. // GetBrowserWindowBounds will default to saved "default" values for the app. - WindowSizer::GetBrowserWindowBounds(std::wstring(), empty_bounds, + WindowSizer::GetBrowserWindowBounds(std::string(), empty_bounds, GetCurrentBrowser(), &bounds, &maximized); diff --git a/chrome/browser/extensions/extension_updater.cc b/chrome/browser/extensions/extension_updater.cc index 015002c..8201edd 100644 --- a/chrome/browser/extensions/extension_updater.cc +++ b/chrome/browser/extensions/extension_updater.cc @@ -334,7 +334,7 @@ ExtensionUpdater::~ExtensionUpdater() { } static void EnsureInt64PrefRegistered(PrefService* prefs, - const wchar_t name[]) { + const char name[]) { if (!prefs->FindPreference(name)) prefs->RegisterInt64Pref(name, 0); } diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc index 047f48d..a28abed 100644 --- a/chrome/browser/gtk/browser_toolbar_gtk.cc +++ b/chrome/browser/gtk/browser_toolbar_gtk.cc @@ -377,7 +377,7 @@ void BrowserToolbarGtk::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { if (type == NotificationType::PREF_CHANGED) { - NotifyPrefChanged(Details<std::wstring>(details).ptr()); + NotifyPrefChanged(Details<std::string>(details).ptr()); } else if (type == NotificationType::BROWSER_THEME_CHANGED) { // Update the spacing around the menu buttons bool use_gtk = theme_provider_->UseGtkTheme(); @@ -627,7 +627,7 @@ void BrowserToolbarGtk::OnDragDataReceived(GtkWidget* widget, home_page_.SetValue(url.spec()); } -void BrowserToolbarGtk::NotifyPrefChanged(const std::wstring* pref) { +void BrowserToolbarGtk::NotifyPrefChanged(const std::string* pref) { if (!pref || *pref == prefs::kShowHomeButton) { if (show_home_button_.GetValue() && !ShouldOnlyShowLocation()) { gtk_widget_show(home_->widget()); diff --git a/chrome/browser/gtk/browser_toolbar_gtk.h b/chrome/browser/gtk/browser_toolbar_gtk.h index 38b7d7f..09f04f1 100644 --- a/chrome/browser/gtk/browser_toolbar_gtk.h +++ b/chrome/browser/gtk/browser_toolbar_gtk.h @@ -160,7 +160,7 @@ class BrowserToolbarGtk : public CommandUpdater::CommandObserver, GdkEventExpose*); // Updates preference-dependent state. - void NotifyPrefChanged(const std::wstring* pref); + void NotifyPrefChanged(const std::string* pref); // Start the upgrade notification animation if we have detected an upgrade // and the current toolbar is focused. diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index e7b0007..e81bca9 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -1141,7 +1141,7 @@ void BrowserWindowGtk::Observe(NotificationType type, break; case NotificationType::PREF_CHANGED: { - std::wstring* pref_name = Details<std::wstring>(details).ptr(); + std::string* pref_name = Details<std::string>(details).ptr(); if (*pref_name == prefs::kUseCustomChromeFrame) { UpdateCustomFrame(); } else { @@ -1750,27 +1750,27 @@ void BrowserWindowGtk::SaveWindowPosition() { if (!g_browser_process->local_state()) return; - std::wstring window_name = browser_->GetWindowPlacementKey(); + std::string window_name = browser_->GetWindowPlacementKey(); DictionaryValue* window_preferences = g_browser_process->local_state()->GetMutableDictionary( window_name.c_str()); // Note that we store left/top for consistency with Windows, but that we // *don't* obey them; we only use them for computing width/height. See // comments in SetGeometryHints(). - window_preferences->SetInteger(L"left", restored_bounds_.x()); - window_preferences->SetInteger(L"top", restored_bounds_.y()); - window_preferences->SetInteger(L"right", restored_bounds_.right()); - window_preferences->SetInteger(L"bottom", restored_bounds_.bottom()); - window_preferences->SetBoolean(L"maximized", IsMaximized()); + window_preferences->SetInteger("left", restored_bounds_.x()); + window_preferences->SetInteger("top", restored_bounds_.y()); + window_preferences->SetInteger("right", restored_bounds_.right()); + window_preferences->SetInteger("bottom", restored_bounds_.bottom()); + window_preferences->SetBoolean("maximized", IsMaximized()); scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_info_provider( WindowSizer::CreateDefaultMonitorInfoProvider()); gfx::Rect work_area( monitor_info_provider->GetMonitorWorkAreaMatching(restored_bounds_)); - window_preferences->SetInteger(L"work_area_left", work_area.x()); - window_preferences->SetInteger(L"work_area_top", work_area.y()); - window_preferences->SetInteger(L"work_area_right", work_area.right()); - window_preferences->SetInteger(L"work_area_bottom", work_area.bottom()); + window_preferences->SetInteger("work_area_left", work_area.x()); + window_preferences->SetInteger("work_area_top", work_area.y()); + window_preferences->SetInteger("work_area_right", work_area.right()); + window_preferences->SetInteger("work_area_bottom", work_area.bottom()); } // static diff --git a/chrome/browser/gtk/gtk_theme_provider.cc b/chrome/browser/gtk/gtk_theme_provider.cc index 577c6d1..3ffaae5 100644 --- a/chrome/browser/gtk/gtk_theme_provider.cc +++ b/chrome/browser/gtk/gtk_theme_provider.cc @@ -345,7 +345,7 @@ void GtkThemeProvider::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { if ((type == NotificationType::PREF_CHANGED) && - (*Details<std::wstring>(details).ptr() == prefs::kUsesSystemTheme)) + (*Details<std::string>(details).ptr() == prefs::kUsesSystemTheme)) use_gtk_ = profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme); } diff --git a/chrome/browser/gtk/options/advanced_contents_gtk.cc b/chrome/browser/gtk/options/advanced_contents_gtk.cc index 15650b2..f400b75 100644 --- a/chrome/browser/gtk/options/advanced_contents_gtk.cc +++ b/chrome/browser/gtk/options/advanced_contents_gtk.cc @@ -153,7 +153,7 @@ class DownloadSection : public OptionsPageBase { private: // Overridden from OptionsPageBase. - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); // Callbacks for the widgets. static void OnDownloadLocationChanged(GtkFileChooser* widget, @@ -268,7 +268,7 @@ DownloadSection::DownloadSection(Profile* profile) NotifyPrefChanged(NULL); } -void DownloadSection::NotifyPrefChanged(const std::wstring* pref_name) { +void DownloadSection::NotifyPrefChanged(const std::string* pref_name) { pref_changing_ = true; if (!pref_name || *pref_name == prefs::kDownloadDefaultDirectory) { gtk_file_chooser_set_current_folder( @@ -351,7 +351,7 @@ class NetworkSection : public OptionsPageBase { private: // Overridden from OptionsPageBase. - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); struct ProxyConfigCommand { std::string binary; @@ -409,7 +409,7 @@ NetworkSection::NetworkSection(Profile* profile) NotifyPrefChanged(NULL); } -void NetworkSection::NotifyPrefChanged(const std::wstring* pref_name) { +void NetworkSection::NotifyPrefChanged(const std::string* pref_name) { if (!pref_name || proxy_prefs_->IsObserved(*pref_name)) gtk_widget_set_sensitive(change_proxies_button_, !proxy_prefs_->IsManaged()); @@ -520,7 +520,7 @@ class TranslateSection : public OptionsPageBase { private: // Overridden from OptionsPageBase. - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); CHROMEGTK_CALLBACK_0(TranslateSection, void, OnTranslateClicked); @@ -566,7 +566,7 @@ TranslateSection::TranslateSection(Profile* profile) NotifyPrefChanged(NULL); } -void TranslateSection::NotifyPrefChanged(const std::wstring* pref_name) { +void TranslateSection::NotifyPrefChanged(const std::string* pref_name) { pref_changing_ = true; if (!pref_name || *pref_name == prefs::kEnableTranslate) { gtk_toggle_button_set_active( @@ -601,7 +601,7 @@ class PrivacySection : public OptionsPageBase { private: // Overridden from OptionsPageBase. - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); // Try to make the the crash stats consent and the metrics upload // permission match the |reporting_enabled_checkbox_|. @@ -887,7 +887,7 @@ void PrivacySection::OnLoggingChange(GtkWidget* widget, privacy_section->enable_metrics_recording_.SetValue(enabled); } -void PrivacySection::NotifyPrefChanged(const std::wstring* pref_name) { +void PrivacySection::NotifyPrefChanged(const std::string* pref_name) { pref_changing_ = true; if (!pref_name || *pref_name == prefs::kAlternateErrorPagesEnabled) { gtk_toggle_button_set_active( @@ -961,7 +961,7 @@ class SecuritySection : public OptionsPageBase { private: // Overridden from OptionsPageBase. - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); // The callback functions for the options widgets. static void OnManageCertificatesClicked(GtkButton* button, @@ -1055,7 +1055,7 @@ SecuritySection::SecuritySection(Profile* profile) NotifyPrefChanged(NULL); } -void SecuritySection::NotifyPrefChanged(const std::wstring* pref_name) { +void SecuritySection::NotifyPrefChanged(const std::string* pref_name) { pref_changing_ = true; if (!pref_name || *pref_name == prefs::kCertRevocationCheckingEnabled) { gtk_toggle_button_set_active( diff --git a/chrome/browser/gtk/options/content_page_gtk.cc b/chrome/browser/gtk/options/content_page_gtk.cc index 7f363cf..a9e9514 100644 --- a/chrome/browser/gtk/options/content_page_gtk.cc +++ b/chrome/browser/gtk/options/content_page_gtk.cc @@ -150,7 +150,7 @@ void ContentPageGtk::OnStateChanged() { // If |pref_name| is NULL, set the state of all the widgets. (This is used // in ContentPageGtk() above to initialize the dialog.) Otherwise, reset the // state of the widget for the given preference name, as it has changed. -void ContentPageGtk::NotifyPrefChanged(const std::wstring* pref_name) { +void ContentPageGtk::NotifyPrefChanged(const std::string* pref_name) { initializing_ = true; if (!pref_name || *pref_name == prefs::kPasswordManagerEnabled) { if (ask_to_save_passwords_.GetValue()) { diff --git a/chrome/browser/gtk/options/content_page_gtk.h b/chrome/browser/gtk/options/content_page_gtk.h index 675f0a2..f41cf99 100644 --- a/chrome/browser/gtk/options/content_page_gtk.h +++ b/chrome/browser/gtk/options/content_page_gtk.h @@ -34,7 +34,7 @@ class ContentPageGtk : public OptionsPageBase, void UpdateSyncControls(); // Overridden from OptionsPageBase. - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); // Overridden from OptionsPageBase. virtual void Observe(NotificationType type, diff --git a/chrome/browser/gtk/options/cookie_filter_page_gtk.cc b/chrome/browser/gtk/options/cookie_filter_page_gtk.cc index d51c91d..1826694 100644 --- a/chrome/browser/gtk/options/cookie_filter_page_gtk.cc +++ b/chrome/browser/gtk/options/cookie_filter_page_gtk.cc @@ -50,7 +50,7 @@ CookieFilterPageGtk::CookieFilterPageGtk(Profile* profile) CookieFilterPageGtk::~CookieFilterPageGtk() { } -void CookieFilterPageGtk::NotifyPrefChanged(const std::wstring* pref_name) { +void CookieFilterPageGtk::NotifyPrefChanged(const std::string* pref_name) { initializing_ = true; if (!pref_name || *pref_name == prefs::kClearSiteDataOnExit) { diff --git a/chrome/browser/gtk/options/cookie_filter_page_gtk.h b/chrome/browser/gtk/options/cookie_filter_page_gtk.h index ff65022..8aaf214 100644 --- a/chrome/browser/gtk/options/cookie_filter_page_gtk.h +++ b/chrome/browser/gtk/options/cookie_filter_page_gtk.h @@ -30,7 +30,7 @@ class CookieFilterPageGtk : public OptionsPageBase { private: // Overridden from OptionsPageBase - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); virtual void HighlightGroup(OptionsGroup highlight_group); CHROMEGTK_CALLBACK_0(CookieFilterPageGtk, void, OnCookiesAllowToggled); diff --git a/chrome/browser/gtk/options/fonts_page_gtk.cc b/chrome/browser/gtk/options/fonts_page_gtk.cc index 33b0bb8..abb544d 100644 --- a/chrome/browser/gtk/options/fonts_page_gtk.cc +++ b/chrome/browser/gtk/options/fonts_page_gtk.cc @@ -120,7 +120,7 @@ void FontsPageGtk::InitDefaultEncodingComboBox() { } } -void FontsPageGtk::NotifyPrefChanged(const std::wstring* pref_name) { +void FontsPageGtk::NotifyPrefChanged(const std::string* pref_name) { if (!pref_name || *pref_name == prefs::kWebKitSerifFontFamily || *pref_name == prefs::kWebKitDefaultFontSize) { gtk_font_button_set_font_name(GTK_FONT_BUTTON(serif_font_button_), diff --git a/chrome/browser/gtk/options/fonts_page_gtk.h b/chrome/browser/gtk/options/fonts_page_gtk.h index eb90901..b1ef255 100644 --- a/chrome/browser/gtk/options/fonts_page_gtk.h +++ b/chrome/browser/gtk/options/fonts_page_gtk.h @@ -32,7 +32,7 @@ class FontsPageGtk : public OptionsPageBase { void InitDefaultEncodingComboBox(); // Overridden from OptionsPageBase. - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); // Retrieve the font selection from the button and save it to the prefs. Also // ensure the button(s) are displayed in the proper size, as the diff --git a/chrome/browser/gtk/options/general_page_gtk.cc b/chrome/browser/gtk/options/general_page_gtk.cc index 53615f0..ea3adc9 100644 --- a/chrome/browser/gtk/options/general_page_gtk.cc +++ b/chrome/browser/gtk/options/general_page_gtk.cc @@ -120,7 +120,7 @@ GeneralPageGtk::~GeneralPageGtk() { /////////////////////////////////////////////////////////////////////////////// // GeneralPageGtk, OptionsPageBase overrides: -void GeneralPageGtk::NotifyPrefChanged(const std::wstring* pref_name) { +void GeneralPageGtk::NotifyPrefChanged(const std::string* pref_name) { initializing_ = true; if (!pref_name || *pref_name == prefs::kRestoreOnStartup) { PrefService* prefs = profile()->GetPrefs(); diff --git a/chrome/browser/gtk/options/general_page_gtk.h b/chrome/browser/gtk/options/general_page_gtk.h index 3ac5f66..acfee2f 100644 --- a/chrome/browser/gtk/options/general_page_gtk.h +++ b/chrome/browser/gtk/options/general_page_gtk.h @@ -35,7 +35,7 @@ class GeneralPageGtk : public OptionsPageBase, private: // Overridden from OptionsPageBase - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); virtual void HighlightGroup(OptionsGroup highlight_group); // Initialize the option group widgets, return their container diff --git a/chrome/browser/gtk/options/languages_page_gtk.cc b/chrome/browser/gtk/options/languages_page_gtk.cc index 4b8d8e3..19c2d15 100644 --- a/chrome/browser/gtk/options/languages_page_gtk.cc +++ b/chrome/browser/gtk/options/languages_page_gtk.cc @@ -313,7 +313,7 @@ int LanguagesPageGtk::FirstSelectedRowNum() { return row_num; } -void LanguagesPageGtk::NotifyPrefChanged(const std::wstring* pref_name) { +void LanguagesPageGtk::NotifyPrefChanged(const std::string* pref_name) { initializing_ = true; if (!pref_name || *pref_name == prefs::kAcceptLanguages) { language_order_table_model_->SetAcceptLanguagesString( @@ -321,7 +321,7 @@ void LanguagesPageGtk::NotifyPrefChanged(const std::wstring* pref_name) { } if (!pref_name || *pref_name == prefs::kSpellCheckDictionary) { int index = dictionary_language_model_->GetSelectedLanguageIndex( - prefs::kSpellCheckDictionary); + UTF8ToWide(prefs::kSpellCheckDictionary)); // If not found, fall back from "language-region" to "language". if (index < 0) { @@ -329,7 +329,7 @@ void LanguagesPageGtk::NotifyPrefChanged(const std::wstring* pref_name) { dictionary_language_.SetValue( SpellCheckCommon::GetLanguageFromLanguageRegion(lang_region)); index = dictionary_language_model_->GetSelectedLanguageIndex( - prefs::kSpellCheckDictionary); + UTF8ToWide(prefs::kSpellCheckDictionary)); } gtk_combo_box_set_active(GTK_COMBO_BOX(dictionary_language_combobox_), diff --git a/chrome/browser/gtk/options/languages_page_gtk.h b/chrome/browser/gtk/options/languages_page_gtk.h index f3f56d4..5fe66a9 100644 --- a/chrome/browser/gtk/options/languages_page_gtk.h +++ b/chrome/browser/gtk/options/languages_page_gtk.h @@ -59,7 +59,7 @@ class LanguagesPageGtk int FirstSelectedRowNum(); // Overridden from OptionsPageBase. - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); // Callbacks for accept languages widgets. CHROMEG_CALLBACK_0(LanguagesPageGtk, void, OnSelectionChanged, diff --git a/chrome/browser/host_content_settings_map.cc b/chrome/browser/host_content_settings_map.cc index 3bf6d13..dabdc96 100644 --- a/chrome/browser/host_content_settings_map.cc +++ b/chrome/browser/host_content_settings_map.cc @@ -505,10 +505,10 @@ void HostContentSettingsMap::SetContentSetting( { AutoLock auto_lock(lock_); - if (!map_to_modify->count(pattern.AsString())) - (*map_to_modify)[pattern.AsString()].content_settings = ContentSettings(); + if (!map_to_modify->count(pattern_str)) + (*map_to_modify)[pattern_str].content_settings = ContentSettings(); HostContentSettings::iterator - i(map_to_modify->find(pattern.AsString())); + i(map_to_modify->find(pattern_str)); ContentSettings& settings = i->second.content_settings; if (RequiresResourceIdentifier(content_type)) { settings.settings[content_type] = CONTENT_SETTING_DEFAULT; @@ -725,7 +725,7 @@ void HostContentSettingsMap::Observe(NotificationType type, if (updating_preferences_) return; - std::wstring* name = Details<std::wstring>(details).ptr(); + std::string* name = Details<std::string>(details).ptr(); if (prefs::kDefaultContentSettings == *name) { ReadDefaultSettings(true); } else if (prefs::kContentSettingsPatterns == *name) { diff --git a/chrome/browser/host_zoom_map.cc b/chrome/browser/host_zoom_map.cc index 512fdf0..b676cf4 100644 --- a/chrome/browser/host_zoom_map.cc +++ b/chrome/browser/host_zoom_map.cc @@ -94,13 +94,11 @@ void HostZoomMap::SetZoomLevel(const GURL& url, int level) { ScopedPrefUpdate update(profile_->GetPrefs(), prefs::kPerHostZoomLevels); DictionaryValue* host_zoom_dictionary = profile_->GetPrefs()->GetMutableDictionary(prefs::kPerHostZoomLevels); - std::wstring wide_host(UTF8ToWide(host)); if (level == 0) { - host_zoom_dictionary->RemoveWithoutPathExpansion(wide_host, NULL); + host_zoom_dictionary->RemoveWithoutPathExpansion(host, NULL); } else { host_zoom_dictionary->SetWithoutPathExpansion( - wide_host, - Value::CreateIntegerValue(level)); + host, Value::CreateIntegerValue(level)); } } updating_preferences_ = false; @@ -150,7 +148,7 @@ void HostZoomMap::Observe( if (updating_preferences_) return; - std::wstring* name = Details<std::wstring>(details).ptr(); + std::string* name = Details<std::string>(details).ptr(); if (prefs::kPerHostZoomLevels == *name) { Load(); return; diff --git a/chrome/browser/host_zoom_map_unittest.cc b/chrome/browser/host_zoom_map_unittest.cc index a59a142..4b20a09 100644 --- a/chrome/browser/host_zoom_map_unittest.cc +++ b/chrome/browser/host_zoom_map_unittest.cc @@ -40,7 +40,7 @@ class HostZoomMapTest : public testing::Test { pref_observer_, Observe(NotificationType(NotificationType::PREF_CHANGED), _, - Property(&Details<std::wstring>::ptr, + Property(&Details<std::string>::ptr, Pointee(per_host_zoom_levels_pref_)))); } @@ -48,7 +48,7 @@ class HostZoomMapTest : public testing::Test { ChromeThread ui_thread_; TestingProfile profile_; PrefService* prefs_; - std::wstring per_host_zoom_levels_pref_; // For the observe matcher. + std::string per_host_zoom_levels_pref_; // For the observe matcher. GURL url_; std::string host_; NotificationObserverMock pref_observer_; diff --git a/chrome/browser/managed_prefs_banner_base.cc b/chrome/browser/managed_prefs_banner_base.cc index 0297488..6836e0c 100644 --- a/chrome/browser/managed_prefs_banner_base.cc +++ b/chrome/browser/managed_prefs_banner_base.cc @@ -21,19 +21,19 @@ ManagedPrefsBannerBase::ManagedPrefsBannerBase(PrefService* local_state, Init(local_state, user_prefs, page); } -void ManagedPrefsBannerBase::AddLocalStatePref(const wchar_t* pref) { +void ManagedPrefsBannerBase::AddLocalStatePref(const char* pref) { local_state_set_->AddPref(pref); } -void ManagedPrefsBannerBase::RemoveLocalStatePref(const wchar_t* pref) { +void ManagedPrefsBannerBase::RemoveLocalStatePref(const char* pref) { local_state_set_->RemovePref(pref); } -void ManagedPrefsBannerBase::AddUserPref(const wchar_t* pref) { +void ManagedPrefsBannerBase::AddUserPref(const char* pref) { user_pref_set_->AddPref(pref); } -void ManagedPrefsBannerBase::RemoveUserPref(const wchar_t* pref) { +void ManagedPrefsBannerBase::RemoveUserPref(const char* pref) { user_pref_set_->RemovePref(pref); } @@ -79,7 +79,7 @@ void ManagedPrefsBannerBase::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { if (NotificationType::PREF_CHANGED == type) { - std::wstring* pref = Details<std::wstring>(details).ptr(); + std::string* pref = Details<std::string>(details).ptr(); if (pref && (local_state_set_->IsObserved(*pref) || user_pref_set_->IsObserved(*pref))) OnUpdateVisibility(); diff --git a/chrome/browser/managed_prefs_banner_base.h b/chrome/browser/managed_prefs_banner_base.h index 78a24a4..9baadc9f 100644 --- a/chrome/browser/managed_prefs_banner_base.h +++ b/chrome/browser/managed_prefs_banner_base.h @@ -36,14 +36,14 @@ class ManagedPrefsBannerBase : public NotificationObserver { bool DetermineVisibility() const; // Add a local state preference as visibility trigger. - void AddLocalStatePref(const wchar_t* pref); + void AddLocalStatePref(const char* pref); // Remove a local state preference from being a visibility trigger. - void RemoveLocalStatePref(const wchar_t* pref); + void RemoveLocalStatePref(const char* pref); // Add a user preference as visibility trigger. - void AddUserPref(const wchar_t* pref); + void AddUserPref(const char* pref); // Remove a user preference from being a visibility trigger. - void RemoveUserPref(const wchar_t* pref); + void RemoveUserPref(const char* pref); protected: // Update banner visibility. This is called whenever a preference change is diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc index fb7f8a2..4b0db68 100644 --- a/chrome/browser/metrics/metrics_log.cc +++ b/chrome/browser/metrics/metrics_log.cc @@ -158,13 +158,13 @@ void MetricsLog::WritePluginStabilityElements(PrefService* pref) { } DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*iter); - std::wstring plugin_name; + std::string plugin_name; plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name); OPEN_ELEMENT_FOR_SCOPE("pluginstability"); // Use "filename" instead of "name", otherwise we need to update the // UMA servers. - WriteAttribute("filename", CreateBase64Hash(WideToUTF8(plugin_name))); + WriteAttribute("filename", CreateBase64Hash(plugin_name)); int launches = 0; plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches); @@ -352,7 +352,7 @@ void MetricsLog::RecordEnvironment( void MetricsLog::WriteAllProfilesMetrics( const DictionaryValue& all_profiles_metrics) { - const std::string profile_prefix(WideToUTF8(prefs::kProfilePrefix)); + const std::string profile_prefix(prefs::kProfilePrefix); for (DictionaryValue::key_iterator i = all_profiles_metrics.begin_keys(); i != all_profiles_metrics.end_keys(); ++i) { const std::string& key_name = *i; diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc index 1dcc6df..df65772 100644 --- a/chrome/browser/metrics/metrics_service.cc +++ b/chrome/browser/metrics/metrics_service.cc @@ -1716,14 +1716,14 @@ void MetricsService::LogLoadComplete(NotificationType type, load_details->load_time()); } -void MetricsService::IncrementPrefValue(const wchar_t* path) { +void MetricsService::IncrementPrefValue(const char* path) { PrefService* pref = g_browser_process->local_state(); DCHECK(pref); int value = pref->GetInteger(path); pref->SetInteger(path, value + 1); } -void MetricsService::IncrementLongPrefsValue(const wchar_t* path) { +void MetricsService::IncrementLongPrefsValue(const char* path) { PrefService* pref = g_browser_process->local_state(); DCHECK(pref); int64 value = pref->GetInt64(path); @@ -1800,8 +1800,8 @@ static void CountBookmarks(const BookmarkNode* node, } void MetricsService::LogBookmarks(const BookmarkNode* node, - const wchar_t* num_bookmarks_key, - const wchar_t* num_folders_key) { + const char* num_bookmarks_key, + const char* num_folders_key) { DCHECK(node); int num_bookmarks = 0; int num_folders = 0; @@ -1847,18 +1847,20 @@ void MetricsService::RecordPluginChanges(PrefService* pref) { } DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*value_iter); - std::wstring plugin_name; + std::string plugin_name; plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name); if (plugin_name.empty()) { NOTREACHED(); continue; } - if (child_process_stats_buffer_.find(plugin_name) == + // TODO(viettrungluu): remove conversions + if (child_process_stats_buffer_.find(UTF8ToWide(plugin_name)) == child_process_stats_buffer_.end()) continue; - ChildProcessStats stats = child_process_stats_buffer_[plugin_name]; + ChildProcessStats stats = + child_process_stats_buffer_[UTF8ToWide(plugin_name)]; if (stats.process_launches) { int launches = 0; plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches); @@ -1878,7 +1880,7 @@ void MetricsService::RecordPluginChanges(PrefService* pref) { plugin_dict->SetInteger(prefs::kStabilityPluginInstances, instances); } - child_process_stats_buffer_.erase(plugin_name); + child_process_stats_buffer_.erase(UTF8ToWide(plugin_name)); } // Now go through and add dictionaries for plugins that didn't already have @@ -1892,7 +1894,8 @@ void MetricsService::RecordPluginChanges(PrefService* pref) { if (ChildProcessInfo::PLUGIN_PROCESS != stats.process_type) continue; - std::wstring plugin_name = cache_iter->first; + // TODO(viettrungluu): remove conversion + std::string plugin_name = WideToUTF8(cache_iter->first); DictionaryValue* plugin_dict = new DictionaryValue; @@ -1917,7 +1920,7 @@ bool MetricsService::CanLogNotification(NotificationType type, return !BrowserList::IsOffTheRecordSessionActive(); } -void MetricsService::RecordBooleanPrefValue(const wchar_t* path, bool value) { +void MetricsService::RecordBooleanPrefValue(const char* path, bool value) { DCHECK(IsSingleThreaded()); PrefService* pref = g_browser_process->local_state(); diff --git a/chrome/browser/metrics/metrics_service.h b/chrome/browser/metrics/metrics_service.h index 65f2af9..db402a5 100644 --- a/chrome/browser/metrics/metrics_service.h +++ b/chrome/browser/metrics/metrics_service.h @@ -334,11 +334,11 @@ class MetricsService : public NotificationObserver, const NotificationDetails& details); // Reads, increments and then sets the specified integer preference. - void IncrementPrefValue(const wchar_t* path); + void IncrementPrefValue(const char* path); // Reads, increments and then sets the specified long preference that is // stored as a string. - void IncrementLongPrefsValue(const wchar_t* path); + void IncrementLongPrefsValue(const char* path); // Records a renderer process crash. void LogRendererCrash(); @@ -353,8 +353,8 @@ class MetricsService : public NotificationObserver, // in node. The pref key for the number of bookmarks in num_bookmarks_key and // the pref key for number of folders in num_folders_key. void LogBookmarks(const BookmarkNode* node, - const wchar_t* num_bookmarks_key, - const wchar_t* num_folders_key); + const char* num_bookmarks_key, + const char* num_folders_key); // Sets preferences for the number of bookmarks in model. void LogBookmarks(BookmarkModel* model); @@ -392,7 +392,7 @@ class MetricsService : public NotificationObserver, const NotificationDetails& details); // Sets the value of the specified path in prefs and schedules a save. - void RecordBooleanPrefValue(const wchar_t* path, bool value); + void RecordBooleanPrefValue(const char* path, bool value); NotificationRegistrar registrar_; diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index 8e9b6ba..a67e506 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -662,7 +662,7 @@ void ChromeURLRequestContextGetter::Observe( CheckCurrentlyOnMainThread(); if (NotificationType::PREF_CHANGED == type) { - std::wstring* pref_name_in = Details<std::wstring>(details).ptr(); + std::string* pref_name_in = Details<std::string>(details).ptr(); PrefService* prefs = Source<PrefService>(source).ptr(); DCHECK(pref_name_in && prefs); if (*pref_name_in == prefs::kAcceptLanguages) { @@ -1019,7 +1019,7 @@ void ChromeURLRequestContextFactory::ApplyProfileParametersToContext( net::ProxyConfig* CreateProxyConfig(const PrefService* pref_service) { // Scan for all "enable" type proxy switches. - static const wchar_t* proxy_prefs[] = { + static const char* proxy_prefs[] = { prefs::kProxyPacUrl, prefs::kProxyServer, prefs::kProxyBypassList, diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc index 49610ef..47c7591 100644 --- a/chrome/browser/notifications/desktop_notification_service.cc +++ b/chrome/browser/notifications/desktop_notification_service.cc @@ -295,7 +295,7 @@ void DesktopNotificationService::Observe(NotificationType type, const NotificationDetails& details) { DCHECK(NotificationType::PREF_CHANGED == type); PrefService* prefs = profile_->GetPrefs(); - std::wstring* name = Details<std::wstring>(details).ptr(); + std::string* name = Details<std::string>(details).ptr(); if (0 == name->compare(prefs::kDesktopNotificationAllowedOrigins)) { std::vector<GURL> allowed_origins(GetAllowedOrigins()); diff --git a/chrome/browser/options_page_base.cc b/chrome/browser/options_page_base.cc index 260fb5b..5099aa9 100644 --- a/chrome/browser/options_page_base.cc +++ b/chrome/browser/options_page_base.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-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. @@ -32,5 +32,5 @@ void OptionsPageBase::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { if (type == NotificationType::PREF_CHANGED) - NotifyPrefChanged(Details<std::wstring>(details).ptr()); + NotifyPrefChanged(Details<std::string>(details).ptr()); } diff --git a/chrome/browser/options_page_base.h b/chrome/browser/options_page_base.h index 79229b6..0e6c756 100644 --- a/chrome/browser/options_page_base.h +++ b/chrome/browser/options_page_base.h @@ -50,7 +50,7 @@ class OptionsPageBase : public NotificationObserver { // the specific pref that changed, or NULL if all pref UI should be // validated. This should be called during setup, but with NULL as the // parameter to allow initial state to be set. - virtual void NotifyPrefChanged(const std::wstring* pref_name) { } + virtual void NotifyPrefChanged(const std::string* pref_name) {} private: // The Profile associated with this page. diff --git a/chrome/browser/options_util.cc b/chrome/browser/options_util.cc index 5ab7b06..fa9a229 100644 --- a/chrome/browser/options_util.cc +++ b/chrome/browser/options_util.cc @@ -21,7 +21,7 @@ void OptionsUtil::ResetToDefaults(Profile* profile) { // changes to any of the options pages doesn't require updating this list // manually. PrefService* prefs = profile->GetPrefs(); - const wchar_t* kUserPrefs[] = { + const char* kUserPrefs[] = { prefs::kAcceptLanguages, prefs::kAlternateErrorPagesEnabled, prefs::kClearSiteDataOnExit, @@ -82,7 +82,7 @@ void OptionsUtil::ResetToDefaults(Profile* profile) { // settings they'll either inadvertedly enable this logging or disable it. // One is undesirable for them, one is undesirable for us. For now, we just // don't reset it. - const wchar_t* kLocalStatePrefs[] = { + const char* kLocalStatePrefs[] = { prefs::kApplicationLocale, }; for (size_t i = 0; i < arraysize(kLocalStatePrefs); ++i) diff --git a/chrome/browser/policy/configuration_policy_pref_store.h b/chrome/browser/policy/configuration_policy_pref_store.h index df35238..a214ea2 100644 --- a/chrome/browser/policy/configuration_policy_pref_store.h +++ b/chrome/browser/policy/configuration_policy_pref_store.h @@ -49,7 +49,7 @@ class ConfigurationPolicyPrefStore : public PrefStore, struct PolicyToPreferenceMapEntry { Value::ValueType value_type; PolicyType policy_type; - const wchar_t* preference_path; // A DictionaryValue path, not a file path. + const char* preference_path; // A DictionaryValue path, not a file path. }; static const PolicyToPreferenceMapEntry simple_policy_map_[]; diff --git a/chrome/browser/policy/configuration_policy_pref_store_unittest.cc b/chrome/browser/policy/configuration_policy_pref_store_unittest.cc index fa63845..ecb8fc4 100644 --- a/chrome/browser/policy/configuration_policy_pref_store_unittest.cc +++ b/chrome/browser/policy/configuration_policy_pref_store_unittest.cc @@ -17,74 +17,74 @@ class ConfigurationPolicyPrefStoreTest : public testing::Test { void ApplyStringPolicyValue( ConfigurationPolicyPrefStore* store, ConfigurationPolicyStore::PolicyType type, - const wchar_t* policy_value); + const char* policy_value); // The following three methods test a policy which controls a string // preference. // Checks that by default, it's an empty string. - void TestStringPolicyGetDefault(const wchar_t* pref_name); + void TestStringPolicyGetDefault(const char* pref_name); // Checks that values can be set. - void TestStringPolicySetValue(const wchar_t* pref_name, + void TestStringPolicySetValue(const char* pref_name, ConfigurationPolicyStore::PolicyType type); // A wrapper that calls the above two methods. - void TestStringPolicy(const wchar_t* pref_name, + void TestStringPolicy(const char* pref_name, ConfigurationPolicyStore::PolicyType type); // The following three methods test a policy which controls a boolean // preference. // Checks that there's no deafult. - void TestBooleanPolicyGetDefault(const wchar_t* pref_name); + void TestBooleanPolicyGetDefault(const char* pref_name); // Checks that values can be set. - void TestBooleanPolicySetValue(const wchar_t* pref_name, + void TestBooleanPolicySetValue(const char* pref_name, ConfigurationPolicyStore::PolicyType type); // A wrapper that calls the above two methods. - void TestBooleanPolicy(const wchar_t* pref_name, + void TestBooleanPolicy(const char* pref_name, ConfigurationPolicyStore::PolicyType type); // The following three methods test a policy which controls an integer // preference. // Checks that by default, it's 0. - void TestIntegerPolicyGetDefault(const wchar_t* pref_name); + void TestIntegerPolicyGetDefault(const char* pref_name); // Checks that values can be set. - void TestIntegerPolicySetValue(const wchar_t* pref_name, + void TestIntegerPolicySetValue(const char* pref_name, ConfigurationPolicyStore::PolicyType type); // A wrapper that calls the above two methods. - void TestIntegerPolicy(const wchar_t* pref_name, + void TestIntegerPolicy(const char* pref_name, ConfigurationPolicyStore::PolicyType type); }; void ConfigurationPolicyPrefStoreTest::ApplyStringPolicyValue( ConfigurationPolicyPrefStore* store, ConfigurationPolicyStore::PolicyType type, - const wchar_t* policy_value) { + const char* policy_value) { store->Apply(type, Value::CreateStringValue(policy_value)); } void ConfigurationPolicyPrefStoreTest::TestStringPolicyGetDefault( - const wchar_t* pref_name) { + const char* pref_name) { ConfigurationPolicyPrefStore store(NULL, NULL); - std::wstring result; + std::string result; store.prefs()->GetString(pref_name, &result); - EXPECT_EQ(result, L""); + EXPECT_EQ(result, ""); } void ConfigurationPolicyPrefStoreTest::TestStringPolicySetValue( - const wchar_t* pref_name, ConfigurationPolicyStore::PolicyType type) { + const char* pref_name, ConfigurationPolicyStore::PolicyType type) { ConfigurationPolicyPrefStore store(NULL, NULL); - ApplyStringPolicyValue(&store, type, L"http://chromium.org"); - std::wstring result; + ApplyStringPolicyValue(&store, type, "http://chromium.org"); + std::string result; store.prefs()->GetString(pref_name, &result); - EXPECT_EQ(result, L"http://chromium.org"); + EXPECT_EQ(result, "http://chromium.org"); } void ConfigurationPolicyPrefStoreTest::TestStringPolicy( - const wchar_t* pref_name, ConfigurationPolicyStore::PolicyType type) { + const char* pref_name, ConfigurationPolicyStore::PolicyType type) { TestStringPolicyGetDefault(pref_name); TestStringPolicySetValue(pref_name, type); } void ConfigurationPolicyPrefStoreTest::TestBooleanPolicyGetDefault( - const wchar_t* pref_name) { + const char* pref_name) { ConfigurationPolicyPrefStore store(NULL, NULL); bool result = false; store.prefs()->GetBoolean(pref_name, &result); @@ -95,7 +95,7 @@ void ConfigurationPolicyPrefStoreTest::TestBooleanPolicyGetDefault( } void ConfigurationPolicyPrefStoreTest::TestBooleanPolicySetValue( - const wchar_t* pref_name, ConfigurationPolicyStore::PolicyType type) { + const char* pref_name, ConfigurationPolicyStore::PolicyType type) { ConfigurationPolicyPrefStore store(NULL, NULL); store.Apply(type, Value::CreateBooleanValue(false)); bool result = true; @@ -109,13 +109,13 @@ void ConfigurationPolicyPrefStoreTest::TestBooleanPolicySetValue( } void ConfigurationPolicyPrefStoreTest::TestBooleanPolicy( - const wchar_t* pref_name, ConfigurationPolicyStore::PolicyType type) { + const char* pref_name, ConfigurationPolicyStore::PolicyType type) { TestBooleanPolicyGetDefault(pref_name); TestBooleanPolicySetValue(pref_name, type); } void ConfigurationPolicyPrefStoreTest::TestIntegerPolicyGetDefault( - const wchar_t* pref_name) { + const char* pref_name) { ConfigurationPolicyPrefStore store(NULL, NULL); int result = 0; store.prefs()->GetInteger(pref_name, &result); @@ -123,7 +123,7 @@ void ConfigurationPolicyPrefStoreTest::TestIntegerPolicyGetDefault( } void ConfigurationPolicyPrefStoreTest::TestIntegerPolicySetValue( - const wchar_t* pref_name, ConfigurationPolicyStore::PolicyType type) { + const char* pref_name, ConfigurationPolicyStore::PolicyType type) { ConfigurationPolicyPrefStore store(NULL, NULL); store.Apply(type, Value::CreateIntegerValue(2)); int result = 0; @@ -132,7 +132,7 @@ void ConfigurationPolicyPrefStoreTest::TestIntegerPolicySetValue( } void ConfigurationPolicyPrefStoreTest::TestIntegerPolicy( - const wchar_t* pref_name, ConfigurationPolicyStore::PolicyType type) { + const char* pref_name, ConfigurationPolicyStore::PolicyType type) { TestIntegerPolicyGetDefault(pref_name); TestIntegerPolicySetValue(pref_name, type); } @@ -209,15 +209,15 @@ TEST_F(ConfigurationPolicyPrefStoreTest, TestSettingsProxyConfig) { // Ensure that all traces of the command-line specified proxy // switches have been overriden. - std::wstring string_result; + std::string string_result; EXPECT_TRUE(store.prefs()->GetString(prefs::kProxyBypassList, &string_result)); - EXPECT_EQ(string_result, L"http://chromium3.org"); + EXPECT_EQ(string_result, "http://chromium3.org"); EXPECT_TRUE(store.prefs()->GetString(prefs::kProxyPacUrl, &string_result)); - EXPECT_EQ(string_result, L"http://chromium.org/test.pac"); + EXPECT_EQ(string_result, "http://chromium.org/test.pac"); EXPECT_TRUE(store.prefs()->GetString(prefs::kProxyServer, &string_result)); - EXPECT_EQ(string_result, L"http://chromium2.org"); + EXPECT_EQ(string_result, "http://chromium2.org"); bool bool_result; EXPECT_TRUE(store.prefs()->GetBoolean(prefs::kNoProxyServer, &bool_result)); EXPECT_TRUE(bool_result); @@ -244,7 +244,7 @@ TEST_F(ConfigurationPolicyPrefStoreTest, TestPolicyProxyConfigManualOverride) { Value::CreateIntegerValue( ConfigurationPolicyStore::kPolicyManuallyConfiguredProxyMode)); provider->AddPolicy(ConfigurationPolicyStore::kPolicyProxyBypassList, - Value::CreateStringValue(L"http://chromium.org/override")); + Value::CreateStringValue("http://chromium.org/override")); ConfigurationPolicyPrefStore store(&command_line, provider.release()); @@ -252,10 +252,10 @@ TEST_F(ConfigurationPolicyPrefStoreTest, TestPolicyProxyConfigManualOverride) { // Ensure that all traces of the command-line specified proxy // switches have been overriden. - std::wstring string_result; + std::string string_result; EXPECT_TRUE(store.prefs()->GetString(prefs::kProxyBypassList, &string_result)); - EXPECT_EQ(string_result, L"http://chromium.org/override"); + EXPECT_EQ(string_result, "http://chromium.org/override"); EXPECT_FALSE(store.prefs()->GetString(prefs::kProxyPacUrl, &string_result)); EXPECT_FALSE(store.prefs()->GetString(prefs::kProxyServer, &string_result)); @@ -273,7 +273,7 @@ TEST_F(ConfigurationPolicyPrefStoreTest, TestPolicyProxyConfigNoProxy) { scoped_ptr<MockConfigurationPolicyProvider> provider( new MockConfigurationPolicyProvider()); provider->AddPolicy(ConfigurationPolicyStore::kPolicyProxyBypassList, - Value::CreateStringValue(L"http://chromium.org/override")); + Value::CreateStringValue("http://chromium.org/override")); provider->AddPolicy(ConfigurationPolicyStore::kPolicyProxyServerMode, Value::CreateIntegerValue( ConfigurationPolicyStore::kPolicyNoProxyServerMode)); @@ -281,7 +281,7 @@ TEST_F(ConfigurationPolicyPrefStoreTest, TestPolicyProxyConfigNoProxy) { ConfigurationPolicyPrefStore store(&command_line, provider.release()); EXPECT_EQ(store.ReadPrefs(), PrefStore::PREF_READ_ERROR_NONE); - std::wstring string_result; + std::string string_result; EXPECT_FALSE(store.prefs()->GetString(prefs::kProxyBypassList, &string_result)); @@ -305,12 +305,12 @@ TEST_F(ConfigurationPolicyPrefStoreTest, Value::CreateIntegerValue( ConfigurationPolicyStore::kPolicyNoProxyServerMode)); provider->AddPolicy(ConfigurationPolicyStore::kPolicyProxyBypassList, - Value::CreateStringValue(L"http://chromium.org/override")); + Value::CreateStringValue("http://chromium.org/override")); ConfigurationPolicyPrefStore store(&command_line, provider.release()); EXPECT_EQ(store.ReadPrefs(), PrefStore::PREF_READ_ERROR_NONE); - std::wstring string_result; + std::string string_result; EXPECT_FALSE(store.prefs()->GetString(prefs::kProxyBypassList, &string_result)); @@ -330,7 +330,7 @@ TEST_F(ConfigurationPolicyPrefStoreTest, TestPolicyProxyConfigAutoDetect) { scoped_ptr<MockConfigurationPolicyProvider> provider( new MockConfigurationPolicyProvider()); provider->AddPolicy(ConfigurationPolicyStore::kPolicyProxyBypassList, - Value::CreateStringValue(L"http://chromium.org/override")); + Value::CreateStringValue("http://chromium.org/override")); provider->AddPolicy(ConfigurationPolicyStore::kPolicyProxyServerMode, Value::CreateIntegerValue( ConfigurationPolicyStore::kPolicyAutoDetectProxyMode)); @@ -340,10 +340,10 @@ TEST_F(ConfigurationPolicyPrefStoreTest, TestPolicyProxyConfigAutoDetect) { // Ensure that all traces of the command-line specified proxy // switches have been overriden. - std::wstring string_result; + std::string string_result; EXPECT_TRUE(store.prefs()->GetString(prefs::kProxyBypassList, &string_result)); - EXPECT_EQ(string_result, L"http://chromium.org/override"); + EXPECT_EQ(string_result, "http://chromium.org/override"); EXPECT_FALSE(store.prefs()->GetString(prefs::kProxyPacUrl, &string_result)); EXPECT_FALSE(store.prefs()->GetString(prefs::kProxyServer, &string_result)); @@ -361,7 +361,7 @@ TEST_F(ConfigurationPolicyPrefStoreTest, TestPolicyProxyConfiguseSystem) { scoped_ptr<MockConfigurationPolicyProvider> provider( new MockConfigurationPolicyProvider()); provider->AddPolicy(ConfigurationPolicyStore::kPolicyProxyBypassList, - Value::CreateStringValue(L"http://chromium.org/override")); + Value::CreateStringValue("http://chromium.org/override")); provider->AddPolicy(ConfigurationPolicyStore::kPolicyProxyServerMode, Value::CreateIntegerValue( ConfigurationPolicyStore::kPolicyUseSystemProxyMode)); @@ -369,10 +369,10 @@ TEST_F(ConfigurationPolicyPrefStoreTest, TestPolicyProxyConfiguseSystem) { ConfigurationPolicyPrefStore store(&command_line, provider.release()); EXPECT_EQ(store.ReadPrefs(), PrefStore::PREF_READ_ERROR_NONE); - std::wstring string_result; + std::string string_result; EXPECT_FALSE(store.prefs()->GetString(prefs::kProxyBypassList, &string_result)); - EXPECT_EQ(string_result, L""); + EXPECT_EQ(string_result, ""); EXPECT_FALSE(store.prefs()->GetString(prefs::kProxyPacUrl, &string_result)); EXPECT_FALSE(store.prefs()->GetString(prefs::kProxyServer, &string_result)); @@ -392,15 +392,15 @@ TEST_F(ConfigurationPolicyPrefStoreTest, Value::CreateIntegerValue( ConfigurationPolicyStore::kPolicyUseSystemProxyMode)); provider->AddPolicy(ConfigurationPolicyStore::kPolicyProxyBypassList, - Value::CreateStringValue(L"http://chromium.org/override")); + Value::CreateStringValue("http://chromium.org/override")); ConfigurationPolicyPrefStore store(&command_line, provider.release()); EXPECT_EQ(store.ReadPrefs(), PrefStore::PREF_READ_ERROR_NONE); - std::wstring string_result; + std::string string_result; EXPECT_FALSE(store.prefs()->GetString(prefs::kProxyBypassList, &string_result)); - EXPECT_EQ(string_result, L""); + EXPECT_EQ(string_result, ""); EXPECT_FALSE(store.prefs()->GetString(prefs::kProxyPacUrl, &string_result)); EXPECT_FALSE(store.prefs()->GetString(prefs::kProxyServer, &string_result)); @@ -420,7 +420,7 @@ TEST_F(ConfigurationPolicyPrefStoreTest, ConfigurationPolicyPrefStore store(&command_line, provider.release()); ApplyStringPolicyValue(&store, ConfigurationPolicyStore::kPolicyDisabledPlugins, - L"plugin1"); + "plugin1"); EXPECT_EQ(store.ReadPrefs(), PrefStore::PREF_READ_ERROR_NONE); ListValue* plugin_blacklist = NULL; @@ -448,7 +448,7 @@ TEST_F(ConfigurationPolicyPrefStoreTest, ConfigurationPolicyPrefStore store(&command_line, provider.release()); ApplyStringPolicyValue(&store, ConfigurationPolicyStore::kPolicyDisabledPlugins, - L"plugin1,plugin2\\,"); + "plugin1,plugin2\\,"); EXPECT_EQ(store.ReadPrefs(), PrefStore::PREF_READ_ERROR_NONE); ListValue* plugin_blacklist = NULL; diff --git a/chrome/browser/pref_member.cc b/chrome/browser/pref_member.cc index 9502022..3b42198 100644 --- a/chrome/browser/pref_member.cc +++ b/chrome/browser/pref_member.cc @@ -23,7 +23,7 @@ PrefMemberBase::~PrefMemberBase() { } -void PrefMemberBase::Init(const wchar_t* pref_name, PrefService* prefs, +void PrefMemberBase::Init(const char* pref_name, PrefService* prefs, NotificationObserver* observer) { DCHECK(pref_name); DCHECK(prefs); diff --git a/chrome/browser/pref_member.h b/chrome/browser/pref_member.h index 012d3a1..e9d3c53 100644 --- a/chrome/browser/pref_member.h +++ b/chrome/browser/pref_member.h @@ -41,7 +41,7 @@ class PrefMemberBase : public NotificationObserver { virtual ~PrefMemberBase(); // See PrefMember<> for description. - void Init(const wchar_t* pref_name, PrefService* prefs, + void Init(const char* pref_name, PrefService* prefs, NotificationObserver* observer); // See PrefMember<> for description. @@ -57,12 +57,12 @@ class PrefMemberBase : public NotificationObserver { // This methods is used to do the actual sync with pref of the specified type. virtual void UpdateValueFromPref() = 0; - const std::wstring& pref_name() const { return pref_name_; } + const std::string& pref_name() const { return pref_name_; } PrefService* prefs() { return prefs_; } // Ordered the members to compact the class instance. private: - std::wstring pref_name_; + std::string pref_name_; NotificationObserver* observer_; PrefService* prefs_; @@ -84,7 +84,7 @@ class PrefMember : public subtle::PrefMemberBase { // Do the actual initialization of the class. |observer| may be null if you // don't want any notifications of changes. - void Init(const wchar_t* pref_name, PrefService* prefs, + void Init(const char* pref_name, PrefService* prefs, NotificationObserver* observer) { subtle::PrefMemberBase::Init(pref_name, prefs, observer); } diff --git a/chrome/browser/pref_member_unittest.cc b/chrome/browser/pref_member_unittest.cc index b0379d6..e280c72 100644 --- a/chrome/browser/pref_member_unittest.cc +++ b/chrome/browser/pref_member_unittest.cc @@ -12,10 +12,10 @@ namespace { -static const wchar_t kBoolPref[] = L"bool"; -static const wchar_t kIntPref[] = L"int"; -static const wchar_t kRealPref[] = L"real"; -static const wchar_t kStringPref[] = L"string"; +static const char kBoolPref[] = "bool"; +static const char kIntPref[] = "int"; +static const char kRealPref[] = "real"; +static const char kStringPref[] = "string"; void RegisterTestPrefs(PrefService* prefs) { prefs->RegisterBooleanPref(kBoolPref, false); @@ -37,7 +37,7 @@ class PrefMemberTestClass : public NotificationObserver { DCHECK(NotificationType::PREF_CHANGED == type); PrefService* prefs_in = Source<PrefService>(source).ptr(); EXPECT_EQ(prefs_in, prefs_); - std::wstring* pref_name_in = Details<std::wstring>(details).ptr(); + std::string* pref_name_in = Details<std::string>(details).ptr(); EXPECT_EQ(*pref_name_in, kStringPref); EXPECT_EQ(str_.GetValue(), prefs_->GetString(kStringPref)); ++observe_cnt_; diff --git a/chrome/browser/pref_service.cc b/chrome/browser/pref_service.cc index 1fa5e6b..2a7dbe9 100644 --- a/chrome/browser/pref_service.cc +++ b/chrome/browser/pref_service.cc @@ -169,82 +169,146 @@ void PrefService::ScheduleSavePersistentPrefs() { pref_value_store_->ScheduleWritePrefs(); } -void PrefService::RegisterBooleanPref(const wchar_t* path, +void PrefService::RegisterBooleanPref(const char* path, bool default_value) { Preference* pref = new Preference(pref_value_store_.get(), path, Value::CreateBooleanValue(default_value)); RegisterPreference(pref); } -void PrefService::RegisterIntegerPref(const wchar_t* path, - int default_value) { +// TODO(viettrungluu): deprecate: +void PrefService::RegisterBooleanPref(const wchar_t* path, bool default_value) { + RegisterBooleanPref(WideToUTF8(path).c_str(), default_value); +} + +void PrefService::RegisterIntegerPref(const char* path, int default_value) { Preference* pref = new Preference(pref_value_store_.get(), path, Value::CreateIntegerValue(default_value)); RegisterPreference(pref); } -void PrefService::RegisterRealPref(const wchar_t* path, - double default_value) { +// TODO(viettrungluu): deprecate: +void PrefService::RegisterIntegerPref(const wchar_t* path, int default_value) { + RegisterIntegerPref(WideToUTF8(path).c_str(), default_value); +} + +void PrefService::RegisterRealPref(const char* path, double default_value) { Preference* pref = new Preference(pref_value_store_.get(), path, Value::CreateRealValue(default_value)); RegisterPreference(pref); } -void PrefService::RegisterStringPref(const wchar_t* path, +// TODO(viettrungluu): deprecate: +void PrefService::RegisterRealPref(const wchar_t* path, + double default_value) { + RegisterRealPref(WideToUTF8(path).c_str(), default_value); +} + +void PrefService::RegisterStringPref(const char* path, const std::string& default_value) { Preference* pref = new Preference(pref_value_store_.get(), path, Value::CreateStringValue(default_value)); RegisterPreference(pref); } -void PrefService::RegisterFilePathPref(const wchar_t* path, +// TODO(viettrungluu): deprecate: +void PrefService::RegisterStringPref(const wchar_t* path, + const std::string& default_value) { + RegisterStringPref(WideToUTF8(path).c_str(), default_value); +} + +void PrefService::RegisterFilePathPref(const char* path, const FilePath& default_value) { Preference* pref = new Preference(pref_value_store_.get(), path, Value::CreateStringValue(default_value.value())); RegisterPreference(pref); } -void PrefService::RegisterListPref(const wchar_t* path) { +// TODO(viettrungluu): deprecate: +void PrefService::RegisterFilePathPref(const wchar_t* path, + const FilePath& default_value) { + RegisterFilePathPref(WideToUTF8(path).c_str(), default_value); +} + +void PrefService::RegisterListPref(const char* path) { Preference* pref = new Preference(pref_value_store_.get(), path, new ListValue); RegisterPreference(pref); } -void PrefService::RegisterDictionaryPref(const wchar_t* path) { +// TODO(viettrungluu): deprecate: +void PrefService::RegisterListPref(const wchar_t* path) { + RegisterListPref(WideToUTF8(path).c_str()); +} + +void PrefService::RegisterDictionaryPref(const char* path) { Preference* pref = new Preference(pref_value_store_.get(), path, new DictionaryValue()); RegisterPreference(pref); } -void PrefService::RegisterLocalizedBooleanPref(const wchar_t* path, +// TODO(viettrungluu): deprecate: +void PrefService::RegisterDictionaryPref(const wchar_t* path) { + RegisterDictionaryPref(WideToUTF8(path).c_str()); +} + +void PrefService::RegisterLocalizedBooleanPref(const char* path, int locale_default_message_id) { Preference* pref = new Preference(pref_value_store_.get(), path, CreateLocaleDefaultValue(Value::TYPE_BOOLEAN, locale_default_message_id)); RegisterPreference(pref); } -void PrefService::RegisterLocalizedIntegerPref(const wchar_t* path, +// TODO(viettrungluu): deprecate: +void PrefService::RegisterLocalizedBooleanPref(const wchar_t* path, + int locale_default_message_id) { + RegisterLocalizedBooleanPref(WideToUTF8(path).c_str(), + locale_default_message_id); +} + +void PrefService::RegisterLocalizedIntegerPref(const char* path, int locale_default_message_id) { Preference* pref = new Preference(pref_value_store_.get(), path, CreateLocaleDefaultValue(Value::TYPE_INTEGER, locale_default_message_id)); RegisterPreference(pref); } -void PrefService::RegisterLocalizedRealPref(const wchar_t* path, +// TODO(viettrungluu): deprecate: +void PrefService::RegisterLocalizedIntegerPref(const wchar_t* path, + int locale_default_message_id) { + RegisterLocalizedIntegerPref(WideToUTF8(path).c_str(), + locale_default_message_id); +} + +void PrefService::RegisterLocalizedRealPref(const char* path, int locale_default_message_id) { Preference* pref = new Preference(pref_value_store_.get(), path, CreateLocaleDefaultValue(Value::TYPE_REAL, locale_default_message_id)); RegisterPreference(pref); } -void PrefService::RegisterLocalizedStringPref(const wchar_t* path, +// TODO(viettrungluu): deprecate: +void PrefService::RegisterLocalizedRealPref(const wchar_t* path, + int locale_default_message_id) { + RegisterLocalizedRealPref(WideToUTF8(path).c_str(), + locale_default_message_id); +} + +void PrefService::RegisterLocalizedStringPref(const char* path, int locale_default_message_id) { Preference* pref = new Preference(pref_value_store_.get(), path, CreateLocaleDefaultValue(Value::TYPE_STRING, locale_default_message_id)); RegisterPreference(pref); } -bool PrefService::GetBoolean(const wchar_t* path) const { +// TODO(viettrungluu): deprecate: +void PrefService::RegisterLocalizedStringPref(const wchar_t* path, + int locale_default_message_id) { + RegisterLocalizedStringPref(WideToUTF8(path).c_str(), + locale_default_message_id); +} + +bool PrefService::GetBoolean(const char* path) const { DCHECK(CalledOnValidThread()); bool result = false; @@ -259,7 +323,12 @@ bool PrefService::GetBoolean(const wchar_t* path) const { return result; } -int PrefService::GetInteger(const wchar_t* path) const { +// TODO(viettrungluu): deprecate: +bool PrefService::GetBoolean(const wchar_t* path) const { + return GetBoolean(WideToUTF8(path).c_str()); +} + +int PrefService::GetInteger(const char* path) const { DCHECK(CalledOnValidThread()); int result = 0; @@ -274,7 +343,12 @@ int PrefService::GetInteger(const wchar_t* path) const { return result; } -double PrefService::GetReal(const wchar_t* path) const { +// TODO(viettrungluu): deprecate: +int PrefService::GetInteger(const wchar_t* path) const { + return GetInteger(WideToUTF8(path).c_str()); +} + +double PrefService::GetReal(const char* path) const { DCHECK(CalledOnValidThread()); double result = 0.0; @@ -289,7 +363,12 @@ double PrefService::GetReal(const wchar_t* path) const { return result; } -std::string PrefService::GetString(const wchar_t* path) const { +// TODO(viettrungluu): deprecate: +double PrefService::GetReal(const wchar_t* path) const { + return GetReal(WideToUTF8(path).c_str()); +} + +std::string PrefService::GetString(const char* path) const { DCHECK(CalledOnValidThread()); std::string result; @@ -304,7 +383,12 @@ std::string PrefService::GetString(const wchar_t* path) const { return result; } -FilePath PrefService::GetFilePath(const wchar_t* path) const { +// TODO(viettrungluu): deprecate: +std::string PrefService::GetString(const wchar_t* path) const { + return GetString(WideToUTF8(path).c_str()); +} + +FilePath PrefService::GetFilePath(const char* path) const { DCHECK(CalledOnValidThread()); FilePath::StringType result; @@ -323,19 +407,35 @@ FilePath PrefService::GetFilePath(const wchar_t* path) const { return FilePath(result); } -bool PrefService::HasPrefPath(const wchar_t* path) const { +// TODO(viettrungluu): deprecate: +FilePath PrefService::GetFilePath(const wchar_t* path) const { + return GetFilePath(WideToUTF8(path).c_str()); +} + +bool PrefService::HasPrefPath(const char* path) const { return pref_value_store_->HasPrefPath(path); } +// TODO(viettrungluu): deprecate: +bool PrefService::HasPrefPath(const wchar_t* path) const { + return HasPrefPath(WideToUTF8(path).c_str()); +} + const PrefService::Preference* PrefService::FindPreference( - const wchar_t* pref_name) const { + const char* pref_name) const { DCHECK(CalledOnValidThread()); Preference p(NULL, pref_name, NULL); PreferenceSet::const_iterator it = prefs_.find(&p); return it == prefs_.end() ? NULL : *it; } -bool PrefService::IsManagedPreference(const wchar_t* pref_name) const { +// TODO(viettrungluu): deprecate: +const PrefService::Preference* PrefService::FindPreference( + const wchar_t* pref_name) const { + return FindPreference(WideToUTF8(pref_name).c_str()); +} + +bool PrefService::IsManagedPreference(const char* pref_name) const { const Preference* pref = FindPreference(pref_name); if (pref && pref->IsManaged()) { return true; @@ -343,18 +443,23 @@ bool PrefService::IsManagedPreference(const wchar_t* pref_name) const { return false; } -void PrefService::FireObserversIfChanged(const wchar_t* path, +// TODO(viettrungluu): deprecate: +bool PrefService::IsManagedPreference(const wchar_t* pref_name) const { + return IsManagedPreference(WideToUTF8(pref_name).c_str()); +} + +void PrefService::FireObserversIfChanged(const char* path, const Value* old_value) { if (PrefIsChanged(path, old_value)) FireObservers(path); } -void PrefService::FireObservers(const wchar_t* path) { +void PrefService::FireObservers(const char* path) { DCHECK(CalledOnValidThread()); - // Convert path to a std::wstring because the Details constructor requires a + // Convert path to a std::string because the Details constructor requires a // class. - std::wstring path_str(path); + std::string path_str(path); PrefObserverMap::iterator observer_iterator = pref_observers_.find(path_str); if (observer_iterator == pref_observers_.end()) return; @@ -364,11 +469,11 @@ void PrefService::FireObservers(const wchar_t* path) { while ((observer = it.GetNext()) != NULL) { observer->Observe(NotificationType::PREF_CHANGED, Source<PrefService>(this), - Details<std::wstring>(&path_str)); + Details<std::string>(&path_str)); } } -bool PrefService::PrefIsChanged(const wchar_t* path, +bool PrefService::PrefIsChanged(const char* path, const Value* old_value) { Value* new_value = NULL; pref_value_store_->GetValue(path, &new_value); @@ -376,7 +481,7 @@ bool PrefService::PrefIsChanged(const wchar_t* path, return (!new_value || !old_value->Equals(new_value)); } -const DictionaryValue* PrefService::GetDictionary(const wchar_t* path) const { +const DictionaryValue* PrefService::GetDictionary(const char* path) const { DCHECK(CalledOnValidThread()); const Preference* pref = FindPreference(path); @@ -390,7 +495,12 @@ const DictionaryValue* PrefService::GetDictionary(const wchar_t* path) const { return static_cast<const DictionaryValue*>(value); } -const ListValue* PrefService::GetList(const wchar_t* path) const { +// TODO(viettrungluu): deprecate: +const DictionaryValue* PrefService::GetDictionary(const wchar_t* path) const { + return GetDictionary(WideToUTF8(path).c_str()); +} + +const ListValue* PrefService::GetList(const char* path) const { DCHECK(CalledOnValidThread()); const Preference* pref = FindPreference(path); @@ -404,7 +514,12 @@ const ListValue* PrefService::GetList(const wchar_t* path) const { return static_cast<const ListValue*>(value); } -void PrefService::AddPrefObserver(const wchar_t* path, +// TODO(viettrungluu): deprecate: +const ListValue* PrefService::GetList(const wchar_t* path) const { + return GetList(WideToUTF8(path).c_str()); +} + +void PrefService::AddPrefObserver(const char* path, NotificationObserver* obs) { DCHECK(CalledOnValidThread()); @@ -438,7 +553,13 @@ void PrefService::AddPrefObserver(const wchar_t* path, observer_list->AddObserver(obs); } -void PrefService::RemovePrefObserver(const wchar_t* path, +// TODO(viettrungluu): deprecate: +void PrefService::AddPrefObserver(const wchar_t* path, + NotificationObserver* obs) { + AddPrefObserver(WideToUTF8(path).c_str(), obs); +} + +void PrefService::RemovePrefObserver(const char* path, NotificationObserver* obs) { DCHECK(CalledOnValidThread()); @@ -451,6 +572,12 @@ void PrefService::RemovePrefObserver(const wchar_t* path, observer_list->RemoveObserver(obs); } +// TODO(viettrungluu): deprecate: +void PrefService::RemovePrefObserver(const wchar_t* path, + NotificationObserver* obs) { + RemovePrefObserver(WideToUTF8(path).c_str(), obs); +} + void PrefService::RegisterPreference(Preference* pref) { DCHECK(CalledOnValidThread()); @@ -462,7 +589,7 @@ void PrefService::RegisterPreference(Preference* pref) { prefs_.insert(pref); } -void PrefService::ClearPref(const wchar_t* path) { +void PrefService::ClearPref(const char* path) { DCHECK(CalledOnValidThread()); const Preference* pref = FindPreference(path); @@ -478,7 +605,12 @@ void PrefService::ClearPref(const wchar_t* path) { FireObservers(path); } -void PrefService::Set(const wchar_t* path, const Value& value) { +// TODO(viettrungluu): deprecate: +void PrefService::ClearPref(const wchar_t* path) { + ClearPref(WideToUTF8(path).c_str()); +} + +void PrefService::Set(const char* path, const Value& value) { DCHECK(CalledOnValidThread()); const Preference* pref = FindPreference(path); @@ -509,7 +641,12 @@ void PrefService::Set(const wchar_t* path, const Value& value) { FireObserversIfChanged(path, old_value.get()); } -void PrefService::SetBoolean(const wchar_t* path, bool value) { +// TODO(viettrungluu): deprecate: +void PrefService::Set(const wchar_t* path, const Value& value) { + Set(WideToUTF8(path).c_str(), value); +} + +void PrefService::SetBoolean(const char* path, bool value) { DCHECK(CalledOnValidThread()); const Preference* pref = FindPreference(path); @@ -533,7 +670,12 @@ void PrefService::SetBoolean(const wchar_t* path, bool value) { FireObserversIfChanged(path, old_value.get()); } -void PrefService::SetInteger(const wchar_t* path, int value) { +// TODO(viettrungluu): deprecate: +void PrefService::SetBoolean(const wchar_t* path, bool value) { + SetBoolean(WideToUTF8(path).c_str(), value); +} + +void PrefService::SetInteger(const char* path, int value) { DCHECK(CalledOnValidThread()); const Preference* pref = FindPreference(path); @@ -557,7 +699,12 @@ void PrefService::SetInteger(const wchar_t* path, int value) { FireObserversIfChanged(path, old_value.get()); } -void PrefService::SetReal(const wchar_t* path, double value) { +// TODO(viettrungluu): deprecate: +void PrefService::SetInteger(const wchar_t* path, int value) { + SetInteger(WideToUTF8(path).c_str(), value); +} + +void PrefService::SetReal(const char* path, double value) { DCHECK(CalledOnValidThread()); const Preference* pref = FindPreference(path); @@ -581,7 +728,12 @@ void PrefService::SetReal(const wchar_t* path, double value) { FireObserversIfChanged(path, old_value.get()); } -void PrefService::SetString(const wchar_t* path, const std::string& value) { +// TODO(viettrungluu): deprecate: +void PrefService::SetReal(const wchar_t* path, double value) { + SetReal(WideToUTF8(path).c_str(), value); +} + +void PrefService::SetString(const char* path, const std::string& value) { DCHECK(CalledOnValidThread()); const Preference* pref = FindPreference(path); @@ -605,7 +757,12 @@ void PrefService::SetString(const wchar_t* path, const std::string& value) { FireObserversIfChanged(path, old_value.get()); } -void PrefService::SetFilePath(const wchar_t* path, const FilePath& value) { +// TODO(viettrungluu): deprecate: +void PrefService::SetString(const wchar_t* path, const std::string& value) { + SetString(WideToUTF8(path).c_str(), value); +} + +void PrefService::SetFilePath(const char* path, const FilePath& value) { DCHECK(CalledOnValidThread()); const Preference* pref = FindPreference(path); @@ -637,7 +794,12 @@ void PrefService::SetFilePath(const wchar_t* path, const FilePath& value) { FireObserversIfChanged(path, old_value.get()); } -void PrefService::SetInt64(const wchar_t* path, int64 value) { +// TODO(viettrungluu): deprecate: +void PrefService::SetFilePath(const wchar_t* path, const FilePath& value) { + SetFilePath(WideToUTF8(path).c_str(), value); +} + +void PrefService::SetInt64(const char* path, int64 value) { DCHECK(CalledOnValidThread()); const Preference* pref = FindPreference(path); @@ -661,7 +823,12 @@ void PrefService::SetInt64(const wchar_t* path, int64 value) { FireObserversIfChanged(path, old_value.get()); } -int64 PrefService::GetInt64(const wchar_t* path) const { +// TODO(viettrungluu): deprecate: +void PrefService::SetInt64(const wchar_t* path, int64 value) { + SetInt64(WideToUTF8(path).c_str(), value); +} + +int64 PrefService::GetInt64(const char* path) const { DCHECK(CalledOnValidThread()); const Preference* pref = FindPreference(path); @@ -678,13 +845,23 @@ int64 PrefService::GetInt64(const wchar_t* path) const { return val; } -void PrefService::RegisterInt64Pref(const wchar_t* path, int64 default_value) { +// TODO(viettrungluu): deprecate: +int64 PrefService::GetInt64(const wchar_t* path) const { + return GetInt64(WideToUTF8(path).c_str()); +} + +void PrefService::RegisterInt64Pref(const char* path, int64 default_value) { Preference* pref = new Preference(pref_value_store_.get(), path, Value::CreateStringValue(base::Int64ToString(default_value))); RegisterPreference(pref); } -DictionaryValue* PrefService::GetMutableDictionary(const wchar_t* path) { +// TODO(viettrungluu): deprecate: +void PrefService::RegisterInt64Pref(const wchar_t* path, int64 default_value) { + RegisterInt64Pref(WideToUTF8(path).c_str(), default_value); +} + +DictionaryValue* PrefService::GetMutableDictionary(const char* path) { DCHECK(CalledOnValidThread()); const Preference* pref = FindPreference(path); @@ -709,7 +886,12 @@ DictionaryValue* PrefService::GetMutableDictionary(const wchar_t* path) { return dict; } -ListValue* PrefService::GetMutableList(const wchar_t* path) { +// TODO(viettrungluu): deprecate: +DictionaryValue* PrefService::GetMutableDictionary(const wchar_t* path) { + return GetMutableDictionary(WideToUTF8(path).c_str()); +} + +ListValue* PrefService::GetMutableList(const char* path) { DCHECK(CalledOnValidThread()); const Preference* pref = FindPreference(path); @@ -733,7 +915,12 @@ ListValue* PrefService::GetMutableList(const wchar_t* path) { return list; } -Value* PrefService::GetPrefCopy(const wchar_t* path) { +// TODO(viettrungluu): deprecate: +ListValue* PrefService::GetMutableList(const wchar_t* path) { + return GetMutableList(WideToUTF8(path).c_str()); +} + +Value* PrefService::GetPrefCopy(const char* path) { DCHECK(CalledOnValidThread()); const Preference* pref = FindPreference(path); @@ -745,7 +932,7 @@ Value* PrefService::GetPrefCopy(const wchar_t* path) { // PrefService::Preference PrefService::Preference::Preference(PrefValueStore* pref_value_store, - const wchar_t* name, + const char* name, Value* default_value) : type_(Value::TYPE_NULL), name_(name), @@ -811,7 +998,7 @@ void PrefService::FireObserversForRefreshedManagedPrefs( for (current = changed_prefs_paths.begin(); current != changed_prefs_paths.end(); ++current) { - FireObservers(UTF8ToWide(current->data()).data()); + FireObservers(current->c_str()); } } diff --git a/chrome/browser/pref_service.h b/chrome/browser/pref_service.h index e15c5f5..58e5ea9 100644 --- a/chrome/browser/pref_service.h +++ b/chrome/browser/pref_service.h @@ -34,7 +34,6 @@ class ScopedPrefUpdate; class PrefService : public NonThreadSafe, public NotificationObserver { public: - // A helper class to store all the information associated with a preference. class Preference { public: @@ -45,7 +44,7 @@ class PrefService : public NonThreadSafe, // your own, use the PrefService::Register*Pref methods instead. // |default_value| will be owned by the Preference object. Preference(PrefValueStore* pref_value_store, - const wchar_t* name, + const char* name, Value* default_value); ~Preference() {} @@ -53,7 +52,7 @@ class PrefService : public NonThreadSafe, // Returns the name of the Preference (i.e., the key, e.g., // browser.window_placement). - const std::wstring name() const { return name_; } + const std::string name() const { return name_; } // Returns the value of the Preference. If there is no user specified // value, it returns the default value. @@ -92,7 +91,7 @@ class PrefService : public NonThreadSafe, friend class PrefService; Value::ValueType type_; - std::wstring name_; + std::string name_; scoped_ptr<Value> default_value_; // A reference to the pref service's pref_value_store_. @@ -128,7 +127,8 @@ class PrefService : public NonThreadSafe, // Returns true if the preference for the given preference name is available // and is managed. - bool IsManagedPreference(const wchar_t* pref_name) const; + bool IsManagedPreference(const char* pref_name) const; + /*DEPRECATED*/bool IsManagedPreference(const wchar_t* pref_name) const; // Writes the data to disk. The return value only reflects whether // serialization was successful; we don't know whether the data actually made @@ -141,66 +141,103 @@ class PrefService : public NonThreadSafe, void ScheduleSavePersistentPrefs(); // Make the PrefService aware of a pref. - void RegisterBooleanPref(const wchar_t* path, - bool default_value); - void RegisterIntegerPref(const wchar_t* path, - int default_value); - void RegisterRealPref(const wchar_t* path, - double default_value); - void RegisterStringPref(const wchar_t* path, - const std::string& default_value); - void RegisterFilePathPref(const wchar_t* path, - const FilePath& default_value); - void RegisterListPref(const wchar_t* path); - void RegisterDictionaryPref(const wchar_t* path); + void RegisterBooleanPref(const char* path, bool default_value); + void RegisterIntegerPref(const char* path, int default_value); + void RegisterRealPref(const char* path, double default_value); + void RegisterStringPref(const char* path, const std::string& default_value); + void RegisterFilePathPref(const char* path, const FilePath& default_value); + void RegisterListPref(const char* path); + void RegisterDictionaryPref(const char* path); + /*DEPRECATED*/void RegisterBooleanPref(const wchar_t* path, + bool default_value); + /*DEPRECATED*/void RegisterIntegerPref(const wchar_t* path, + int default_value); + /*DEPRECATED*/void RegisterRealPref(const wchar_t* path, + double default_value); + /*DEPRECATED*/void RegisterStringPref(const wchar_t* path, + const std::string& default_value); + /*DEPRECATED*/void RegisterFilePathPref(const wchar_t* path, + const FilePath& default_value); + /*DEPRECATED*/void RegisterListPref(const wchar_t* path); + /*DEPRECATED*/void RegisterDictionaryPref(const wchar_t* path); // These varients use a default value from the locale dll instead. - void RegisterLocalizedBooleanPref(const wchar_t* path, + void RegisterLocalizedBooleanPref(const char* path, int locale_default_message_id); - void RegisterLocalizedIntegerPref(const wchar_t* path, + void RegisterLocalizedIntegerPref(const char* path, int locale_default_message_id); - void RegisterLocalizedRealPref(const wchar_t* path, + void RegisterLocalizedRealPref(const char* path, int locale_default_message_id); - void RegisterLocalizedStringPref(const wchar_t* path, + void RegisterLocalizedStringPref(const char* path, int locale_default_message_id); + /*DEPRECATED*/void RegisterLocalizedBooleanPref(const wchar_t* path, + int locale_default_message_id); + /*DEPRECATED*/void RegisterLocalizedIntegerPref(const wchar_t* path, + int locale_default_message_id); + /*DEPRECATED*/void RegisterLocalizedRealPref(const wchar_t* path, + int locale_default_message_id); + /*DEPRECATED*/void RegisterLocalizedStringPref(const wchar_t* path, + int locale_default_message_id); // If the path is valid and the value at the end of the path matches the type // specified, it will return the specified value. Otherwise, the default // value (set when the pref was registered) will be returned. - bool GetBoolean(const wchar_t* path) const; - int GetInteger(const wchar_t* path) const; - double GetReal(const wchar_t* path) const; - std::string GetString(const wchar_t* path) const; - FilePath GetFilePath(const wchar_t* path) const; + bool GetBoolean(const char* path) const; + int GetInteger(const char* path) const; + double GetReal(const char* path) const; + std::string GetString(const char* path) const; + FilePath GetFilePath(const char* path) const; + /*DEPRECATED*/bool GetBoolean(const wchar_t* path) const; + /*DEPRECATED*/int GetInteger(const wchar_t* path) const; + /*DEPRECATED*/double GetReal(const wchar_t* path) const; + /*DEPRECATED*/std::string GetString(const wchar_t* path) const; + /*DEPRECATED*/FilePath GetFilePath(const wchar_t* path) const; // Returns the branch if it exists. If it's not a branch or the branch does // not exist, returns NULL. - const DictionaryValue* GetDictionary(const wchar_t* path) const; - const ListValue* GetList(const wchar_t* path) const; + const DictionaryValue* GetDictionary(const char* path) const; + const ListValue* GetList(const char* path) const; + /*DEPRECATED*/const DictionaryValue* GetDictionary(const wchar_t* path) const; + /*DEPRECATED*/const ListValue* GetList(const wchar_t* path) const; // If the pref at the given path changes, we call the observer's Observe // method with NOTIFY_PREF_CHANGED. - virtual void AddPrefObserver(const wchar_t* path, NotificationObserver* obs); - void RemovePrefObserver(const wchar_t* path, NotificationObserver* obs); + virtual void AddPrefObserver(const char* path, NotificationObserver* obs); + void RemovePrefObserver(const char* path, NotificationObserver* obs); + /*DEPRECATED*/virtual void AddPrefObserver(const wchar_t* path, + NotificationObserver* obs); + /*DEPRECATED*/void RemovePrefObserver(const wchar_t* path, + NotificationObserver* obs); // Removes a user pref and restores the pref to its default value. - void ClearPref(const wchar_t* path); + void ClearPref(const char* path); + /*DEPRECATED*/void ClearPref(const wchar_t* path); // If the path is valid (i.e., registered), update the pref value in the user // prefs. - void Set(const wchar_t* path, const Value& value); - void SetBoolean(const wchar_t* path, bool value); - void SetInteger(const wchar_t* path, int value); - void SetReal(const wchar_t* path, double value); - void SetString(const wchar_t* path, const std::string& value); - void SetFilePath(const wchar_t* path, const FilePath& value); + void Set(const char* path, const Value& value); + void SetBoolean(const char* path, bool value); + void SetInteger(const char* path, int value); + void SetReal(const char* path, double value); + void SetString(const char* path, const std::string& value); + void SetFilePath(const char* path, const FilePath& value); + /*DEPRECATED*/void Set(const wchar_t* path, const Value& value); + /*DEPRECATED*/void SetBoolean(const wchar_t* path, bool value); + /*DEPRECATED*/void SetInteger(const wchar_t* path, int value); + /*DEPRECATED*/void SetReal(const wchar_t* path, double value); + /*DEPRECATED*/void SetString(const wchar_t* path, const std::string& value); + /*DEPRECATED*/void SetFilePath(const wchar_t* path, const FilePath& value); // Int64 helper methods that actually store the given value as a string. // Note that if obtaining the named value via GetDictionary or GetList, the // Value type will be TYPE_STRING. - void SetInt64(const wchar_t* path, int64 value); - int64 GetInt64(const wchar_t* path) const; - void RegisterInt64Pref(const wchar_t* path, int64 default_value); + void SetInt64(const char* path, int64 value); + int64 GetInt64(const char* path) const; + void RegisterInt64Pref(const char* path, int64 default_value); + /*DEPRECATED*/void SetInt64(const wchar_t* path, int64 value); + /*DEPRECATED*/int64 GetInt64(const wchar_t* path) const; + /*DEPRECATED*/void RegisterInt64Pref(const wchar_t* path, + int64 default_value); // Used to set the value of dictionary or list values in the pref tree. This // will create a dictionary or list if one does not exist in the pref tree. @@ -209,14 +246,17 @@ class PrefService : public NonThreadSafe, // WARNING: Changes to the dictionary or list will not automatically notify // pref observers. // Use a ScopedPrefUpdate to update observers on changes. - DictionaryValue* GetMutableDictionary(const wchar_t* path); - ListValue* GetMutableList(const wchar_t* path); + DictionaryValue* GetMutableDictionary(const char* path); + ListValue* GetMutableList(const char* path); + /*DEPRECATED*/DictionaryValue* GetMutableDictionary(const wchar_t* path); + /*DEPRECATED*/ListValue* GetMutableList(const wchar_t* path); // Returns true if a value has been set for the specified path. // NOTE: this is NOT the same as FindPreference. In particular // FindPreference returns whether RegisterXXX has been invoked, where as // this checks if a value exists for the path. - bool HasPrefPath(const wchar_t* path) const; + bool HasPrefPath(const char* path) const; + /*DEPRECATED*/bool HasPrefPath(const wchar_t* path) const; class PreferencePathComparator { public: @@ -229,22 +269,24 @@ class PrefService : public NonThreadSafe, // A helper method to quickly look up a preference. Returns NULL if the // preference is not registered. - const Preference* FindPreference(const wchar_t* pref_name) const; + const Preference* FindPreference(const char* pref_name) const; + /*DEPRECATED*/const Preference* FindPreference( + const wchar_t* pref_name) const; // For the given pref_name, fire any observer of the pref only if |old_value| // is different from the current value. Virtual so it can be mocked for a // unit test. - virtual void FireObserversIfChanged(const wchar_t* pref_name, + virtual void FireObserversIfChanged(const char* pref_name, const Value* old_value); bool read_only() const { return pref_value_store_->ReadOnly(); } protected: // For the given pref_name, fire any observer of the pref. - void FireObservers(const wchar_t* pref_name); + void FireObservers(const char* pref_name); // This should only be accessed by subclasses for unit-testing. - bool PrefIsChanged(const wchar_t* path, const Value* old_value); + bool PrefIsChanged(const char* path, const Value* old_value); private: // Add a preference to the PreferenceMap. If the pref already exists, return @@ -253,7 +295,7 @@ class PrefService : public NonThreadSafe, // Returns a copy of the current pref value. The caller is responsible for // deleting the returned object. - Value* GetPrefCopy(const wchar_t* pref_name); + Value* GetPrefCopy(const char* pref_name); // Load from disk. Returns a non-zero error code on failure. PrefStore::PrefReadError LoadPersistentPrefs(); @@ -292,7 +334,7 @@ class PrefService : public NonThreadSafe, // A map from pref names to a list of observers. Observers get fired in the // order they are added. typedef ObserverList<NotificationObserver> NotificationObserverList; - typedef base::hash_map<std::wstring, NotificationObserverList*> + typedef base::hash_map<std::string, NotificationObserverList*> PrefObserverMap; PrefObserverMap pref_observers_; diff --git a/chrome/browser/pref_service_uitest.cc b/chrome/browser/pref_service_uitest.cc index 2f8f4e0..9712481 100644 --- a/chrome/browser/pref_service_uitest.cc +++ b/chrome/browser/pref_service_uitest.cc @@ -103,23 +103,23 @@ TEST_F(PreferenceServiceTest, PreservedWindowPlacementIsLoaded) { // Retrieve the expected rect values from "Preferences" int bottom = 0; - std::wstring kBrowserWindowPlacement(prefs::kBrowserWindowPlacement); - EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + L".bottom", + std::string kBrowserWindowPlacement(prefs::kBrowserWindowPlacement); + EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + ".bottom", &bottom)); EXPECT_EQ(bottom, bounds.y() + bounds.height()); int top = 0; - EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + L".top", + EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + ".top", &top)); EXPECT_EQ(top, bounds.y()); int left = 0; - EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + L".left", + EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + ".left", &left)); EXPECT_EQ(left, bounds.x()); int right = 0; - EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + L".right", + EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + ".right", &right)); EXPECT_EQ(right, bounds.x() + bounds.width()); @@ -127,7 +127,7 @@ TEST_F(PreferenceServiceTest, PreservedWindowPlacementIsLoaded) { bool is_window_maximized = false; ASSERT_TRUE(window->IsMaximized(&is_window_maximized)); bool is_maximized = false; - EXPECT_TRUE(root_dict->GetBoolean(kBrowserWindowPlacement + L".maximized", + EXPECT_TRUE(root_dict->GetBoolean(kBrowserWindowPlacement + ".maximized", &is_maximized)); EXPECT_EQ(is_maximized, is_window_maximized); } diff --git a/chrome/browser/pref_service_unittest.cc b/chrome/browser/pref_service_unittest.cc index 967c0cb..1f68e41 100644 --- a/chrome/browser/pref_service_unittest.cc +++ b/chrome/browser/pref_service_unittest.cc @@ -26,7 +26,7 @@ using testing::Property; class TestPrefObserver : public NotificationObserver { public: TestPrefObserver(const PrefService* prefs, - const std::wstring& pref_name, + const std::string& pref_name, const std::string& new_pref_value) : observer_fired_(false), prefs_(prefs), @@ -41,9 +41,9 @@ class TestPrefObserver : public NotificationObserver { EXPECT_EQ(type.value, NotificationType::PREF_CHANGED); PrefService* prefs_in = Source<PrefService>(source).ptr(); EXPECT_EQ(prefs_in, prefs_); - std::wstring* pref_name_in = Details<std::wstring>(details).ptr(); + std::string* pref_name_in = Details<std::string>(details).ptr(); EXPECT_EQ(*pref_name_in, pref_name_); - EXPECT_EQ(new_pref_value_, prefs_in->GetString(L"homepage")); + EXPECT_EQ(new_pref_value_, prefs_in->GetString("homepage")); observer_fired_ = true; } @@ -57,7 +57,7 @@ class TestPrefObserver : public NotificationObserver { private: bool observer_fired_; const PrefService* prefs_; - const std::wstring pref_name_; + const std::string pref_name_; std::string new_pref_value_; }; @@ -65,9 +65,9 @@ class TestPrefObserver : public NotificationObserver { #if defined(OS_WIN) TEST(PrefServiceTest, LocalizedPrefs) { TestingPrefService prefs; - const wchar_t kBoolean[] = L"boolean"; - const wchar_t kInteger[] = L"integer"; - const wchar_t kString[] = L"string"; + const char kBoolean[] = "boolean"; + const char kInteger[] = "integer"; + const char kString[] = "string"; prefs.RegisterLocalizedBooleanPref(kBoolean, IDS_LOCALE_BOOL); prefs.RegisterLocalizedIntegerPref(kInteger, IDS_LOCALE_INT); prefs.RegisterLocalizedStringPref(kString, IDS_LOCALE_STRING); @@ -89,7 +89,7 @@ TEST(PrefServiceTest, LocalizedPrefs) { TEST(PrefServiceTest, NoObserverFire) { TestingPrefService prefs; - const wchar_t pref_name[] = L"homepage"; + const char pref_name[] = "homepage"; prefs.RegisterStringPref(pref_name, ""); const std::string new_pref_value("http://www.google.com/"); @@ -124,7 +124,7 @@ TEST(PrefServiceTest, NoObserverFire) { TEST(PrefServiceTest, HasPrefPath) { TestingPrefService prefs; - const wchar_t path[] = L"fake.path"; + const char path[] = "fake.path"; // Shouldn't initially have a path. EXPECT_FALSE(prefs.HasPrefPath(path)); @@ -140,10 +140,10 @@ TEST(PrefServiceTest, HasPrefPath) { } TEST(PrefServiceTest, Observers) { - const wchar_t pref_name[] = L"homepage"; + const char pref_name[] = "homepage"; TestingPrefService prefs; - prefs.SetUserPref(pref_name, Value::CreateStringValue(L"http://www.cnn.com")); + prefs.SetUserPref(pref_name, Value::CreateStringValue("http://www.cnn.com")); prefs.RegisterStringPref(pref_name, ""); const std::string new_pref_value("http://www.google.com/"); @@ -180,7 +180,7 @@ TEST(PrefServiceTest, Observers) { class PrefServiceSetValueTest : public testing::Test { protected: - static const wchar_t name_[]; + static const char name_[]; static const char value_[]; PrefServiceSetValueTest() @@ -194,17 +194,17 @@ class PrefServiceSetValueTest : public testing::Test { void SetExpectPrefChanged() { EXPECT_CALL(observer_, Observe(NotificationType(NotificationType::PREF_CHANGED), _, - Property(&Details<std::wstring>::ptr, + Property(&Details<std::string>::ptr, Pointee(name_string_)))); } TestingPrefService prefs_; - std::wstring name_string_; + std::string name_string_; scoped_ptr<Value> null_value_; NotificationObserverMock observer_; }; -const wchar_t PrefServiceSetValueTest::name_[] = L"name"; +const char PrefServiceSetValueTest::name_[] = "name"; const char PrefServiceSetValueTest::value_[] = "value"; TEST_F(PrefServiceSetValueTest, SetStringValue) { diff --git a/chrome/browser/pref_set_observer.cc b/chrome/browser/pref_set_observer.cc index 1e9f904..fb08a9b 100644 --- a/chrome/browser/pref_set_observer.cc +++ b/chrome/browser/pref_set_observer.cc @@ -18,19 +18,19 @@ PrefSetObserver::~PrefSetObserver() { pref_service_->RemovePrefObserver(i->c_str(), this); } -void PrefSetObserver::AddPref(const std::wstring& pref) { +void PrefSetObserver::AddPref(const std::string& pref) { if (!prefs_.count(pref) && pref_service_->FindPreference(pref.c_str())) { prefs_.insert(pref); pref_service_->AddPrefObserver(pref.c_str(), this); } } -void PrefSetObserver::RemovePref(const std::wstring& pref) { +void PrefSetObserver::RemovePref(const std::string& pref) { if (prefs_.erase(pref)) pref_service_->RemovePrefObserver(pref.c_str(), this); } -bool PrefSetObserver::IsObserved(const std::wstring& pref) { +bool PrefSetObserver::IsObserved(const std::string& pref) { return prefs_.count(pref) > 0; } diff --git a/chrome/browser/pref_set_observer.h b/chrome/browser/pref_set_observer.h index 33813fc..787c078f 100644 --- a/chrome/browser/pref_set_observer.h +++ b/chrome/browser/pref_set_observer.h @@ -22,12 +22,12 @@ class PrefSetObserver : public NotificationObserver { virtual ~PrefSetObserver(); // Add a |pref| to the set of preferences to observe. - void AddPref(const std::wstring& pref); + void AddPref(const std::string& pref); // Remove |pref| from the set of observed peferences. - void RemovePref(const std::wstring& pref); + void RemovePref(const std::string& pref); // Check whether |pref| is in the set of observed preferences. - bool IsObserved(const std::wstring& pref); + bool IsObserved(const std::string& pref); // Check whether any of the observed preferences has the managed bit set. bool IsManaged(); @@ -42,7 +42,7 @@ class PrefSetObserver : public NotificationObserver { const NotificationSource& source, const NotificationDetails& details); - typedef std::set<std::wstring> PrefSet; + typedef std::set<std::string> PrefSet; PrefSet prefs_; PrefService* pref_service_; diff --git a/chrome/browser/pref_set_observer_unittest.cc b/chrome/browser/pref_set_observer_unittest.cc index ddb4d54..4426da2 100644 --- a/chrome/browser/pref_set_observer_unittest.cc +++ b/chrome/browser/pref_set_observer_unittest.cc @@ -53,8 +53,7 @@ TEST_F(PrefSetObserverTest, IsManaged) { } MATCHER_P(PrefNameDetails, name, "details references named preference") { - std::wstring* pstr = - reinterpret_cast<const Details<std::wstring>&>(arg).ptr(); + std::string* pstr = reinterpret_cast<const Details<std::string>&>(arg).ptr(); return pstr && *pstr == name; } diff --git a/chrome/browser/pref_value_store.cc b/chrome/browser/pref_value_store.cc index 70837f0..47b01e0 100644 --- a/chrome/browser/pref_value_store.cc +++ b/chrome/browser/pref_value_store.cc @@ -42,7 +42,7 @@ PrefValueStore* PrefValueStore::CreatePrefValueStore( PrefValueStore::~PrefValueStore() {} -bool PrefValueStore::GetValue(const std::wstring& name, +bool PrefValueStore::GetValue(const std::string& name, Value** out_value) const { // Check the |PrefStore|s in order of their priority from highest to lowest // to find the value of the preference described by the given preference name. @@ -87,9 +87,9 @@ PrefStore::PrefReadError PrefValueStore::ReadPrefs() { return result; } -bool PrefValueStore::HasPrefPath(const wchar_t* path) const { +bool PrefValueStore::HasPrefPath(const char* path) const { Value* tmp_value = NULL; - const std::wstring name(path); + const std::string name(path); bool rv = GetValue(name, &tmp_value); return rv; } @@ -97,7 +97,7 @@ bool PrefValueStore::HasPrefPath(const wchar_t* path) const { // Note the |DictionaryValue| referenced by the |PrefStore| user_prefs_ // (returned by the method prefs()) takes the ownership of the Value referenced // by in_value. -void PrefValueStore::SetUserPrefValue(const wchar_t* name, Value* in_value) { +void PrefValueStore::SetUserPrefValue(const char* name, Value* in_value) { pref_stores_[USER]->prefs()->Set(name, in_value); } @@ -105,38 +105,38 @@ bool PrefValueStore::ReadOnly() { return pref_stores_[USER]->ReadOnly(); } -void PrefValueStore::RemoveUserPrefValue(const wchar_t* name) { +void PrefValueStore::RemoveUserPrefValue(const char* name) { if (pref_stores_[USER].get()) { pref_stores_[USER]->prefs()->Remove(name, NULL); } } -bool PrefValueStore::PrefValueInManagedStore(const wchar_t* name) { +bool PrefValueStore::PrefValueInManagedStore(const char* name) { return PrefValueInStore(name, MANAGED); } -bool PrefValueStore::PrefValueInExtensionStore(const wchar_t* name) { +bool PrefValueStore::PrefValueInExtensionStore(const char* name) { return PrefValueInStore(name, EXTENSION); } -bool PrefValueStore::PrefValueInUserStore(const wchar_t* name) { +bool PrefValueStore::PrefValueInUserStore(const char* name) { return PrefValueInStore(name, USER); } -bool PrefValueStore::PrefValueFromExtensionStore(const wchar_t* name) { +bool PrefValueStore::PrefValueFromExtensionStore(const char* name) { return ControllingPrefStoreForPref(name) == EXTENSION; } -bool PrefValueStore::PrefValueFromUserStore(const wchar_t* name) { +bool PrefValueStore::PrefValueFromUserStore(const char* name) { return ControllingPrefStoreForPref(name) == USER; } -bool PrefValueStore::PrefValueUserModifiable(const wchar_t* name) { +bool PrefValueStore::PrefValueUserModifiable(const char* name) { PrefStoreType effective_store = ControllingPrefStoreForPref(name); return effective_store >= USER || effective_store == INVALID; } -bool PrefValueStore::PrefValueInStore(const wchar_t* name, PrefStoreType type) { +bool PrefValueStore::PrefValueInStore(const char* name, PrefStoreType type) { if (!pref_stores_[type].get()) { // No store of that type set, so this pref can't be in it. return false; @@ -146,7 +146,7 @@ bool PrefValueStore::PrefValueInStore(const wchar_t* name, PrefStoreType type) { } PrefValueStore::PrefStoreType PrefValueStore::ControllingPrefStoreForPref( - const wchar_t* name) { + const char* name) { for (int i = 0; i <= PREF_STORE_TYPE_MAX; ++i) { if (PrefValueInStore(name, static_cast<PrefStoreType>(i))) return static_cast<PrefStoreType>(i); diff --git a/chrome/browser/pref_value_store.h b/chrome/browser/pref_value_store.h index adb51a9..9dfa56e 100644 --- a/chrome/browser/pref_value_store.h +++ b/chrome/browser/pref_value_store.h @@ -55,7 +55,7 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore> { // Get the preference value for the given preference name. // Return true if a value for the given preference name was found. - bool GetValue(const std::wstring& name, Value** out_value) const; + bool GetValue(const std::string& name, Value** out_value) const; // Read preference values into the three PrefStores so that they are available // through the GetValue method. Return the first error that occurs (but @@ -72,7 +72,7 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore> { void ScheduleWritePrefs(); // Returns true if the PrefValueStore contains the given preference. - bool HasPrefPath(const wchar_t* name) const; + bool HasPrefPath(const char* name) const; // Returns true if the PrefValueStore is read-only. // Because the managed and recommended PrefStores are always read-only, the @@ -87,28 +87,28 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore> { // of the preference. Note that the PrefValueStore takes the ownership of // the value referenced by |in_value|. It is an error to call this when no // user PrefStore has been set. - void SetUserPrefValue(const wchar_t* name, Value* in_value); + void SetUserPrefValue(const char* name, Value* in_value); // Removes a value from the PrefValueStore. If a preference is managed // or recommended this function should have no effect. - void RemoveUserPrefValue(const wchar_t* name); + void RemoveUserPrefValue(const char* name); // These methods return true if a preference with the given name is in the // indicated pref store, even if that value is currently being overridden by // a higher-priority source. - bool PrefValueInManagedStore(const wchar_t* name); - bool PrefValueInExtensionStore(const wchar_t* name); - bool PrefValueInUserStore(const wchar_t* name); + bool PrefValueInManagedStore(const char* name); + bool PrefValueInExtensionStore(const char* name); + bool PrefValueInUserStore(const char* name); // These methods return true if a preference with the given name is actually // being controlled by the indicated pref store and not being overridden by // a higher-priority source. - bool PrefValueFromExtensionStore(const wchar_t* name); - bool PrefValueFromUserStore(const wchar_t* name); + bool PrefValueFromExtensionStore(const char* name); + bool PrefValueFromUserStore(const char* name); // Check whether a Preference value is modifiable by the user, i.e. whether // there is no higher-priority source controlling it. - bool PrefValueUserModifiable(const wchar_t* name); + bool PrefValueUserModifiable(const char* name); // Signature of callback triggered after policy refresh. Parameter is not // passed as reference to prevent passing along a pointer to a set whose @@ -166,12 +166,12 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore> { scoped_ptr<PrefStore> pref_stores_[PREF_STORE_TYPE_MAX + 1]; - bool PrefValueInStore(const wchar_t* name, PrefStoreType type); + bool PrefValueInStore(const char* name, PrefStoreType type); // Returns the pref store type identifying the source that controls the // Preference identified by |name|. If none of the sources has a value, // INVALID is returned. - PrefStoreType ControllingPrefStoreForPref(const wchar_t* name); + PrefStoreType ControllingPrefStoreForPref(const char* name); // Called during policy refresh after ReadPrefs completes on the thread // that initiated the policy refresh. RefreshPolicyPrefsCompletion takes diff --git a/chrome/browser/pref_value_store_unittest.cc b/chrome/browser/pref_value_store_unittest.cc index a4af696..42033fb 100644 --- a/chrome/browser/pref_value_store_unittest.cc +++ b/chrome/browser/pref_value_store_unittest.cc @@ -18,18 +18,18 @@ using testing::Mock; // Names of the preferences used in this test program. namespace prefs { - const wchar_t kCurrentThemeID[] = L"extensions.theme.id"; - const wchar_t kDeleteCache[] = L"browser.clear_data.cache"; - const wchar_t kHomepage[] = L"homepage"; - const wchar_t kMaxTabs[] = L"tabs.max_tabs"; - const wchar_t kMissingPref[] = L"this.pref.does_not_exist"; - const wchar_t kRecommendedPref[] = L"this.pref.recommended_value_only"; - const wchar_t kSampleDict[] = L"sample.dict"; - const wchar_t kSampleList[] = L"sample.list"; + const char kCurrentThemeID[] = "extensions.theme.id"; + const char kDeleteCache[] = "browser.clear_data.cache"; + const char kHomepage[] = "homepage"; + const char kMaxTabs[] = "tabs.max_tabs"; + const char kMissingPref[] = "this.pref.does_not_exist"; + const char kRecommendedPref[] = "this.pref.recommended_value_only"; + const char kSampleDict[] = "sample.dict"; + const char kSampleList[] = "sample.list"; // This must match the actual pref name so the command-line store knows about // it. - const wchar_t kApplicationLocale[] = L"intl.app_locale"; + const char kApplicationLocale[] = "intl.app_locale"; } // Potentailly expected values of all preferences used in this test program. @@ -38,24 +38,24 @@ namespace prefs { namespace user_pref { const int kMaxTabsValue = 31; const bool kDeleteCacheValue = true; - const std::wstring kCurrentThemeIDValue = L"abcdefg"; - const std::wstring kHomepageValue = L"http://www.google.com"; - const std::wstring kApplicationLocaleValue = L"is-WRONG"; + const char kCurrentThemeIDValue[] = "abcdefg"; + const char kHomepageValue[] = "http://www.google.com"; + const char kApplicationLocaleValue[] = "is-WRONG"; } namespace enforced_pref { - const std::wstring kHomepageValue = L"http://www.topeka.com"; + const std::string kHomepageValue = "http://www.topeka.com"; } namespace extension_pref { - const std::wstring kCurrentThemeIDValue = L"set by extension"; - const std::wstring kHomepageValue = L"http://www.chromium.org"; + const char kCurrentThemeIDValue[] = "set by extension"; + const char kHomepageValue[] = "http://www.chromium.org"; } namespace command_line_pref { - const std::wstring kApplicationLocaleValue = L"hi-MOM"; - const std::wstring kCurrentThemeIDValue = L"zyxwvut"; - const std::wstring kHomepageValue = L"http://www.ferretcentral.org"; + const char kApplicationLocaleValue[] = "hi-MOM"; + const char kCurrentThemeIDValue[] = "zyxwvut"; + const char kHomepageValue[] = "http://www.ferretcentral.org"; } namespace recommended_pref { @@ -115,7 +115,7 @@ class PrefValueStoreTest : public testing::Test { DictionaryValue* CreateEnforcedPrefs() { DictionaryValue* enforced_prefs = new DictionaryValue(); enforced_prefs->SetString(prefs::kHomepage, enforced_pref::kHomepageValue); - expected_differing_paths_.push_back(WideToUTF8(prefs::kHomepage)); + expected_differing_paths_.push_back(prefs::kHomepage); return enforced_prefs; } @@ -150,10 +150,10 @@ class PrefValueStoreTest : public testing::Test { // Expected differing paths must be added in lexicographic order // to work properly expected_differing_paths_.push_back("tabs"); - expected_differing_paths_.push_back(WideToUTF8(prefs::kMaxTabs)); + expected_differing_paths_.push_back(prefs::kMaxTabs); expected_differing_paths_.push_back("this"); expected_differing_paths_.push_back("this.pref"); - expected_differing_paths_.push_back(WideToUTF8(prefs::kRecommendedPref)); + expected_differing_paths_.push_back(prefs::kRecommendedPref); return recommended_prefs; } DictionaryValue* CreateSampleDictValue() { @@ -225,7 +225,7 @@ TEST_F(PrefValueStoreTest, GetValue) { // extension-defined value. value = NULL; ASSERT_TRUE(pref_value_store_->GetValue(prefs::kHomepage, &value)); - std::wstring actual_str_value; + std::string actual_str_value; EXPECT_TRUE(value->GetAsString(&actual_str_value)); EXPECT_EQ(enforced_pref::kHomepageValue, actual_str_value); @@ -308,7 +308,7 @@ TEST_F(PrefValueStoreTest, SetUserPrefValue) { pref_value_store_->SetUserPrefValue(prefs::kHomepage, new_value); ASSERT_TRUE(pref_value_store_->GetValue(prefs::kHomepage, &actual_value)); - std::wstring value_str; + std::string value_str; actual_value->GetAsString(&value_str); ASSERT_EQ(enforced_pref::kHomepageValue, value_str); @@ -331,7 +331,7 @@ TEST_F(PrefValueStoreTest, SetUserPrefValue) { pref_value_store_->SetUserPrefValue(prefs::kSampleDict, expected_dict_value); actual_value = NULL; - std::wstring key(prefs::kSampleDict); + std::string key(prefs::kSampleDict); pref_value_store_->GetValue(key , &actual_value); ASSERT_EQ(expected_dict_value, actual_value); diff --git a/chrome/browser/profile_impl.cc b/chrome/browser/profile_impl.cc index 63269b2..9cfc4a2 100644 --- a/chrome/browser/profile_impl.cc +++ b/chrome/browser/profile_impl.cc @@ -1121,7 +1121,7 @@ void ProfileImpl::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { if (NotificationType::PREF_CHANGED == type) { - std::wstring* pref_name_in = Details<std::wstring>(details).ptr(); + std::string* pref_name_in = Details<std::string>(details).ptr(); PrefService* prefs = Source<PrefService>(source).ptr(); DCHECK(pref_name_in && prefs); if (*pref_name_in == prefs::kSpellCheckDictionary || diff --git a/chrome/browser/scoped_pref_update.cc b/chrome/browser/scoped_pref_update.cc index 6a18bf6..5e74ee3 100644 --- a/chrome/browser/scoped_pref_update.cc +++ b/chrome/browser/scoped_pref_update.cc @@ -2,13 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/utf_string_conversions.h" // TODO(viettrungluu): remove #include "chrome/browser/pref_service.h" #include "chrome/browser/scoped_pref_update.h" -ScopedPrefUpdate::ScopedPrefUpdate(PrefService* service, const wchar_t* path) +ScopedPrefUpdate::ScopedPrefUpdate(PrefService* service, const char* path) : service_(service), path_(path) {} +// TODO(viettrungluu): deprecate and remove #include +ScopedPrefUpdate::ScopedPrefUpdate(PrefService* service, const wchar_t* path) + : service_(service), + path_(WideToUTF8(path)) {} + ScopedPrefUpdate::~ScopedPrefUpdate() { service_->FireObservers(path_.c_str()); } diff --git a/chrome/browser/scoped_pref_update.h b/chrome/browser/scoped_pref_update.h index 9afa2c8..518219a 100644 --- a/chrome/browser/scoped_pref_update.h +++ b/chrome/browser/scoped_pref_update.h @@ -13,12 +13,14 @@ class ScopedPrefUpdate { public: + ScopedPrefUpdate(PrefService* service, const char* path); + // TODO(viettrungluu): deprecate: ScopedPrefUpdate(PrefService* service, const wchar_t* path); ~ScopedPrefUpdate(); private: PrefService* service_; - std::wstring path_; + std::string path_; }; #endif // CHROME_BROWSER_SCOPED_PREF_UPDATE_H_ diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc index 469fcbd..46c05a9 100644 --- a/chrome/browser/shell_integration_win.cc +++ b/chrome/browser/shell_integration_win.cc @@ -17,6 +17,7 @@ #include "base/scoped_comptr_win.h" #include "base/string_util.h" #include "base/task.h" +#include "base/utf_string_conversions.h" #include "base/win_util.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/web_applications/web_app.h" @@ -224,8 +225,8 @@ bool MigrateChromiumShortcutsTask::GetExpectedAppId( std::wstring app_name; if (command_line.HasSwitch(switches::kApp)) { - app_name = web_app::GenerateApplicationNameFromURL( - GURL(command_line.GetSwitchValueASCII(switches::kApp))); + app_name = UTF8ToWide(web_app::GenerateApplicationNameFromURL( + GURL(command_line.GetSwitchValueASCII(switches::kApp)))); } else { app_name = BrowserDistribution::GetDistribution()->GetBrowserAppId(); } diff --git a/chrome/browser/sync/glue/preference_change_processor.cc b/chrome/browser/sync/glue/preference_change_processor.cc index 2b8a6fe..76338d1 100644 --- a/chrome/browser/sync/glue/preference_change_processor.cc +++ b/chrome/browser/sync/glue/preference_change_processor.cc @@ -43,7 +43,7 @@ void PreferenceChangeProcessor::Observe(NotificationType type, DCHECK(NotificationType::PREF_CHANGED == type); DCHECK_EQ(pref_service_, Source<PrefService>(source).ptr()); - std::wstring* name = Details<std::wstring>(details).ptr(); + std::string* name = Details<std::string>(details).ptr(); const PrefService::Preference* preference = pref_service_->FindPreference((*name).c_str()); DCHECK(preference); @@ -71,8 +71,7 @@ void PreferenceChangeProcessor::Observe(NotificationType type, return; } - std::string tag = WideToUTF8(*name); - if (!node.InitUniqueByCreation(syncable::PREFERENCES, root, tag)) { + if (!node.InitUniqueByCreation(syncable::PREFERENCES, root, *name)) { error_handler()->OnUnrecoverableError( FROM_HERE, "Failed to create preference sync node."); @@ -127,7 +126,7 @@ void PreferenceChangeProcessor::ApplyChangesFromSyncModel( } DCHECK(syncable::PREFERENCES == node.GetModelType()); - std::wstring name; + std::string name; scoped_ptr<Value> value(ReadPreference(&node, &name)); // Skip values we can't deserialize. if (!value.get()) @@ -138,7 +137,7 @@ void PreferenceChangeProcessor::ApplyChangesFromSyncModel( // client and a Windows client, the Windows client does not // support kShowPageOptionsButtons. Ignore updates from these // preferences. - const wchar_t* pref_name = name.c_str(); + const char* pref_name = name.c_str(); if (model_associator_->synced_preferences().count(pref_name) == 0) continue; @@ -171,7 +170,7 @@ void PreferenceChangeProcessor::ApplyChangesFromSyncModel( Value* PreferenceChangeProcessor::ReadPreference( sync_api::ReadNode* node, - std::wstring* name) { + std::string* name) { const sync_pb::PreferenceSpecifics& preference( node->GetPreferenceSpecifics()); base::JSONReader reader; @@ -182,7 +181,7 @@ Value* PreferenceChangeProcessor::ReadPreference( error_handler()->OnUnrecoverableError(FROM_HERE, err); return NULL; } - *name = UTF8ToWide(preference.name()); + *name = preference.name(); return value.release(); } @@ -201,7 +200,7 @@ void PreferenceChangeProcessor::StopImpl() { void PreferenceChangeProcessor::StartObserving() { DCHECK(pref_service_); - for (std::set<std::wstring>::const_iterator it = + for (std::set<std::string>::const_iterator it = model_associator_->synced_preferences().begin(); it != model_associator_->synced_preferences().end(); ++it) { pref_service_->AddPrefObserver((*it).c_str(), this); @@ -210,7 +209,7 @@ void PreferenceChangeProcessor::StartObserving() { void PreferenceChangeProcessor::StopObserving() { DCHECK(pref_service_); - for (std::set<std::wstring>::const_iterator it = + for (std::set<std::string>::const_iterator it = model_associator_->synced_preferences().begin(); it != model_associator_->synced_preferences().end(); ++it) { pref_service_->RemovePrefObserver((*it).c_str(), this); diff --git a/chrome/browser/sync/glue/preference_change_processor.h b/chrome/browser/sync/glue/preference_change_processor.h index df23227..ae02708 100644 --- a/chrome/browser/sync/glue/preference_change_processor.h +++ b/chrome/browser/sync/glue/preference_change_processor.h @@ -47,7 +47,7 @@ class PreferenceChangeProcessor : public ChangeProcessor, virtual void StopImpl(); private: - Value* ReadPreference(sync_api::ReadNode* node, std::wstring* name); + Value* ReadPreference(sync_api::ReadNode* node, std::string* name); void StartObserving(); void StopObserving(); diff --git a/chrome/browser/sync/glue/preference_model_associator.cc b/chrome/browser/sync/glue/preference_model_associator.cc index 5dad397..013696b 100644 --- a/chrome/browser/sync/glue/preference_model_associator.cc +++ b/chrome/browser/sync/glue/preference_model_associator.cc @@ -64,11 +64,11 @@ bool PreferenceModelAssociator::AssociateModels() { } base::JSONReader reader; - for (std::set<std::wstring>::iterator it = synced_preferences_.begin(); + for (std::set<std::string>::iterator it = synced_preferences_.begin(); it != synced_preferences_.end(); ++it) { - std::string tag = WideToUTF8(*it); + const std::string& tag = *it; const PrefService::Preference* pref = - pref_service->FindPreference((*it).c_str()); + pref_service->FindPreference(tag.c_str()); DCHECK(pref); sync_api::WriteNode node(&trans); @@ -81,7 +81,7 @@ bool PreferenceModelAssociator::AssociateModels() { if (pref->IsUserModifiable()) { scoped_ptr<Value> value( reader.JsonToValue(preference.value(), false, false)); - std::wstring pref_name = UTF8ToWide(preference.name()); + std::string pref_name = preference.name(); if (!value.get()) { LOG(ERROR) << "Failed to deserialize preference value: " << reader.GetErrorMessage(); @@ -156,7 +156,7 @@ bool PreferenceModelAssociator::SyncModelHasUserCreatedNodes(bool* has_nodes) { } int64 PreferenceModelAssociator::GetSyncIdFromChromeId( - const std::wstring preference_name) { + const std::string preference_name) { PreferenceNameToSyncIdMap::const_iterator iter = id_map_.find(preference_name); return iter == id_map_.end() ? sync_api::kInvalidId : iter->second; @@ -195,14 +195,15 @@ bool PreferenceModelAssociator::GetSyncIdForTaggedNode(const std::string& tag, Value* PreferenceModelAssociator::MergePreference( const PrefService::Preference& local_pref, const Value& server_value) { - if (local_pref.name() == prefs::kURLsToRestoreOnStartup || - local_pref.name() == prefs::kDesktopNotificationAllowedOrigins || - local_pref.name() == prefs::kDesktopNotificationDeniedOrigins) { + const std::string& name(local_pref.name()); + if (name == prefs::kURLsToRestoreOnStartup || + name == prefs::kDesktopNotificationAllowedOrigins || + name == prefs::kDesktopNotificationDeniedOrigins) { return MergeListValues(*local_pref.GetValue(), server_value); } - if (local_pref.name() == prefs::kContentSettingsPatterns || - local_pref.name() == prefs::kGeolocationContentSettings) { + if (name == prefs::kContentSettingsPatterns || + name == prefs::kGeolocationContentSettings) { return MergeDictionaryValues(*local_pref.GetValue(), server_value); } @@ -211,7 +212,7 @@ Value* PreferenceModelAssociator::MergePreference( } bool PreferenceModelAssociator::WritePreferenceToNode( - const std::wstring& name, + const std::string& name, const Value& value, sync_api::WriteNode* node) { std::string serialized; @@ -222,10 +223,11 @@ bool PreferenceModelAssociator::WritePreferenceToNode( } sync_pb::PreferenceSpecifics preference; - preference.set_name(WideToUTF8(name)); + preference.set_name(name); preference.set_value(serialized); node->SetPreferenceSpecifics(preference); - node->SetTitle(name); + // TODO(viettrungluu): eliminate conversion (it's temporary) + node->SetTitle(UTF8ToWide(name)); return true; } @@ -290,7 +292,7 @@ Value* PreferenceModelAssociator::MergeDictionaryValues( } void PreferenceModelAssociator::AfterUpdateOperations( - const std::wstring& pref_name) { + const std::string& pref_name) { // The bookmark bar visibility preference requires a special // notification to update the UI. if (0 == pref_name.compare(prefs::kShowBookmarkBar)) { diff --git a/chrome/browser/sync/glue/preference_model_associator.h b/chrome/browser/sync/glue/preference_model_associator.h index ca170ac..fd2915c 100644 --- a/chrome/browser/sync/glue/preference_model_associator.h +++ b/chrome/browser/sync/glue/preference_model_associator.h @@ -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. @@ -33,7 +33,7 @@ static const char kPreferencesTag[] = "google_chrome_preferences"; // * Algorithm to associate preferences model and sync model. class PreferenceModelAssociator : public PerDataTypeAssociatorInterface<PrefService::Preference, - std::wstring> { + std::string> { public: static syncable::ModelType model_type() { return syncable::PREFERENCES; } explicit PreferenceModelAssociator(ProfileSyncService* sync_service); @@ -42,7 +42,7 @@ class PreferenceModelAssociator // Returns the list of preference names that should be monitored for // changes. Only preferences that are registered will be in this // list. - const std::set<std::wstring>& synced_preferences() { + const std::set<std::string>& synced_preferences() { return synced_preferences_; } @@ -70,14 +70,14 @@ class PreferenceModelAssociator } // Not implemented. - virtual bool InitSyncNodeFromChromeId(std::wstring node_id, + virtual bool InitSyncNodeFromChromeId(std::string node_id, sync_api::BaseNode* sync_node) { return false; } // Returns the sync id for the given preference name, or sync_api::kInvalidId // if the preference name is not associated to any sync id. - virtual int64 GetSyncIdFromChromeId(std::wstring node_id); + virtual int64 GetSyncIdFromChromeId(std::string node_id); // Associates the given preference name with the given sync id. virtual void Associate(const PrefService::Preference* node, int64 sync_id); @@ -100,28 +100,28 @@ class PreferenceModelAssociator // Writes the value of pref into the specified node. Returns true // upon success. - static bool WritePreferenceToNode(const std::wstring& name, + static bool WritePreferenceToNode(const std::string& name, const Value& value, sync_api::WriteNode* node); // Perform any additional operations that need to happen after a preference // has been updated. - void AfterUpdateOperations(const std::wstring& pref_name); + void AfterUpdateOperations(const std::string& pref_name); protected: // Returns sync service instance. ProfileSyncService* sync_service() { return sync_service_; } private: - typedef std::map<std::wstring, int64> PreferenceNameToSyncIdMap; - typedef std::map<int64, std::wstring> SyncIdToPreferenceNameMap; + typedef std::map<std::string, int64> PreferenceNameToSyncIdMap; + typedef std::map<int64, std::string> SyncIdToPreferenceNameMap; static Value* MergeListValues(const Value& from_value, const Value& to_value); static Value* MergeDictionaryValues(const Value& from_value, const Value& to_value); ProfileSyncService* sync_service_; - std::set<std::wstring> synced_preferences_; + std::set<std::string> synced_preferences_; int64 preferences_node_id_; PreferenceNameToSyncIdMap id_map_; diff --git a/chrome/browser/sync/glue/preference_model_associator_unittest.cc b/chrome/browser/sync/glue/preference_model_associator_unittest.cc index 032f0ea..2939db4 100644 --- a/chrome/browser/sync/glue/preference_model_associator_unittest.cc +++ b/chrome/browser/sync/glue/preference_model_associator_unittest.cc @@ -18,8 +18,8 @@ class AbstractPreferenceMergeTest : public testing::Test { } void SetContentPattern(DictionaryValue* patterns_dict, - const std::wstring& expression, - const std::wstring& content_type, + const std::string& expression, + const std::string& content_type, int setting) { DictionaryValue* expression_dict; bool found = @@ -34,12 +34,12 @@ class AbstractPreferenceMergeTest : public testing::Test { Value::CreateIntegerValue(setting)); } - void SetPrefToNull(const std::wstring& pref_name) { + void SetPrefToNull(const std::string& pref_name) { scoped_ptr<Value> null_value(Value::CreateNullValue()); pref_service_->Set(pref_name.c_str(), *null_value); } - void SetPrefToEmpty(const std::wstring& pref_name) { + void SetPrefToEmpty(const std::string& pref_name) { scoped_ptr<Value> empty_value; const PrefService::Preference* pref = pref_service_->FindPreference(pref_name.c_str()); @@ -198,11 +198,11 @@ TEST_F(ListPreferenceMergeTest, Equals) { class DictionaryPreferenceMergeTest : public AbstractPreferenceMergeTest { protected: DictionaryPreferenceMergeTest() : - expression0_(L"expression0"), - expression1_(L"expression1"), - expression2_(L"expression2"), - content_type0_(L"content_type0"), - content_type1_(L"content_type1") {} + expression0_("expression0"), + expression1_("expression1"), + expression2_("expression2"), + content_type0_("content_type0"), + content_type1_("content_type1") {} virtual void SetUp() { AbstractPreferenceMergeTest::SetUp(); @@ -211,11 +211,11 @@ class DictionaryPreferenceMergeTest : public AbstractPreferenceMergeTest { SetContentPattern(&server_patterns_, expression1_, content_type0_, 1); } - std::wstring expression0_; - std::wstring expression1_; - std::wstring expression2_; - std::wstring content_type0_; - std::wstring content_type1_; + std::string expression0_; + std::string expression1_; + std::string expression2_; + std::string content_type0_; + std::string content_type1_; DictionaryValue server_patterns_; }; @@ -340,11 +340,11 @@ TEST_F(DictionaryPreferenceMergeTest, ConflictButServerWins) { class IndividualPreferenceMergeTest : public AbstractPreferenceMergeTest { protected: IndividualPreferenceMergeTest() : - url0_(L"http://example.com/server0"), - url1_(L"http://example.com/server1"), - expression0_(L"expression0"), - expression1_(L"expression1"), - content_type0_(L"content_type0") {} + url0_("http://example.com/server0"), + url1_("http://example.com/server1"), + expression0_("expression0"), + expression1_("expression1"), + content_type0_("content_type0") {} virtual void SetUp() { AbstractPreferenceMergeTest::SetUp(); @@ -352,7 +352,7 @@ class IndividualPreferenceMergeTest : public AbstractPreferenceMergeTest { SetContentPattern(&server_patterns_, expression0_, content_type0_, 1); } - bool MergeListPreference(const wchar_t* pref) { + bool MergeListPreference(const char* pref) { ListValue* local_list_value = pref_service_->GetMutableList(pref); local_list_value->Append(Value::CreateStringValue(url1_)); @@ -366,7 +366,7 @@ class IndividualPreferenceMergeTest : public AbstractPreferenceMergeTest { return merged_value->Equals(&expected); } - bool MergeDictionaryPreference(const wchar_t* pref) { + bool MergeDictionaryPreference(const char* pref) { DictionaryValue* local_dict_value = pref_service_->GetMutableDictionary(pref); SetContentPattern(local_dict_value, expression1_, content_type0_, 1); @@ -381,11 +381,11 @@ class IndividualPreferenceMergeTest : public AbstractPreferenceMergeTest { return merged_value->Equals(&expected); } - std::wstring url0_; - std::wstring url1_; - std::wstring expression0_; - std::wstring expression1_; - std::wstring content_type0_; + std::string url0_; + std::string url1_; + std::string expression0_; + std::string expression1_; + std::string content_type0_; ListValue server_url_list_; DictionaryValue server_patterns_; }; diff --git a/chrome/browser/sync/glue/synchronized_preferences.h b/chrome/browser/sync/glue/synchronized_preferences.h index 263d471..ac09e1d 100644 --- a/chrome/browser/sync/glue/synchronized_preferences.h +++ b/chrome/browser/sync/glue/synchronized_preferences.h @@ -14,7 +14,7 @@ namespace browser_sync { -static const wchar_t* kSynchronizedPreferences[] = { +static const char* kSynchronizedPreferences[] = { // Options dialog: Basics tab. prefs::kRestoreOnStartup, prefs::kURLsToRestoreOnStartup, diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc index c6fd726..13e0d42 100644 --- a/chrome/browser/sync/profile_sync_service.cc +++ b/chrome/browser/sync/profile_sync_service.cc @@ -389,7 +389,7 @@ void ProfileSyncService::UpdateLastSyncedTime() { } // static -const wchar_t* ProfileSyncService::GetPrefNameForDataType( +const char* ProfileSyncService::GetPrefNameForDataType( syncable::ModelType data_type) { switch (data_type) { case syncable::BOOKMARKS: @@ -664,7 +664,7 @@ void ProfileSyncService::ChangePreferredDataTypes( syncable::ModelType model_type = syncable::ModelTypeFromInt(i); if (!registered_types.count(model_type)) continue; - const wchar_t* pref_name = GetPrefNameForDataType(model_type); + const char* pref_name = GetPrefNameForDataType(model_type); if (!pref_name) continue; profile_->GetPrefs()->SetBoolean(pref_name, @@ -689,7 +689,7 @@ void ProfileSyncService::GetPreferredDataTypes( syncable::ModelType model_type = syncable::ModelTypeFromInt(i); if (!registered_types.count(model_type)) continue; - const wchar_t* pref_name = GetPrefNameForDataType(model_type); + const char* pref_name = GetPrefNameForDataType(model_type); if (!pref_name) continue; if (profile_->GetPrefs()->GetBoolean(pref_name)) @@ -795,7 +795,7 @@ void ProfileSyncService::Observe(NotificationType type, break; } case NotificationType::PREF_CHANGED: { - std::wstring* pref_name = Details<std::wstring>(details).ptr(); + std::string* pref_name = Details<std::string>(details).ptr(); if (*pref_name == prefs::kSyncManaged) { FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); if (*pref_sync_managed_) diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h index d3f8e79..9f89a19 100644 --- a/chrome/browser/sync/profile_sync_service.h +++ b/chrome/browser/sync/profile_sync_service.h @@ -360,7 +360,7 @@ class ProfileSyncService : public browser_sync::SyncFrontend, // Sets the last synced time to the current time. void UpdateLastSyncedTime(); - static const wchar_t* GetPrefNameForDataType(syncable::ModelType data_type); + static const char* GetPrefNameForDataType(syncable::ModelType data_type); // Time at which we begin an attempt a GAIA authorization. base::TimeTicks auth_start_time_; diff --git a/chrome/browser/sync/profile_sync_service_preference_unittest.cc b/chrome/browser/sync/profile_sync_service_preference_unittest.cc index 94ae735..454d56c 100644 --- a/chrome/browser/sync/profile_sync_service_preference_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_preference_unittest.cc @@ -8,6 +8,7 @@ #include "base/json/json_reader.h" #include "base/stl_util-inl.h" #include "base/task.h" +#include "base/utf_string_conversions.h" // TODO(viettrungluu): remove #include "chrome/browser/sync/abstract_profile_sync_service_test.h" #include "chrome/browser/sync/engine/syncapi.h" #include "chrome/browser/sync/glue/preference_change_processor.h" @@ -33,7 +34,7 @@ using sync_api::SyncManager; using testing::_; using testing::Return; -typedef std::map<const std::wstring, const Value*> PreferenceValues; +typedef std::map<const std::string, const Value*> PreferenceValues; class ProfileSyncServicePreferenceTest : public AbstractProfileSyncServiceTest { @@ -42,7 +43,7 @@ class ProfileSyncServicePreferenceTest : example_url0_("http://example.com/0"), example_url1_("http://example.com/1"), example_url2_("http://example.com/2"), - not_synced_preference_name_(L"nonsense_pref_name"), + not_synced_preference_name_("nonsense_pref_name"), not_synced_preference_default_value_("default"), non_default_charset_value_("foo") {} @@ -92,14 +93,14 @@ class ProfileSyncServicePreferenceTest SyncBackendHost* backend() { return service_->backend_.get(); } - const Value& GetPreferenceValue(const std::wstring& name) { + const Value& GetPreferenceValue(const std::string& name) { const PrefService::Preference* preference = prefs_->FindPreference(name.c_str()); return *preference->GetValue(); } // Caller gets ownership of the returned value. - const Value* GetSyncedValue(const std::wstring& name) { + const Value* GetSyncedValue(const std::string& name) { sync_api::ReadTransaction trans(service_->backend()->GetUserShareHandle()); sync_api::ReadNode node(&trans); @@ -116,7 +117,7 @@ class ProfileSyncServicePreferenceTest return reader.JsonToValue(specifics.value(), false, false); } - int64 SetSyncedValue(const std::wstring& name, const Value& value) { + int64 SetSyncedValue(const std::string& name, const Value& value) { sync_api::WriteTransaction trans(backend()->GetUserShareHandle()); sync_api::ReadNode root(&trans); if (!root.InitByTagLookup(browser_sync::kPreferencesTag)) @@ -128,7 +129,7 @@ class ProfileSyncServicePreferenceTest if (node_id == sync_api::kInvalidId) { if (!node.InitUniqueByCreation(syncable::PREFERENCES, root, - WideToUTF8(name))) { + name)) { return sync_api::kInvalidId; } } else { @@ -142,15 +143,16 @@ class ProfileSyncServicePreferenceTest EXPECT_TRUE(json.Serialize(value)); sync_pb::PreferenceSpecifics preference; - preference.set_name(WideToUTF8(name)); + preference.set_name(name); preference.set_value(serialized); node.SetPreferenceSpecifics(preference); - node.SetTitle(name); + // TODO(viettrungluu): remove conversion and header + node.SetTitle(UTF8ToWide(name)); return node.GetId(); } - SyncManager::ChangeRecord* MakeChangeRecord(const std::wstring& name, + SyncManager::ChangeRecord* MakeChangeRecord(const std::string& name, SyncManager::ChangeRecord) { int64 node_id = model_associator_->GetSyncIdFromChromeId(name); SyncManager::ChangeRecord* record = new SyncManager::ChangeRecord(); @@ -159,7 +161,7 @@ class ProfileSyncServicePreferenceTest return record; } - bool IsSynced(const std::wstring& pref_name) { + bool IsSynced(const std::string& pref_name) { return model_associator_->synced_preferences().count(pref_name) > 0; } @@ -180,7 +182,7 @@ class ProfileSyncServicePreferenceTest std::string example_url0_; std::string example_url1_; std::string example_url2_; - std::wstring not_synced_preference_name_; + std::string not_synced_preference_name_; std::string not_synced_preference_default_value_; std::string non_default_charset_value_; }; @@ -222,13 +224,13 @@ TEST_F(ProfileSyncServicePreferenceTest, WritePreferenceToNode) { sync_api::WriteTransaction trans(service_->backend()->GetUserShareHandle()); sync_api::WriteNode node(&trans); EXPECT_TRUE(node.InitByClientTagLookup(syncable::PREFERENCES, - WideToUTF8(prefs::kHomePage))); + prefs::kHomePage)); EXPECT_TRUE(PreferenceModelAssociator::WritePreferenceToNode( pref->name(), *pref->GetValue(), &node)); - EXPECT_EQ(std::wstring(prefs::kHomePage), node.GetTitle()); + EXPECT_EQ(UTF8ToWide(prefs::kHomePage), node.GetTitle()); const sync_pb::PreferenceSpecifics& specifics(node.GetPreferenceSpecifics()); - EXPECT_EQ(WideToUTF8(prefs::kHomePage), specifics.name()); + EXPECT_EQ(std::string(prefs::kHomePage), specifics.name()); base::JSONReader reader; scoped_ptr<Value> value(reader.JsonToValue(specifics.value(), false, false)); @@ -398,7 +400,7 @@ TEST_F(ProfileSyncServicePreferenceTest, UpdatedSyncNodeUnknownPreference) { ASSERT_TRUE(task.success()); scoped_ptr<Value> expected(Value::CreateStringValue(example_url0_)); - int64 node_id = SetSyncedValue(L"unknown preference", *expected); + int64 node_id = SetSyncedValue("unknown preference", *expected); ASSERT_NE(node_id, sync_api::kInvalidId); scoped_ptr<SyncManager::ChangeRecord> record(new SyncManager::ChangeRecord); record->action = SyncManager::ChangeRecord::ACTION_ADD; @@ -415,7 +417,7 @@ TEST_F(ProfileSyncServicePreferenceTest, UpdatedSyncNodeUnknownPreference) { TEST_F(ProfileSyncServicePreferenceTest, ManagedPreferences) { // Make the homepage preference managed. scoped_ptr<Value> managed_value( - Value::CreateStringValue(L"http://example.com")); + Value::CreateStringValue("http://example.com")); prefs_->SetManagedPref(prefs::kHomePage, managed_value->DeepCopy()); CreateRootTask task(this, syncable::PREFERENCES); @@ -424,13 +426,13 @@ TEST_F(ProfileSyncServicePreferenceTest, ManagedPreferences) { // Changing the homepage preference should not sync anything. scoped_ptr<Value> user_value( - Value::CreateStringValue(L"http://chromium..com")); + Value::CreateStringValue("http://chromium..com")); prefs_->SetUserPref(prefs::kHomePage, user_value->DeepCopy()); EXPECT_EQ(NULL, GetSyncedValue(prefs::kHomePage)); // An incoming sync transaction shouldn't change the user value. scoped_ptr<Value> sync_value( - Value::CreateStringValue(L"http://crbug.com")); + Value::CreateStringValue("http://crbug.com")); int64 node_id = SetSyncedValue(prefs::kHomePage, *sync_value); ASSERT_NE(node_id, sync_api::kInvalidId); scoped_ptr<SyncManager::ChangeRecord> record(new SyncManager::ChangeRecord); @@ -440,6 +442,8 @@ TEST_F(ProfileSyncServicePreferenceTest, ManagedPreferences) { sync_api::WriteTransaction trans(backend()->GetUserShareHandle()); change_processor_->ApplyChangesFromSyncModel(&trans, record.get(), 1); } - EXPECT_TRUE(managed_value->Equals(prefs_->GetManagedPref(prefs::kHomePage))); - EXPECT_TRUE(user_value->Equals(prefs_->GetUserPref(prefs::kHomePage))); + EXPECT_TRUE(managed_value->Equals( + prefs_->GetManagedPref(prefs::kHomePage))); + EXPECT_TRUE(user_value->Equals( + prefs_->GetUserPref(prefs::kHomePage))); } diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 3e43c8f..42da773 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -162,7 +162,7 @@ const float kMaxHeightFactor = 0.6; const int kJavascriptMessageExpectedDelay = 1000; // The list of prefs we want to observe. -const wchar_t* kPrefsToObserve[] = { +const char* kPrefsToObserve[] = { prefs::kAlternateErrorPagesEnabled, prefs::kWebKitJavaEnabled, prefs::kWebKitJavascriptEnabled, @@ -3072,12 +3072,12 @@ void TabContents::Observe(NotificationType type, break; } case NotificationType::PREF_CHANGED: { - std::wstring* pref_name_in = Details<std::wstring>(details).ptr(); + std::string* pref_name_in = Details<std::string>(details).ptr(); DCHECK(Source<PrefService>(source).ptr() == profile()->GetPrefs()); if (*pref_name_in == prefs::kAlternateErrorPagesEnabled) { UpdateAlternateErrorPageURL(); } else if (*pref_name_in == prefs::kDefaultCharset || - StartsWithASCII(WideToUTF8(*pref_name_in), "webkit.webprefs.", true) + StartsWithASCII(*pref_name_in, "webkit.webprefs.", true) ) { UpdateWebPreferences(); } else { diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc index b34a81d..52a4873 100644 --- a/chrome/browser/tab_contents/web_contents_unittest.cc +++ b/chrome/browser/tab_contents/web_contents_unittest.cc @@ -208,8 +208,8 @@ class TabContentsTest : public RenderViewHostTestHarness { Value::CreateBooleanValue(true)); pref_services->SetUserPref(prefs::kWebKitStandardFontIsSerif, Value::CreateBooleanValue(true)); - pref_services->SetUserPref(L"webkit.webprefs.foo", - Value::CreateStringValue(L"bar")); + pref_services->SetUserPref("webkit.webprefs.foo", + Value::CreateStringValue("bar")); RenderViewHostTestHarness::SetUp(); } diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc index 7ce63f6..13810e6 100644 --- a/chrome/browser/translate/translate_manager.cc +++ b/chrome/browser/translate/translate_manager.cc @@ -242,7 +242,7 @@ void TranslateManager::Observe(NotificationType type, break; } case NotificationType::PREF_CHANGED: { - DCHECK(*Details<std::wstring>(details).ptr() == prefs::kAcceptLanguages); + DCHECK(*Details<std::string>(details).ptr() == prefs::kAcceptLanguages); PrefService* prefs = Source<PrefService>(source).ptr(); InitAcceptLanguages(prefs); break; diff --git a/chrome/browser/translate/translate_manager_unittest.cc b/chrome/browser/translate/translate_manager_unittest.cc index 227d837..e34307f 100644 --- a/chrome/browser/translate/translate_manager_unittest.cc +++ b/chrome/browser/translate/translate_manager_unittest.cc @@ -185,12 +185,12 @@ class TranslateManagerTest : public RenderViewHostTestHarness, std::string()); } - void SetPrefObserverExpectation(const wchar_t* path) { + void SetPrefObserverExpectation(const char* path) { EXPECT_CALL( pref_observer_, Observe(NotificationType(NotificationType::PREF_CHANGED), _, - Property(&Details<std::wstring>::ptr, Pointee(path)))); + Property(&Details<std::string>::ptr, Pointee(path)))); } NotificationObserverMock pref_observer_; diff --git a/chrome/browser/translate/translate_prefs.cc b/chrome/browser/translate/translate_prefs.cc index 3d72df0..5ca8879 100644 --- a/chrome/browser/translate/translate_prefs.cc +++ b/chrome/browser/translate/translate_prefs.cc @@ -9,16 +9,16 @@ #include "chrome/browser/pref_service.h" #include "chrome/browser/scoped_pref_update.h" -const wchar_t TranslatePrefs::kPrefTranslateLanguageBlacklist[] = - L"translate_language_blacklist"; -const wchar_t TranslatePrefs::kPrefTranslateSiteBlacklist[] = - L"translate_site_blacklist"; -const wchar_t TranslatePrefs::kPrefTranslateWhitelists[] = - L"translate_whitelists"; -const wchar_t TranslatePrefs::kPrefTranslateDeniedCount[] = - L"translate_denied_count"; -const wchar_t TranslatePrefs::kPrefTranslateAcceptedCount[] = - L"translate_accepted_count"; +const char TranslatePrefs::kPrefTranslateLanguageBlacklist[] = + "translate_language_blacklist"; +const char TranslatePrefs::kPrefTranslateSiteBlacklist[] = + "translate_site_blacklist"; +const char TranslatePrefs::kPrefTranslateWhitelists[] = + "translate_whitelists"; +const char TranslatePrefs::kPrefTranslateDeniedCount[] = + "translate_denied_count"; +const char TranslatePrefs::kPrefTranslateAcceptedCount[] = + "translate_accepted_count"; // TranslatePrefs: public: ----------------------------------------------------- @@ -226,13 +226,13 @@ bool TranslatePrefs::IsValueInList(const ListValue* list, return false; } -bool TranslatePrefs::IsValueBlacklisted(const wchar_t* pref_id, +bool TranslatePrefs::IsValueBlacklisted(const char* pref_id, const std::string& value) { const ListValue* blacklist = prefs_->GetList(pref_id); return (blacklist && !blacklist->empty() && IsValueInList(blacklist, value)); } -void TranslatePrefs::BlacklistValue(const wchar_t* pref_id, +void TranslatePrefs::BlacklistValue(const char* pref_id, const std::string& value) { ListValue* blacklist = prefs_->GetMutableList(pref_id); if (!blacklist) { @@ -243,7 +243,7 @@ void TranslatePrefs::BlacklistValue(const wchar_t* pref_id, prefs_->ScheduleSavePersistentPrefs(); } -void TranslatePrefs::RemoveValueFromBlacklist(const wchar_t* pref_id, +void TranslatePrefs::RemoveValueFromBlacklist(const char* pref_id, const std::string& value) { ListValue* blacklist = prefs_->GetMutableList(pref_id); if (!blacklist) { diff --git a/chrome/browser/translate/translate_prefs.h b/chrome/browser/translate/translate_prefs.h index a07d70d..a173fab 100644 --- a/chrome/browser/translate/translate_prefs.h +++ b/chrome/browser/translate/translate_prefs.h @@ -17,11 +17,11 @@ class PrefService; class TranslatePrefs { public: - static const wchar_t kPrefTranslateLanguageBlacklist[]; - static const wchar_t kPrefTranslateSiteBlacklist[]; - static const wchar_t kPrefTranslateWhitelists[]; - static const wchar_t kPrefTranslateDeniedCount[]; - static const wchar_t kPrefTranslateAcceptedCount[]; + static const char kPrefTranslateLanguageBlacklist[]; + static const char kPrefTranslateSiteBlacklist[]; + static const char kPrefTranslateWhitelists[]; + static const char kPrefTranslateDeniedCount[]; + static const char kPrefTranslateAcceptedCount[]; explicit TranslatePrefs(PrefService* user_prefs); @@ -62,10 +62,9 @@ class TranslatePrefs { private: static void MigrateTranslateWhitelists(PrefService* user_prefs); - bool IsValueBlacklisted(const wchar_t* pref_id, const std::string& value); - void BlacklistValue(const wchar_t* pref_id, const std::string& value); - void RemoveValueFromBlacklist(const wchar_t* pref_id, - const std::string& value); + bool IsValueBlacklisted(const char* pref_id, const std::string& value); + void BlacklistValue(const char* pref_id, const std::string& value); + void RemoveValueFromBlacklist(const char* pref_id, const std::string& value); bool IsValueInList(const ListValue* list, const std::string& value); bool IsLanguageWhitelisted(const std::string& original_language, std::string* target_language); diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index d8ab622..3034a38 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -1321,7 +1321,7 @@ void BrowserView::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { if (type == NotificationType::PREF_CHANGED && - *Details<std::wstring>(details).ptr() == prefs::kShowBookmarkBar) { + *Details<std::string>(details).ptr() == prefs::kShowBookmarkBar) { if (MaybeShowBookmarkBar(browser_->GetSelectedTabContents())) Layout(); } else { @@ -1503,7 +1503,7 @@ bool BrowserView::ExecuteWindowsCommand(int command_id) { } std::wstring BrowserView::GetWindowName() const { - return browser_->GetWindowPlacementKey(); + return UTF8ToWide(browser_->GetWindowPlacementKey()); } void BrowserView::SaveWindowPlacement(const gfx::Rect& bounds, diff --git a/chrome/browser/views/keyword_editor_view.cc b/chrome/browser/views/keyword_editor_view.cc index e40a704..ad9c6c3 100644 --- a/chrome/browser/views/keyword_editor_view.cc +++ b/chrome/browser/views/keyword_editor_view.cc @@ -9,6 +9,7 @@ #include "app/l10n_util.h" #include "base/stl_util-inl.h" #include "base/string_util.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/pref_service.h" #include "chrome/browser/profile.h" #include "chrome/browser/search_engines/template_url.h" @@ -129,7 +130,7 @@ std::wstring KeywordEditorView::GetWindowTitle() const { } std::wstring KeywordEditorView::GetWindowName() const { - return prefs::kKeywordEditorWindowPlacement; + return UTF8ToWide(prefs::kKeywordEditorWindowPlacement); } int KeywordEditorView::GetDialogButtons() const { diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc index 3dc31e5..f6869db 100644 --- a/chrome/browser/views/options/advanced_contents_view.cc +++ b/chrome/browser/views/options/advanced_contents_view.cc @@ -437,7 +437,7 @@ class PrivacySection : public AdvancedSection, protected: // OptionsPageView overrides: virtual void InitControlLayout(); - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); private: // Controls for this section: @@ -644,7 +644,7 @@ void PrivacySection::InitControlLayout() { #endif } -void PrivacySection::NotifyPrefChanged(const std::wstring* pref_name) { +void PrivacySection::NotifyPrefChanged(const std::string* pref_name) { if (!pref_name || *pref_name == prefs::kAlternateErrorPagesEnabled) { enable_link_doctor_checkbox_->SetChecked( alternate_error_pages_.GetValue()); @@ -787,7 +787,7 @@ class SecuritySection : public AdvancedSection, protected: // OptionsPageView overrides: virtual void InitControlLayout(); - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); private: // Controls for this section: @@ -883,7 +883,7 @@ void SecuritySection::InitControlLayout() { } // This method is called with a null pref_name when the dialog is initialized. -void SecuritySection::NotifyPrefChanged(const std::wstring* pref_name) { +void SecuritySection::NotifyPrefChanged(const std::string* pref_name) { // These SSL options are system settings and stored in the OS. if (!pref_name) { net::SSLConfig config; @@ -947,7 +947,7 @@ class NetworkSection : public AdvancedSection, protected: // OptionsPageView overrides: virtual void InitControlLayout(); - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); private: // Controls for this section: @@ -1008,7 +1008,7 @@ void NetworkSection::InitControlLayout() { NotifyPrefChanged(NULL); } -void NetworkSection::NotifyPrefChanged(const std::wstring* pref_name) { +void NetworkSection::NotifyPrefChanged(const std::string* pref_name) { if (!pref_name || proxy_prefs_->IsObserved(*pref_name)) { change_proxies_button_->SetEnabled(!proxy_prefs_->IsManaged()); } @@ -1040,7 +1040,7 @@ class DownloadSection : public AdvancedSection, protected: // OptionsPageView overrides. virtual void InitControlLayout(); - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); private: // Controls for this section. @@ -1189,7 +1189,7 @@ void DownloadSection::InitControlLayout() { this); } -void DownloadSection::NotifyPrefChanged(const std::wstring* pref_name) { +void DownloadSection::NotifyPrefChanged(const std::string* pref_name) { if (!pref_name || *pref_name == prefs::kDownloadDefaultDirectory) UpdateDownloadDirectoryDisplay(); @@ -1226,7 +1226,7 @@ class TranslateSection : public AdvancedSection, protected: // OptionsPageView overrides: virtual void InitControlLayout(); - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); private: // Control for this section: @@ -1272,7 +1272,7 @@ void TranslateSection::InitControlLayout() { enable_translate_.Init(prefs::kEnableTranslate, profile()->GetPrefs(), this); } -void TranslateSection::NotifyPrefChanged(const std::wstring* pref_name) { +void TranslateSection::NotifyPrefChanged(const std::string* pref_name) { if (!pref_name || *pref_name == prefs::kEnableTranslate) enable_translate_checkbox_->SetChecked(enable_translate_.GetValue()); } diff --git a/chrome/browser/views/options/content_page_view.cc b/chrome/browser/views/options/content_page_view.cc index 0b14992..6775232 100644 --- a/chrome/browser/views/options/content_page_view.cc +++ b/chrome/browser/views/options/content_page_view.cc @@ -228,7 +228,7 @@ void ContentPageView::InitControlLayout() { show_passwords_button_->SetEnabled(enablePasswordManagerElements); } -void ContentPageView::NotifyPrefChanged(const std::wstring* pref_name) { +void ContentPageView::NotifyPrefChanged(const std::string* pref_name) { if (!pref_name || *pref_name == prefs::kPasswordManagerEnabled) { if (ask_to_save_passwords_.GetValue()) { passwords_asktosave_radio_->SetChecked(true); diff --git a/chrome/browser/views/options/content_page_view.h b/chrome/browser/views/options/content_page_view.h index 5dfe969..06f0a3f 100644 --- a/chrome/browser/views/options/content_page_view.h +++ b/chrome/browser/views/options/content_page_view.h @@ -52,7 +52,7 @@ class ContentPageView : public OptionsPageView, protected: // OptionsPageView implementation: virtual void InitControlLayout(); - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); // views::View overrides: virtual void Layout(); diff --git a/chrome/browser/views/options/cookie_filter_page_view.cc b/chrome/browser/views/options/cookie_filter_page_view.cc index 7aaa7c8..320445c 100644 --- a/chrome/browser/views/options/cookie_filter_page_view.cc +++ b/chrome/browser/views/options/cookie_filter_page_view.cc @@ -83,7 +83,7 @@ void CookieFilterPageView::InitControlLayout() { /////////////////////////////////////////////////////////////////////////////// // CookieFilterPageView, OptionsPageView implementation: -void CookieFilterPageView::NotifyPrefChanged(const std::wstring* pref_name) { +void CookieFilterPageView::NotifyPrefChanged(const std::string* pref_name) { if (!pref_name || *pref_name == prefs::kClearSiteDataOnExit) { clear_on_close_check_->SetChecked( clear_site_data_on_exit_.GetValue()); diff --git a/chrome/browser/views/options/cookie_filter_page_view.h b/chrome/browser/views/options/cookie_filter_page_view.h index 61c138a..688b8d3 100644 --- a/chrome/browser/views/options/cookie_filter_page_view.h +++ b/chrome/browser/views/options/cookie_filter_page_view.h @@ -28,7 +28,7 @@ class CookieFilterPageView : public ContentFilterPageView, virtual void InitControlLayout(); // OptionsPageView implementation: - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); // views::ButtonListener implementation: virtual void ButtonPressed(views::Button* sender, const views::Event& event); diff --git a/chrome/browser/views/options/fonts_page_view.cc b/chrome/browser/views/options/fonts_page_view.cc index 4b995cf..7ad53e3 100644 --- a/chrome/browser/views/options/fonts_page_view.cc +++ b/chrome/browser/views/options/fonts_page_view.cc @@ -294,7 +294,7 @@ void FontsPageView::InitControlLayout() { layout->AddView(encoding_contents_); } -void FontsPageView::NotifyPrefChanged(const std::wstring* pref_name) { +void FontsPageView::NotifyPrefChanged(const std::string* pref_name) { if (!pref_name || *pref_name == prefs::kWebKitFixedFontFamily) { fixed_width_font_size_pixel_ = fixed_width_size_.GetValue(); fixed_width_font_display_view_->SetFontType( diff --git a/chrome/browser/views/options/fonts_page_view.h b/chrome/browser/views/options/fonts_page_view.h index c9813b7..283ec7b 100644 --- a/chrome/browser/views/options/fonts_page_view.h +++ b/chrome/browser/views/options/fonts_page_view.h @@ -55,7 +55,7 @@ class FontsPageView : public OptionsPageView, protected: // OptionsPageView implementation: virtual void InitControlLayout(); - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); private: enum FontTypeBeingChanged { diff --git a/chrome/browser/views/options/general_page_view.cc b/chrome/browser/views/options/general_page_view.cc index afe4ae7..1c43f0e 100644 --- a/chrome/browser/views/options/general_page_view.cc +++ b/chrome/browser/views/options/general_page_view.cc @@ -348,7 +348,7 @@ void GeneralPageView::InitControlLayout() { show_home_button_.Init(prefs::kShowHomeButton, profile()->GetPrefs(), this); } -void GeneralPageView::NotifyPrefChanged(const std::wstring* pref_name) { +void GeneralPageView::NotifyPrefChanged(const std::string* pref_name) { if (!pref_name || *pref_name == prefs::kRestoreOnStartup) { PrefService* prefs = profile()->GetPrefs(); const SessionStartupPref startup_pref = diff --git a/chrome/browser/views/options/general_page_view.h b/chrome/browser/views/options/general_page_view.h index 2b05c70a..1c6216d 100644 --- a/chrome/browser/views/options/general_page_view.h +++ b/chrome/browser/views/options/general_page_view.h @@ -60,7 +60,7 @@ class GeneralPageView : public OptionsPageView, // OptionsPageView implementation: virtual void InitControlLayout(); - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); virtual void HighlightGroup(OptionsGroup highlight_group); private: diff --git a/chrome/browser/views/options/languages_page_view.cc b/chrome/browser/views/options/languages_page_view.cc index 0a2bc589..8a2df06 100644 --- a/chrome/browser/views/options/languages_page_view.cc +++ b/chrome/browser/views/options/languages_page_view.cc @@ -14,7 +14,7 @@ #include "base/command_line.h" #include "base/file_util.h" #include "base/string_util.h" -#include "base/string_util.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/language_combobox_model.h" #include "chrome/browser/language_order_table_model.h" @@ -398,14 +398,14 @@ void LanguagesPageView::InitControlLayout() { profile()->GetPrefs(), this); } -void LanguagesPageView::NotifyPrefChanged(const std::wstring* pref_name) { +void LanguagesPageView::NotifyPrefChanged(const std::string* pref_name) { if (!pref_name || *pref_name == prefs::kAcceptLanguages) { language_order_table_model_->SetAcceptLanguagesString( accept_languages_.GetValue()); } if (!pref_name || *pref_name == prefs::kApplicationLocale) { int index = ui_language_model_->GetSelectedLanguageIndex( - prefs::kApplicationLocale); + UTF8ToWide(prefs::kApplicationLocale)); if (-1 == index) { // The pref value for locale isn't valid. Use the current app locale // (which is what we're currently using). @@ -418,7 +418,7 @@ void LanguagesPageView::NotifyPrefChanged(const std::wstring* pref_name) { } if (!pref_name || *pref_name == prefs::kSpellCheckDictionary) { int index = dictionary_language_model_->GetSelectedLanguageIndex( - prefs::kSpellCheckDictionary); + UTF8ToWide(prefs::kSpellCheckDictionary)); // If the index for the current language cannot be found, it is due to // the fact that the pref-member value for the last dictionary language @@ -435,7 +435,7 @@ void LanguagesPageView::NotifyPrefChanged(const std::wstring* pref_name) { dictionary_language_.SetValue( SpellCheckCommon::GetLanguageFromLanguageRegion(lang_region)); index = dictionary_language_model_->GetSelectedLanguageIndex( - prefs::kSpellCheckDictionary); + UTF8ToWide(prefs::kSpellCheckDictionary)); } change_dictionary_language_combobox_->SetSelectedItem(index); diff --git a/chrome/browser/views/options/languages_page_view.h b/chrome/browser/views/options/languages_page_view.h index d4ab082..e5ab3e6 100644 --- a/chrome/browser/views/options/languages_page_view.h +++ b/chrome/browser/views/options/languages_page_view.h @@ -52,7 +52,7 @@ class LanguagesPageView : public OptionsPageView, protected: // OptionsPageView implementation: virtual void InitControlLayout(); - virtual void NotifyPrefChanged(const std::wstring* pref_name); + virtual void NotifyPrefChanged(const std::string* pref_name); // views::Combobox::Listener implementation: virtual void ItemChanged(views::Combobox* sender, diff --git a/chrome/browser/views/page_info_window_view.cc b/chrome/browser/views/page_info_window_view.cc index ea573d8..b962acf 100644 --- a/chrome/browser/views/page_info_window_view.cc +++ b/chrome/browser/views/page_info_window_view.cc @@ -240,7 +240,7 @@ std::wstring PageInfoWindowView::GetWindowTitle() const { } std::wstring PageInfoWindowView::GetWindowName() const { - return prefs::kPageInfoWindowPlacement; + return UTF8ToWide(prefs::kPageInfoWindowPlacement); } views::View* PageInfoWindowView::GetContentsView() { diff --git a/chrome/browser/views/task_manager_view.cc b/chrome/browser/views/task_manager_view.cc index 4739be6..b83c42b 100644 --- a/chrome/browser/views/task_manager_view.cc +++ b/chrome/browser/views/task_manager_view.cc @@ -553,7 +553,7 @@ std::wstring TaskManagerView::GetWindowTitle() const { } std::wstring TaskManagerView::GetWindowName() const { - return prefs::kTaskManagerWindowPlacement; + return UTF8ToWide(prefs::kTaskManagerWindowPlacement); } int TaskManagerView::GetDialogButtons() const { diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc index bfd9e3b..929ea6e 100644 --- a/chrome/browser/views/toolbar_view.cc +++ b/chrome/browser/views/toolbar_view.cc @@ -333,7 +333,7 @@ void ToolbarView::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { if (type == NotificationType::PREF_CHANGED) { - std::wstring* pref_name = Details<std::wstring>(details).ptr(); + std::string* pref_name = Details<std::string>(details).ptr(); if (*pref_name == prefs::kShowHomeButton) { Layout(); SchedulePaint(); diff --git a/chrome/browser/web_applications/web_app.cc b/chrome/browser/web_applications/web_app.cc index dea6f74..c79527c 100644 --- a/chrome/browser/web_applications/web_app.cc +++ b/chrome/browser/web_applications/web_app.cc @@ -373,7 +373,7 @@ bool CreateShortcutTask::CreateShortcut() { // Generates app id from web app url and profile path. std::wstring app_id = ShellIntegration::GetAppId( - web_app::GenerateApplicationNameFromURL(shortcut_info_.url), + UTF8ToWide(web_app::GenerateApplicationNameFromURL(shortcut_info_.url)), profile_path_); FilePath shortcut_to_pin; @@ -630,7 +630,7 @@ void UpdateShortcutWorker::UpdateShortcutsOnFileThread() { if (!shortcut_files_.empty()) { // Generates app id from web app url and profile path. std::wstring app_id = ShellIntegration::GetAppId( - web_app::GenerateApplicationNameFromURL(shortcut_info_.url), + UTF8ToWide(web_app::GenerateApplicationNameFromURL(shortcut_info_.url)), profile_path_); // Sanitize description @@ -681,12 +681,12 @@ DISABLE_RUNNABLE_METHOD_REFCOUNT(UpdateShortcutWorker); namespace web_app { -std::wstring GenerateApplicationNameFromURL(const GURL& url) { +std::string GenerateApplicationNameFromURL(const GURL& url) { std::string t; t.append(url.host()); t.append("_"); t.append(url.path()); - return UTF8ToWide(t); + return t; } void CreateShortcut( diff --git a/chrome/browser/web_applications/web_app.h b/chrome/browser/web_applications/web_app.h index ddacac8..c451e85 100644 --- a/chrome/browser/web_applications/web_app.h +++ b/chrome/browser/web_applications/web_app.h @@ -22,7 +22,7 @@ namespace web_app { // Compute a deterministic name based on the URL. We use this pseudo name // as a key to store window location per application URLs in Browser and // as app id for BrowserWindow, shortcut and jump list. -std::wstring GenerateApplicationNameFromURL(const GURL& url); +std::string GenerateApplicationNameFromURL(const GURL& url); // Callback after user dismisses CreateShortcutView. "true" indicates // shortcut is created successfully. Otherwise, it is false. diff --git a/chrome/browser/window_sizer.cc b/chrome/browser/window_sizer.cc index 74e1af4..724d721 100644 --- a/chrome/browser/window_sizer.cc +++ b/chrome/browser/window_sizer.cc @@ -16,7 +16,7 @@ // and persistent state from the browser window and the user's profile. class DefaultStateProvider : public WindowSizer::StateProvider { public: - explicit DefaultStateProvider(const std::wstring& app_name, Browser* browser) + explicit DefaultStateProvider(const std::string& app_name, Browser* browser) : app_name_(app_name), browser_(browser) { } @@ -27,9 +27,9 @@ class DefaultStateProvider : public WindowSizer::StateProvider { gfx::Rect* work_area) const { DCHECK(bounds && maximized); - std::wstring key(prefs::kBrowserWindowPlacement); + std::string key(prefs::kBrowserWindowPlacement); if (!app_name_.empty()) { - key.append(L"_"); + key.append("_"); key.append(app_name_); } @@ -41,11 +41,11 @@ class DefaultStateProvider : public WindowSizer::StateProvider { int top = 0, left = 0, bottom = 0, right = 0; bool has_prefs = wp_pref && - wp_pref->GetInteger(L"top", &top) && - wp_pref->GetInteger(L"left", &left) && - wp_pref->GetInteger(L"bottom", &bottom) && - wp_pref->GetInteger(L"right", &right) && - wp_pref->GetBoolean(L"maximized", maximized); + wp_pref->GetInteger("top", &top) && + wp_pref->GetInteger("left", &left) && + wp_pref->GetInteger("bottom", &bottom) && + wp_pref->GetInteger("right", &right) && + wp_pref->GetBoolean("maximized", maximized); bounds->SetRect(left, top, std::max(0, right - left), std::max(0, bottom - top)); @@ -54,10 +54,10 @@ class DefaultStateProvider : public WindowSizer::StateProvider { int work_area_bottom = 0; int work_area_right = 0; if (wp_pref) { - wp_pref->GetInteger(L"work_area_top", &work_area_top); - wp_pref->GetInteger(L"work_area_left", &work_area_left); - wp_pref->GetInteger(L"work_area_bottom", &work_area_bottom); - wp_pref->GetInteger(L"work_area_right", &work_area_right); + wp_pref->GetInteger("work_area_top", &work_area_top); + wp_pref->GetInteger("work_area_left", &work_area_left); + wp_pref->GetInteger("work_area_bottom", &work_area_bottom); + wp_pref->GetInteger("work_area_right", &work_area_right); } work_area->SetRect(work_area_left, work_area_top, std::max(0, work_area_right - work_area_left), @@ -99,7 +99,7 @@ class DefaultStateProvider : public WindowSizer::StateProvider { } private: - std::wstring app_name_; + std::string app_name_; // If set, is used as the reference browser for GetLastActiveWindowState. Browser* browser_; @@ -123,7 +123,7 @@ WindowSizer::~WindowSizer() { } // static -void WindowSizer::GetBrowserWindowBounds(const std::wstring& app_name, +void WindowSizer::GetBrowserWindowBounds(const std::string& app_name, const gfx::Rect& specified_bounds, Browser* browser, gfx::Rect* window_bounds, @@ -136,7 +136,7 @@ void WindowSizer::GetBrowserWindowBounds(const std::wstring& app_name, /////////////////////////////////////////////////////////////////////////////// // WindowSizer, private: -WindowSizer::WindowSizer(const std::wstring& app_name) { +WindowSizer::WindowSizer(const std::string& app_name) { Init(new DefaultStateProvider(app_name, NULL), CreateDefaultMonitorInfoProvider()); } diff --git a/chrome/browser/window_sizer.h b/chrome/browser/window_sizer.h index d1928c6..16958e2 100644 --- a/chrome/browser/window_sizer.h +++ b/chrome/browser/window_sizer.h @@ -118,7 +118,7 @@ class WindowSizer { // |window_bounds| is calculated by calling GetLastActiveWindowState(). To // explicitly specify a particular window to base the bounds on, pass in a // non-NULL value for |browser|. - static void GetBrowserWindowBounds(const std::wstring& app_name, + static void GetBrowserWindowBounds(const std::string& app_name, const gfx::Rect& specified_bounds, Browser* browser, gfx::Rect* window_bounds, @@ -135,7 +135,7 @@ class WindowSizer { // The edge of the screen to check for out-of-bounds. enum Edge { TOP, LEFT, BOTTOM, RIGHT }; - explicit WindowSizer(const std::wstring& app_name); + explicit WindowSizer(const std::string& app_name); void Init(StateProvider* state_provider, MonitorInfoProvider* monitor_info_provider); |