diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-02 05:29:53 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-02 05:29:53 +0000 |
commit | 8790210c68de5ab29e54a46f761a7a8d60430334 (patch) | |
tree | 159098319252d715c174230adbeb88338a6f67e4 /chrome | |
parent | 05fd507a71a552edc3290adc35c45dfdc13d251a (diff) | |
download | chromium_src-8790210c68de5ab29e54a46f761a7a8d60430334.zip chromium_src-8790210c68de5ab29e54a46f761a7a8d60430334.tar.gz chromium_src-8790210c68de5ab29e54a46f761a7a8d60430334.tar.bz2 |
Move EmptyString, kWhitespace and the BOM to base.
This moves EmptyString*, kWhitespace*, and the UTF 8 Byte Order Marker to the base:: namespace.
Many of them just got changed to a default-constructed string when a reference was not required.
I qualified some string16s with base:: when I was changing adjacent code. I need to do another pass to finish these up.
BUG=
TBR=sky@chromium.org
Review URL: https://codereview.chromium.org/89243003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238032 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
22 files changed, 41 insertions, 38 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_input.cc b/chrome/browser/autocomplete/autocomplete_input.cc index 110fbea..2de3f96 100644 --- a/chrome/browser/autocomplete/autocomplete_input.cc +++ b/chrome/browser/autocomplete/autocomplete_input.cc @@ -121,12 +121,12 @@ std::string AutocompleteInput::TypeToString(Type type) { // static AutocompleteInput::Type AutocompleteInput::Parse( - const string16& text, - const string16& desired_tld, + const base::string16& text, + const base::string16& desired_tld, url_parse::Parsed* parts, - string16* scheme, + base::string16* scheme, GURL* canonicalized_url) { - const size_t first_non_white = text.find_first_not_of(kWhitespaceUTF16, 0); + size_t first_non_white = text.find_first_not_of(base::kWhitespaceUTF16, 0); if (first_non_white == string16::npos) return INVALID; // All whitespace. diff --git a/chrome/browser/autocomplete/keyword_provider.cc b/chrome/browser/autocomplete/keyword_provider.cc index ed89397..76251ce 100644 --- a/chrome/browser/autocomplete/keyword_provider.cc +++ b/chrome/browser/autocomplete/keyword_provider.cc @@ -105,7 +105,7 @@ string16 KeywordProvider::SplitKeywordFromInput( string16* remaining_input) { // Find end of first token. The AutocompleteController has trimmed leading // whitespace, so we need not skip over that. - const size_t first_white(input.find_first_of(kWhitespaceUTF16)); + const size_t first_white(input.find_first_of(base::kWhitespaceUTF16)); DCHECK_NE(0U, first_white); if (first_white == string16::npos) return input; // Only one token provided. @@ -113,7 +113,8 @@ string16 KeywordProvider::SplitKeywordFromInput( // Set |remaining_input| to everything after the first token. DCHECK(remaining_input != NULL); const size_t remaining_start = trim_leading_whitespace ? - input.find_first_not_of(kWhitespaceUTF16, first_white) : first_white + 1; + input.find_first_not_of(base::kWhitespaceUTF16, first_white) : + first_white + 1; if (remaining_start < input.length()) remaining_input->assign(input.begin() + remaining_start, input.end()); diff --git a/chrome/browser/background/background_contents_service.cc b/chrome/browser/background/background_contents_service.cc index c305b92..8fe6d771 100644 --- a/chrome/browser/background/background_contents_service.cc +++ b/chrome/browser/background/background_contents_service.cc @@ -748,7 +748,7 @@ const string16& BackgroundContentsService::GetParentApplicationId( if (contents == it->second.contents) return it->first; } - return EmptyString16(); + return base::EmptyString16(); } void BackgroundContentsService::AddWebContents( diff --git a/chrome/browser/chromeos/imageburner/burn_manager.cc b/chrome/browser/chromeos/imageburner/burn_manager.cc index 9dee244..de6f7f6 100644 --- a/chrome/browser/chromeos/imageburner/burn_manager.cc +++ b/chrome/browser/chromeos/imageburner/burn_manager.cc @@ -120,12 +120,12 @@ const std::string& ConfigFile::GetProperty( if (property != block_it->properties.end()) { return property->second; } else { - return EmptyString(); + return base::EmptyString(); } } } - return EmptyString(); + return base::EmptyString(); } // Check if last block has a hwid associated with it, and erase it if it diff --git a/chrome/browser/chromeos/settings/device_settings_test_helper.h b/chrome/browser/chromeos/settings/device_settings_test_helper.h index 661317b..9111672 100644 --- a/chrome/browser/chromeos/settings/device_settings_test_helper.h +++ b/chrome/browser/chromeos/settings/device_settings_test_helper.h @@ -69,7 +69,7 @@ class DeviceSettingsTestHelper : public SessionManagerClient { const std::map<std::string, PolicyState>::const_iterator entry = device_local_account_policy_.find(id); return entry == device_local_account_policy_.end() ? - EmptyString() : entry->second.policy_blob_; + base::EmptyString() : entry->second.policy_blob_; } void set_device_local_account_policy_blob(const std::string& id, diff --git a/chrome/browser/drive/drive_api_util.cc b/chrome/browser/drive/drive_api_util.cc index 732ab63..845e5d2 100644 --- a/chrome/browser/drive/drive_api_util.cc +++ b/chrome/browser/drive/drive_api_util.cc @@ -162,12 +162,12 @@ std::string TranslateQuery(const std::string& original_query) { // In order to handle non-ascii white spaces correctly, convert to UTF16. base::string16 query = UTF8ToUTF16(original_query); const base::string16 kDelimiter( - kWhitespaceUTF16 + base::string16(1, static_cast<char16>('"'))); + base::kWhitespaceUTF16 + base::string16(1, static_cast<char16>('"'))); std::string result; - for (size_t index = query.find_first_not_of(kWhitespaceUTF16); + for (size_t index = query.find_first_not_of(base::kWhitespaceUTF16); index != base::string16::npos; - index = query.find_first_not_of(kWhitespaceUTF16, index)) { + index = query.find_first_not_of(base::kWhitespaceUTF16, index)) { bool is_exclusion = (query[index] == '-'); if (is_exclusion) ++index; diff --git a/chrome/browser/extensions/user_script_master.cc b/chrome/browser/extensions/user_script_master.cc index 80b6bf7..3f5692a 100644 --- a/chrome/browser/extensions/user_script_master.cc +++ b/chrome/browser/extensions/user_script_master.cc @@ -221,9 +221,9 @@ static bool LoadScriptContent(UserScript::File* script_file, } // Remove BOM from the content. - std::string::size_type index = content.find(kUtf8ByteOrderMark); + std::string::size_type index = content.find(base::kUtf8ByteOrderMark); if (index == 0) { - script_file->set_content(content.substr(strlen(kUtf8ByteOrderMark))); + script_file->set_content(content.substr(strlen(base::kUtf8ByteOrderMark))); } else { script_file->set_content(content); } diff --git a/chrome/browser/history/url_index_private_data.cc b/chrome/browser/history/url_index_private_data.cc index bbb8aae..b7d9c37 100644 --- a/chrome/browser/history/url_index_private_data.cc +++ b/chrome/browser/history/url_index_private_data.cc @@ -234,7 +234,8 @@ ScoredHistoryMatches URLIndexPrivateData::HistoryItemsForTerms( // escaped whitespace. When the user types "colspec=ID%20Mstone Release" we // get two 'terms': "colspec=id%20mstone" and "release". history::String16Vector lower_raw_terms; - if (Tokenize(lower_raw_string, kWhitespaceUTF16, &lower_raw_terms) == 0) { + if (Tokenize(lower_raw_string, base::kWhitespaceUTF16, + &lower_raw_terms) == 0) { // Don't score matches when there are no terms to score against. (It's // possible that the word break iterater that extracts words to search // for in the database allows some whitespace "words" whereas Tokenize diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc index aa694dc..18183c4 100644 --- a/chrome/browser/metrics/metrics_log.cc +++ b/chrome/browser/metrics/metrics_log.cc @@ -860,9 +860,9 @@ void MetricsLog::RecordProfilerData( void MetricsLog::RecordOmniboxOpenedURL(const OmniboxLog& log) { DCHECK(!locked()); - std::vector<string16> terms; + std::vector<base::string16> terms; const int num_terms = - static_cast<int>(Tokenize(log.text, kWhitespaceUTF16, &terms)); + static_cast<int>(Tokenize(log.text, base::kWhitespaceUTF16, &terms)); OmniboxEventProto* omnibox_event = uma_proto()->add_omnibox_event(); omnibox_event->set_time(MetricsLogBase::GetCurrentTime()); diff --git a/chrome/browser/policy/cloud/component_cloud_policy_store.cc b/chrome/browser/policy/cloud/component_cloud_policy_store.cc index 93bccd0..2ddc89b 100644 --- a/chrome/browser/policy/cloud/component_cloud_policy_store.cc +++ b/chrome/browser/policy/cloud/component_cloud_policy_store.cc @@ -104,7 +104,7 @@ const std::string& ComponentCloudPolicyStore::GetCachedHash( DCHECK(CalledOnValidThread()); std::map<PolicyNamespace, std::string>::const_iterator it = cached_hashes_.find(ns); - return it == cached_hashes_.end() ? EmptyString() : it->second; + return it == cached_hashes_.end() ? base::EmptyString() : it->second; } void ComponentCloudPolicyStore::SetCredentials(const std::string& username, diff --git a/chrome/browser/policy/cloud/mock_device_management_service.cc b/chrome/browser/policy/cloud/mock_device_management_service.cc index c80b28b..d01a562 100644 --- a/chrome/browser/policy/cloud/mock_device_management_service.cc +++ b/chrome/browser/policy/cloud/mock_device_management_service.cc @@ -50,7 +50,7 @@ class MockRequestJobBase : public DeviceManagementRequestJob { return entry->second; } - return EmptyString(); + return base::EmptyString(); } MockDeviceManagementService* service_; diff --git a/chrome/browser/signin/token_service.cc b/chrome/browser/signin/token_service.cc index 83c2e3b..0121743 100644 --- a/chrome/browser/signin/token_service.cc +++ b/chrome/browser/signin/token_service.cc @@ -110,7 +110,7 @@ bool TokenService::HasTokenForService(const char* service) const { const std::string& TokenService::GetTokenForService( const char* const service) const { - return EmptyString(); + return base::EmptyString(); } bool TokenService::HasOAuthLoginToken() const { diff --git a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc index 824ddf7..a3344a3 100644 --- a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc +++ b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc @@ -209,7 +209,8 @@ void MultiUserWindowManagerChromeOS::SetWindowOwner( const std::string& MultiUserWindowManagerChromeOS::GetWindowOwner( aura::Window* window) { WindowToEntryMap::iterator it = window_to_entry_.find(window); - return it != window_to_entry_.end() ? it->second->owner() : EmptyString(); + return it != window_to_entry_.end() ? it->second->owner() + : base::EmptyString(); } void MultiUserWindowManagerChromeOS::ShowWindowForUser( @@ -264,7 +265,7 @@ const std::string& MultiUserWindowManagerChromeOS::GetUserPresentingWindow( // If the window is not owned by anyone it is shown on all desktops and we // return the empty string. if (it == window_to_entry_.end()) - return EmptyString(); + return base::EmptyString(); // Otherwise we ask the object for its desktop. return it->second->show_for_user(); } diff --git a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_stub.cc b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_stub.cc index 1243681..cf31ef7 100644 --- a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_stub.cc +++ b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_stub.cc @@ -16,7 +16,7 @@ void MultiUserWindowManagerStub::SetWindowOwner(aura::Window* window, const std::string& MultiUserWindowManagerStub::GetWindowOwner( aura::Window* window) { - return EmptyString(); + return base::EmptyString(); } void MultiUserWindowManagerStub::ShowWindowForUser(aura::Window* window, @@ -36,7 +36,7 @@ bool MultiUserWindowManagerStub::IsWindowOnDesktopOfUser( const std::string& MultiUserWindowManagerStub::GetUserPresentingWindow( aura::Window* window) { - return EmptyString(); + return base::EmptyString(); } void MultiUserWindowManagerStub::AddUser(Profile* profile) { diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm index fa0df42..4a5a333 100644 --- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm +++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm @@ -273,8 +273,8 @@ void OmniboxViewMac::SetForcedQuery() { // We need to do this first, else |SetSelectedRange()| won't work. FocusLocation(true); - const string16 current_text(GetText()); - const size_t start = current_text.find_first_not_of(kWhitespaceUTF16); + const base::string16 current_text(GetText()); + const size_t start = current_text.find_first_not_of(base::kWhitespaceUTF16); if (start == string16::npos || (current_text[start] != '?')) { SetUserText(ASCIIToUTF16("?")); } else { diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc index 834db6b..d08b3a5 100644 --- a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc +++ b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc @@ -500,8 +500,8 @@ void OmniboxViewGtk::SetWindowTextAndCaretPos(const string16& text, } void OmniboxViewGtk::SetForcedQuery() { - const string16 current_text(GetText()); - const size_t start = current_text.find_first_not_of(kWhitespaceUTF16); + const base::string16 current_text(GetText()); + const size_t start = current_text.find_first_not_of(base::kWhitespaceUTF16); if (start == string16::npos || (current_text[start] != '?')) { SetUserText(ASCIIToUTF16("?")); } else { diff --git a/chrome/browser/ui/omnibox/location_bar_util.cc b/chrome/browser/ui/omnibox/location_bar_util.cc index 71220d3..8bfffbd 100644 --- a/chrome/browser/ui/omnibox/location_bar_util.cc +++ b/chrome/browser/ui/omnibox/location_bar_util.cc @@ -19,7 +19,7 @@ namespace location_bar_util { string16 CalculateMinString(const string16& description) { // Chop at the first '.' or whitespace. const size_t dot_index = description.find('.'); - const size_t ws_index = description.find_first_of(kWhitespaceUTF16); + const size_t ws_index = description.find_first_of(base::kWhitespaceUTF16); size_t chop_index = std::min(dot_index, ws_index); string16 min_string; if (chop_index == string16::npos) { diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc index d2539f8..296ff85 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc @@ -494,8 +494,8 @@ void OmniboxViewViews::SetWindowTextAndCaretPos(const string16& text, } void OmniboxViewViews::SetForcedQuery() { - const string16 current_text(text()); - const size_t start = current_text.find_first_not_of(kWhitespaceUTF16); + const base::string16 current_text(text()); + const size_t start = current_text.find_first_not_of(base::kWhitespaceUTF16); if (start == string16::npos || (current_text[start] != '?')) OmniboxView::SetUserText(ASCIIToUTF16("?")); else diff --git a/chrome/common/extensions/api/i18n/default_locale_handler.cc b/chrome/common/extensions/api/i18n/default_locale_handler.cc index 2978d78..c395ced 100644 --- a/chrome/common/extensions/api/i18n/default_locale_handler.cc +++ b/chrome/common/extensions/api/i18n/default_locale_handler.cc @@ -27,7 +27,7 @@ namespace errors = manifest_errors; const std::string& LocaleInfo::GetDefaultLocale(const Extension* extension) { LocaleInfo* info = static_cast<LocaleInfo*>( extension->GetManifestData(keys::kDefaultLocale)); - return info ? info->default_locale : EmptyString(); + return info ? info->default_locale : base::EmptyString(); } DefaultLocaleHandler::DefaultLocaleHandler() { diff --git a/chrome/common/extensions/api/omnibox/omnibox_handler.cc b/chrome/common/extensions/api/omnibox/omnibox_handler.cc index aec2d7a..77500ac 100644 --- a/chrome/common/extensions/api/omnibox/omnibox_handler.cc +++ b/chrome/common/extensions/api/omnibox/omnibox_handler.cc @@ -25,7 +25,7 @@ const char kKeyword[] = "keyword"; const std::string& OmniboxInfo::GetKeyword(const Extension* extension) { OmniboxInfo* info = static_cast<OmniboxInfo*>( extension->GetManifestData(manifest_keys::kOmnibox)); - return info ? info->keyword : EmptyString(); + return info ? info->keyword : base::EmptyString(); } OmniboxHandler::OmniboxHandler() { diff --git a/chrome/common/extensions/permissions/socket_permission_entry.cc b/chrome/common/extensions/permissions/socket_permission_entry.cc index 9d9eeea..be426ea 100644 --- a/chrome/common/extensions/permissions/socket_permission_entry.cc +++ b/chrome/common/extensions/permissions/socket_permission_entry.cc @@ -28,9 +28,9 @@ const int kWildcardPortNumber = 0; const int kInvalidPort = -1; bool StartsOrEndsWithWhitespace(const std::string& str) { - if (str.find_first_not_of(kWhitespaceASCII) != 0) + if (str.find_first_not_of(base::kWhitespaceASCII) != 0) return true; - if (str.find_last_not_of(kWhitespaceASCII) != str.length() - 1) + if (str.find_last_not_of(base::kWhitespaceASCII) != str.length() - 1) return true; return false; } diff --git a/chrome/renderer/chrome_render_view_observer.cc b/chrome/renderer/chrome_render_view_observer.cc index cdcbe17..9bb2e1f 100644 --- a/chrome/renderer/chrome_render_view_observer.cc +++ b/chrome/renderer/chrome_render_view_observer.cc @@ -958,8 +958,8 @@ void ChromeRenderViewObserver::CaptureText(WebFrame* frame, // partial word indexed at the end that might have been clipped. Therefore, // terminate the string at the last space to ensure no words are clipped. if (contents->size() == kMaxIndexChars) { - size_t last_space_index = contents->find_last_of(kWhitespaceUTF16); - if (last_space_index == std::wstring::npos) + size_t last_space_index = contents->find_last_of(base::kWhitespaceUTF16); + if (last_space_index == base::string16::npos) return; // don't index if we got a huge block of text with no spaces contents->resize(last_space_index); } |