diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-29 20:35:19 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-29 20:35:19 +0000 |
commit | ddd231eaa03153f6d04894cceb0b4480755e1277 (patch) | |
tree | faafed02945c1f8934e6e393ac0c6b094c303cdf /chrome/browser/cocoa | |
parent | c5e30d8572ffae1e0d4fbb2fff765f9a8cbace77 (diff) | |
download | chromium_src-ddd231eaa03153f6d04894cceb0b4480755e1277.zip chromium_src-ddd231eaa03153f6d04894cceb0b4480755e1277.tar.gz chromium_src-ddd231eaa03153f6d04894cceb0b4480755e1277.tar.bz2 |
Change a bunch of string types.
Started out just trying to change PrefService::GetString and ::SetString. This snowballed a little bit. Had to change a bunch of url strings in search_engines/ from wstring to string (some of them may be better off as GURLs, but UTF-8 is a step in the right direction, since that's what GURL uses internally, as well as externally via its setters/getters).
TODO (later patch): things that ask for accepted languages should use std::string, not std::wstring.
BUG=none
TEST=try bots
Review URL: http://codereview.chromium.org/2854015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51157 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
9 files changed, 33 insertions, 32 deletions
diff --git a/chrome/browser/cocoa/edit_search_engine_cocoa_controller.mm b/chrome/browser/cocoa/edit_search_engine_cocoa_controller.mm index d3e2131..7bd5219 100644 --- a/chrome/browser/cocoa/edit_search_engine_cocoa_controller.mm +++ b/chrome/browser/cocoa/edit_search_engine_cocoa_controller.mm @@ -120,7 +120,7 @@ void ShiftOriginY(NSView* view, CGFloat amount) { DCHECK([self validateFields]); std::wstring title = base::SysNSStringToWide([nameField_ stringValue]); std::wstring keyword = base::SysNSStringToWide([keywordField_ stringValue]); - std::wstring url = base::SysNSStringToWide([urlField_ stringValue]); + std::string url = base::SysNSStringToUTF8([urlField_ stringValue]); controller_->AcceptAddOrEdit(title, keyword, url); [self doClose]; } @@ -169,7 +169,7 @@ void ShiftOriginY(NSView* view, CGFloat amount) { forImageView:keywordImage_ textField:keywordField_]; - std::wstring url = base::SysNSStringToWide([urlField_ stringValue]); + std::string url = base::SysNSStringToUTF8([urlField_ stringValue]); BOOL urlValid = controller_->IsURLValid(url); [self setIsValid:urlValid toolTip:IDS_SEARCH_ENGINES_INVALID_URL_TT diff --git a/chrome/browser/cocoa/edit_search_engine_cocoa_controller_unittest.mm b/chrome/browser/cocoa/edit_search_engine_cocoa_controller_unittest.mm index f03578d..e38c022 100644 --- a/chrome/browser/cocoa/edit_search_engine_cocoa_controller_unittest.mm +++ b/chrome/browser/cocoa/edit_search_engine_cocoa_controller_unittest.mm @@ -206,7 +206,7 @@ TEST_F(EditSearchEngineControllerTest, EditTemplateURL) { TemplateURL url; url.set_short_name(L"Foobar"); url.set_keyword(L"keyword"); - std::wstring urlString = TemplateURLRef::DisplayURLToURLRef( + std::string urlString = TemplateURLRef::DisplayURLToURLRef( L"http://foo-bar.com"); url.SetURL(urlString, 0, 1); TestingProfile* profile = browser_helper_.profile(); diff --git a/chrome/browser/cocoa/font_language_settings_controller.mm b/chrome/browser/cocoa/font_language_settings_controller.mm index 4aa0f11..1958e00 100644 --- a/chrome/browser/cocoa/font_language_settings_controller.mm +++ b/chrome/browser/cocoa/font_language_settings_controller.mm @@ -42,7 +42,7 @@ void ShowFontsLanguagesWindow(gfx::NativeWindow window, // Convert the name/size preference values to NSFont objects. serifName_.Init(prefs::kWebKitSerifFontFamily, profile->GetPrefs(), NULL); serifSize_.Init(prefs::kWebKitDefaultFontSize, profile->GetPrefs(), NULL); - NSString* serif = base::SysWideToNSString(serifName_.GetValue()); + NSString* serif = base::SysUTF8ToNSString(serifName_.GetValue()); serifFont_.reset( [[NSFont fontWithName:serif size:serifSize_.GetValue()] retain]); @@ -50,7 +50,7 @@ void ShowFontsLanguagesWindow(gfx::NativeWindow window, NULL); sansSerifSize_.Init(prefs::kWebKitDefaultFontSize, profile->GetPrefs(), NULL); - NSString* sansSerif = base::SysWideToNSString(sansSerifName_.GetValue()); + NSString* sansSerif = base::SysUTF8ToNSString(sansSerifName_.GetValue()); sansSerifFont_.reset( [[NSFont fontWithName:sansSerif size:sansSerifSize_.GetValue()] retain]); @@ -59,7 +59,7 @@ void ShowFontsLanguagesWindow(gfx::NativeWindow window, NULL); fixedWidthSize_.Init(prefs::kWebKitDefaultFixedFontSize, profile->GetPrefs(), NULL); - NSString* fixedWidth = base::SysWideToNSString(fixedWidthName_.GetValue()); + NSString* fixedWidth = base::SysUTF8ToNSString(fixedWidthName_.GetValue()); fixedWidthFont_.reset( [[NSFont fontWithName:fixedWidth size:fixedWidthSize_.GetValue()] retain]); @@ -93,7 +93,7 @@ void ShowFontsLanguagesWindow(gfx::NativeWindow window, // Find and set the default encoding. defaultEncoding_.Init(prefs::kDefaultCharset, profile->GetPrefs(), NULL); NSString* defaultEncoding = - base::SysWideToNSString(defaultEncoding_.GetValue()); + base::SysUTF8ToNSString(defaultEncoding_.GetValue()); NSUInteger index = 0; for (NSDictionary* entry in encodings_.get()) { NSString* encoding = [entry objectForKey:kCharacterInfoEncoding]; @@ -201,23 +201,23 @@ void ShowFontsLanguagesWindow(gfx::NativeWindow window, - (IBAction)save:(id)sender { if (changedSerif_) { - serifName_.SetValue(base::SysNSStringToWide([serifFont_ fontName])); + serifName_.SetValue(base::SysNSStringToUTF8([serifFont_ fontName])); serifSize_.SetValue([serifFont_ pointSize]); } if (changedSansSerif_) { sansSerifName_.SetValue( - base::SysNSStringToWide([sansSerifFont_ fontName])); + base::SysNSStringToUTF8([sansSerifFont_ fontName])); sansSerifSize_.SetValue([sansSerifFont_ pointSize]); } if (changedFixedWidth_) { fixedWidthName_.SetValue( - base::SysNSStringToWide([fixedWidthFont_ fontName])); + base::SysNSStringToUTF8([fixedWidthFont_ fontName])); fixedWidthSize_.SetValue([fixedWidthFont_ pointSize]); } if (changedEncoding_) { NSDictionary* object = [encodings_ objectAtIndex:defaultEncodingIndex_]; NSString* newEncoding = [object objectForKey:kCharacterInfoEncoding]; - std::wstring encoding = base::SysNSStringToWide(newEncoding); + std::string encoding = base::SysNSStringToUTF8(newEncoding); defaultEncoding_.SetValue(encoding); } [self closeSheet:sender]; diff --git a/chrome/browser/cocoa/keyword_editor_cocoa_controller.h b/chrome/browser/cocoa/keyword_editor_cocoa_controller.h index d4c0390..647b200 100644 --- a/chrome/browser/cocoa/keyword_editor_cocoa_controller.h +++ b/chrome/browser/cocoa/keyword_editor_cocoa_controller.h @@ -37,7 +37,7 @@ class KeywordEditorModelObserver : public TemplateURLModelObserver, virtual void OnEditedKeyword(const TemplateURL* template_url, const std::wstring& title, const std::wstring& keyword, - const std::wstring& url); + const std::string& url); // TableModelObserver overrides. Invalidate icon cache. virtual void OnModelChanged(); diff --git a/chrome/browser/cocoa/keyword_editor_cocoa_controller.mm b/chrome/browser/cocoa/keyword_editor_cocoa_controller.mm index 559c840..21c7a20 100644 --- a/chrome/browser/cocoa/keyword_editor_cocoa_controller.mm +++ b/chrome/browser/cocoa/keyword_editor_cocoa_controller.mm @@ -52,7 +52,7 @@ void KeywordEditorModelObserver::OnEditedKeyword( const TemplateURL* template_url, const std::wstring& title, const std::wstring& keyword, - const std::wstring& url) { + const std::string& url) { KeywordEditorController* controller = [controller_ controller]; if (template_url) { controller->ModifyTemplateURL(template_url, title, keyword, url); diff --git a/chrome/browser/cocoa/keyword_editor_cocoa_controller_unittest.mm b/chrome/browser/cocoa/keyword_editor_cocoa_controller_unittest.mm index ccdaf09..2ea9648 100644 --- a/chrome/browser/cocoa/keyword_editor_cocoa_controller_unittest.mm +++ b/chrome/browser/cocoa/keyword_editor_cocoa_controller_unittest.mm @@ -148,7 +148,7 @@ TEST_F(KeywordEditorCocoaControllerTest, IndexInModelForRowMixed) { // Add a default engine. TemplateURL* t_url = new TemplateURL(); - t_url->SetURL(L"http://test1/{searchTerms}", 0, 0); + t_url->SetURL("http://test1/{searchTerms}", 0, 0); t_url->set_keyword(L"test1"); t_url->set_short_name(L"Test1"); t_url->set_show_in_default_list(true); @@ -156,7 +156,7 @@ TEST_F(KeywordEditorCocoaControllerTest, IndexInModelForRowMixed) { // Add a non-default engine. t_url = new TemplateURL(); - t_url->SetURL(L"http://test2/{searchTerms}", 0, 0); + t_url->SetURL("http://test2/{searchTerms}", 0, 0); t_url->set_keyword(L"test2"); t_url->set_short_name(L"Test2"); t_url->set_show_in_default_list(false); @@ -191,14 +191,14 @@ TEST_F(KeywordEditorCocoaControllerTest, IndexInModelForDefault) { // Add 2 default engines. TemplateURL* t_url = new TemplateURL(); - t_url->SetURL(L"http://test1/{searchTerms}", 0, 0); + t_url->SetURL("http://test1/{searchTerms}", 0, 0); t_url->set_keyword(L"test1"); t_url->set_short_name(L"Test1"); t_url->set_show_in_default_list(true); template_model->Add(t_url); t_url = new TemplateURL(); - t_url->SetURL(L"http://test2/{searchTerms}", 0, 0); + t_url->SetURL("http://test2/{searchTerms}", 0, 0); t_url->set_keyword(L"test2"); t_url->set_short_name(L"Test2"); t_url->set_show_in_default_list(true); diff --git a/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm index 2858984..22c3447d 100644 --- a/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm +++ b/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm @@ -893,9 +893,10 @@ void LocationBarViewMac::ContentSettingImageView::OnMousePressed(NSRect bounds) return; GURL url = tabContents->GetURL(); std::wstring displayHost; - net::AppendFormattedHost(url, - profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), &displayHost, - NULL, NULL); + net::AppendFormattedHost( + url, + UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)), + &displayHost, NULL, NULL); // Transform mouse coordinates to screen space. AutocompleteTextField* textField = owner_->GetAutocompleteTextField(); diff --git a/chrome/browser/cocoa/preferences_window_controller.mm b/chrome/browser/cocoa/preferences_window_controller.mm index a86031e..3bc8ef6 100644 --- a/chrome/browser/cocoa/preferences_window_controller.mm +++ b/chrome/browser/cocoa/preferences_window_controller.mm @@ -912,9 +912,9 @@ class ManagedPrefsBannerState : public ManagedPrefsBannerBase { if (!homepage.is_valid() || homepage.spec() == GetNewTabUIURLString()) { newTabPageIsHomePage_.SetValue(true); if (!homepage.has_host()) - homepage_.SetValue(std::wstring()); + homepage_.SetValue(std::string()); } else { - homepage_.SetValue(UTF8ToWide(homepage.spec())); + homepage_.SetValue(homepage.spec()); } } } @@ -951,7 +951,7 @@ class ManagedPrefsBannerState : public ManagedPrefsBannerBase { [self setNewTabPageIsHomePageIndex:useNewTabPage]; } if (*prefName == prefs::kHomePage) { - NSString* value = base::SysWideToNSString(homepage_.GetValue()); + NSString* value = base::SysUTF8ToNSString(homepage_.GetValue()); [self setHomepageURL:value]; } @@ -1114,7 +1114,7 @@ enum { kHomepageNewTabPage, kHomepageURL }; // Returns the homepage URL. - (NSString*)homepageURL { - NSString* value = base::SysWideToNSString(homepage_.GetValue()); + NSString* value = base::SysUTF8ToNSString(homepage_.GetValue()); return value; } @@ -1429,7 +1429,7 @@ const int kDisabledIndex = 1; [self recordUserAction:UserMetricsAction("Options_SetDownloadDirectory")]; NSURL* path = [[panel URLs] lastObject]; // We only allow 1 item. [self willChangeValueForKey:@"defaultDownloadLocation"]; - defaultDownloadLocation_.SetValue(base::SysNSStringToWide([path path])); + defaultDownloadLocation_.SetValue(base::SysNSStringToUTF8([path path])); [self didChangeValueForKey:@"defaultDownloadLocation"]; } } @@ -1440,7 +1440,7 @@ const int kDisabledIndex = 1; [panel setAllowsMultipleSelection:NO]; [panel setCanChooseFiles:NO]; [panel setCanChooseDirectories:YES]; - NSString* path = base::SysWideToNSString(defaultDownloadLocation_.GetValue()); + NSString* path = base::SysUTF8ToNSString(defaultDownloadLocation_.GetValue()); [panel beginSheetForDirectory:path file:nil types:nil @@ -1647,7 +1647,7 @@ const int kDisabledIndex = 1; - (NSURL*)defaultDownloadLocation { NSString* pathString = - base::SysWideToNSString(defaultDownloadLocation_.GetValue()); + base::SysUTF8ToNSString(defaultDownloadLocation_.GetValue()); return [NSURL fileURLWithPath:pathString]; } diff --git a/chrome/browser/cocoa/search_engine_list_model_unittest.mm b/chrome/browser/cocoa/search_engine_list_model_unittest.mm index 60ed101..c6a45cf 100644 --- a/chrome/browser/cocoa/search_engine_list_model_unittest.mm +++ b/chrome/browser/cocoa/search_engine_list_model_unittest.mm @@ -30,13 +30,13 @@ class SearchEngineListModelTest : public PlatformTest { // Build a fake set of template urls. template_model_.reset(new TemplateURLModel(helper_.profile())); TemplateURL* t_url = new TemplateURL(); - t_url->SetURL(L"http://www.google.com/?q={searchTerms}", 0, 0); + t_url->SetURL("http://www.google.com/?q={searchTerms}", 0, 0); t_url->set_keyword(L"keyword"); t_url->set_short_name(L"google"); t_url->set_show_in_default_list(true); template_model_->Add(t_url); t_url = new TemplateURL(); - t_url->SetURL(L"http://www.google2.com/?q={searchTerms}", 0, 0); + t_url->SetURL("http://www.google2.com/?q={searchTerms}", 0, 0); t_url->set_keyword(L"keyword2"); t_url->set_short_name(L"google2"); t_url->set_show_in_default_list(true); @@ -81,13 +81,13 @@ TEST_F(SearchEngineListModelTest, Default) { // Add two more URLs, neither of which are shown in the default list. TemplateURL* t_url = new TemplateURL(); - t_url->SetURL(L"http://www.google3.com/?q={searchTerms}", 0, 0); + t_url->SetURL("http://www.google3.com/?q={searchTerms}", 0, 0); t_url->set_keyword(L"keyword3"); t_url->set_short_name(L"google3 not eligible"); t_url->set_show_in_default_list(false); template_model_->Add(t_url); t_url = new TemplateURL(); - t_url->SetURL(L"http://www.google4.com/?q={searchTerms}", 0, 0); + t_url->SetURL("http://www.google4.com/?q={searchTerms}", 0, 0); t_url->set_keyword(L"keyword4"); t_url->set_short_name(L"google4"); t_url->set_show_in_default_list(false); @@ -110,7 +110,7 @@ TEST_F(SearchEngineListModelTest, Default) { TEST_F(SearchEngineListModelTest, Notification) { // Add one more item to force a notification. TemplateURL* t_url = new TemplateURL(); - t_url->SetURL(L"http://www.google3.com/foo/bar", 0, 0); + t_url->SetURL("http://www.google3.com/foo/bar", 0, 0); t_url->set_keyword(L"keyword3"); t_url->set_short_name(L"google3"); t_url->set_show_in_default_list(true); |