diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-04 21:00:16 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-04 21:00:16 +0000 |
commit | 969201575445f53b11562542f4d8a12d8f1a4777 (patch) | |
tree | fa491f8ec26fa6bd232e3cf5a5051acd2fea6e97 /chrome/browser/autocomplete | |
parent | 84a3403847df91ea351d67e2d50025fd3f0bf651 (diff) | |
download | chromium_src-969201575445f53b11562542f4d8a12d8f1a4777.zip chromium_src-969201575445f53b11562542f4d8a12d8f1a4777.tar.gz chromium_src-969201575445f53b11562542f4d8a12d8f1a4777.tar.bz2 |
Replace string16 with base::string16.
This updates portions of chrome/browser/... to use the base namespace.
BUG=
Review URL: https://codereview.chromium.org/105193002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238766 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
41 files changed, 397 insertions, 366 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_browsertest.cc b/chrome/browser/autocomplete/autocomplete_browsertest.cc index 732920a..eb0a59f 100644 --- a/chrome/browser/autocomplete/autocomplete_browsertest.cc +++ b/chrome/browser/autocomplete/autocomplete_browsertest.cc @@ -36,7 +36,7 @@ namespace { -string16 AutocompleteResultAsString(const AutocompleteResult& result) { +base::string16 AutocompleteResultAsString(const AutocompleteResult& result) { std::string output(base::StringPrintf("{%" PRIuS "} ", result.size())); for (size_t i = 0; i < result.size(); ++i) { AutocompleteMatch match = result.match_at(i); @@ -137,7 +137,7 @@ IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, MAYBE_Autocomplete) { { omnibox_view->model()->SetInputInProgress(true); autocomplete_controller->Start(AutocompleteInput( - ASCIIToUTF16("chrome"), string16::npos, string16(), GURL(), + ASCIIToUTF16("chrome"), base::string16::npos, base::string16(), GURL(), AutocompleteInput::NTP, true, false, true, AutocompleteInput::SYNCHRONOUS_MATCHES)); @@ -179,7 +179,7 @@ IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, TabAwayRevertSelect) { LocationBar* location_bar = GetLocationBar(); OmniboxView* omnibox_view = location_bar->GetOmniboxView(); EXPECT_EQ(UTF8ToUTF16(content::kAboutBlankURL), omnibox_view->GetText()); - omnibox_view->SetUserText(string16()); + omnibox_view->SetUserText(base::string16()); content::WindowedNotificationObserver observer( content::NOTIFICATION_LOAD_STOP, content::NotificationService::AllSources()); diff --git a/chrome/browser/autocomplete/autocomplete_classifier.cc b/chrome/browser/autocomplete/autocomplete_classifier.cc index 49fc6cc..b8169ad 100644 --- a/chrome/browser/autocomplete/autocomplete_classifier.cc +++ b/chrome/browser/autocomplete/autocomplete_classifier.cc @@ -33,7 +33,7 @@ AutocompleteClassifier::~AutocompleteClassifier() { DCHECK(!controller_.get()); } -void AutocompleteClassifier::Classify(const string16& text, +void AutocompleteClassifier::Classify(const base::string16& text, bool prefer_keyword, bool allow_exact_keyword_match, AutocompleteMatch* match, @@ -41,7 +41,7 @@ void AutocompleteClassifier::Classify(const string16& text, DCHECK(!inside_classify_); base::AutoReset<bool> reset(&inside_classify_, true); controller_->Start(AutocompleteInput( - text, string16::npos, string16(), GURL(), + text, base::string16::npos, base::string16(), GURL(), AutocompleteInput::INVALID_SPEC, true, prefer_keyword, allow_exact_keyword_match, AutocompleteInput::BEST_MATCH)); DCHECK(controller_->done()); diff --git a/chrome/browser/autocomplete/autocomplete_classifier.h b/chrome/browser/autocomplete/autocomplete_classifier.h index dc0833e..8e9c760 100644 --- a/chrome/browser/autocomplete/autocomplete_classifier.h +++ b/chrome/browser/autocomplete/autocomplete_classifier.h @@ -39,7 +39,7 @@ class AutocompleteClassifier : public BrowserContextKeyedService { // non-NULL, will be set to the navigational URL (if any) in case of an // accidental search; see comments on // AutocompleteResult::alternate_nav_url_ in autocomplete.h. - void Classify(const string16& text, + void Classify(const base::string16& text, bool prefer_keyword, bool allow_exact_keyword_match, AutocompleteMatch* match, diff --git a/chrome/browser/autocomplete/autocomplete_controller.cc b/chrome/browser/autocomplete/autocomplete_controller.cc index a2bbfff..999d60e 100644 --- a/chrome/browser/autocomplete/autocomplete_controller.cc +++ b/chrome/browser/autocomplete/autocomplete_controller.cc @@ -50,7 +50,7 @@ void AutocompleteMatchToAssistedQuery( // This type indicates a native chrome suggestion. *type = 69; // Default value, indicating no subtype. - *subtype = string16::npos; + *subtype = base::string16::npos; switch (match) { case AutocompleteMatchType::SEARCH_SUGGEST: { @@ -112,7 +112,7 @@ void AppendAvailableAutocompletion(size_t type, autocompletions->append("j"); base::StringAppendF(autocompletions, "%" PRIuS, type); // Subtype is optional - string16::npos indicates no subtype. - if (subtype != string16::npos) + if (subtype != base::string16::npos) base::StringAppendF(autocompletions, "i%" PRIuS, subtype); if (count > 1) base::StringAppendF(autocompletions, "l%d", count); @@ -215,7 +215,7 @@ AutocompleteController::~AutocompleteController() { } void AutocompleteController::Start(const AutocompleteInput& input) { - const string16 old_input_text(input_.text()); + const base::string16 old_input_text(input_.text()); const AutocompleteInput::MatchesRequested old_matches_requested = input_.matches_requested(); input_ = input; @@ -306,7 +306,7 @@ void AutocompleteController::Stop(bool clear_result) { void AutocompleteController::StartZeroSuggest( const GURL& url, AutocompleteInput::PageClassification page_classification, - const string16& permanent_text) { + const base::string16& permanent_text) { if (zero_suggest_provider_ != NULL) { DCHECK(!in_start_); // We should not be already running a query. in_zero_suggest_ = true; @@ -407,7 +407,7 @@ void AutocompleteController::UpdateResult( const bool last_default_was_valid = result_.default_match() != result_.end(); // The following three variables are only set and used if // |last_default_was_valid|. - string16 last_default_fill_into_edit, last_default_keyword, + base::string16 last_default_fill_into_edit, last_default_keyword, last_default_associated_keyword; if (last_default_was_valid) { last_default_fill_into_edit = result_.default_match()->fill_into_edit; @@ -447,7 +447,7 @@ void AutocompleteController::UpdateResult( UpdateAssistedQueryStats(&result_); const bool default_is_valid = result_.default_match() != result_.end(); - string16 default_associated_keyword; + base::string16 default_associated_keyword; if (default_is_valid && (result_.default_match()->associated_keyword != NULL)) { default_associated_keyword = @@ -480,10 +480,11 @@ void AutocompleteController::UpdateAssociatedKeywords( if (!keyword_provider_) return; - std::set<string16> keywords; + std::set<base::string16> keywords; for (ACMatches::iterator match(result->begin()); match != result->end(); ++match) { - string16 keyword(match->GetSubstitutingExplicitlyInvokedKeyword(profile_)); + base::string16 keyword( + match->GetSubstitutingExplicitlyInvokedKeyword(profile_)); if (!keyword.empty()) { keywords.insert(keyword); continue; @@ -509,7 +510,7 @@ void AutocompleteController::UpdateAssociatedKeywords( void AutocompleteController::UpdateKeywordDescriptions( AutocompleteResult* result) { - string16 last_keyword; + base::string16 last_keyword; for (AutocompleteResult::iterator i(result->begin()); i != result->end(); ++i) { if ((i->provider->type() == AutocompleteProvider::TYPE_KEYWORD && @@ -549,14 +550,14 @@ void AutocompleteController::UpdateAssistedQueryStats( // Build the impressions string (the AQS part after "."). std::string autocompletions; int count = 0; - size_t last_type = string16::npos; - size_t last_subtype = string16::npos; + size_t last_type = base::string16::npos; + size_t last_subtype = base::string16::npos; for (ACMatches::iterator match(result->begin()); match != result->end(); ++match) { - size_t type = string16::npos; - size_t subtype = string16::npos; + size_t type = base::string16::npos; + size_t subtype = base::string16::npos; AutocompleteMatchToAssistedQuery(match->type, &type, &subtype); - if (last_type != string16::npos && + if (last_type != base::string16::npos && (type != last_type || subtype != last_subtype)) { AppendAvailableAutocompletion( last_type, last_subtype, count, &autocompletions); diff --git a/chrome/browser/autocomplete/autocomplete_controller.h b/chrome/browser/autocomplete/autocomplete_controller.h index c95b4c9..73ba1ef 100644 --- a/chrome/browser/autocomplete/autocomplete_controller.h +++ b/chrome/browser/autocomplete/autocomplete_controller.h @@ -83,7 +83,7 @@ class AutocompleteController : public AutocompleteProviderListener { void StartZeroSuggest( const GURL& url, AutocompleteInput::PageClassification page_classification, - const string16& permanent_text); + const base::string16& permanent_text); // Cancels any pending zero-suggest fetch. void StopZeroSuggest(); diff --git a/chrome/browser/autocomplete/autocomplete_input.cc b/chrome/browser/autocomplete/autocomplete_input.cc index 2de3f96..40d98fa 100644 --- a/chrome/browser/autocomplete/autocomplete_input.cc +++ b/chrome/browser/autocomplete/autocomplete_input.cc @@ -19,7 +19,7 @@ namespace { void AdjustCursorPositionIfNecessary(size_t num_leading_chars_removed, size_t* cursor_position) { - if (*cursor_position == string16::npos) + if (*cursor_position == base::string16::npos) return; if (num_leading_chars_removed < *cursor_position) *cursor_position -= num_leading_chars_removed; @@ -30,7 +30,7 @@ void AdjustCursorPositionIfNecessary(size_t num_leading_chars_removed, } // namespace AutocompleteInput::AutocompleteInput() - : cursor_position_(string16::npos), + : cursor_position_(base::string16::npos), current_page_classification_(AutocompleteInput::INVALID_SPEC), type_(INVALID), prevent_inline_autocomplete_(false), @@ -40,9 +40,9 @@ AutocompleteInput::AutocompleteInput() } AutocompleteInput::AutocompleteInput( - const string16& text, + const base::string16& text, size_t cursor_position, - const string16& desired_tld, + const base::string16& desired_tld, const GURL& current_url, AutocompleteInput::PageClassification current_page_classification, bool prevent_inline_autocomplete, @@ -56,7 +56,8 @@ AutocompleteInput::AutocompleteInput( prefer_keyword_(prefer_keyword), allow_exact_keyword_match_(allow_exact_keyword_match), matches_requested_(matches_requested) { - DCHECK(cursor_position <= text.length() || cursor_position == string16::npos) + DCHECK(cursor_position <= text.length() || + cursor_position == base::string16::npos) << "Text: '" << text << "', cp: " << cursor_position; // None of the providers care about leading white space so we always trim it. // Providers that care about trailing white space handle trimming themselves. @@ -81,7 +82,7 @@ AutocompleteInput::AutocompleteInput( AdjustCursorPositionIfNecessary(chars_removed, &cursor_position_); if (chars_removed) { // Remove spaces between opening question mark and first actual character. - string16 trimmed_text; + base::string16 trimmed_text; if ((TrimWhitespace(text_, TRIM_LEADING, &trimmed_text) & TRIM_LEADING) != 0) { AdjustCursorPositionIfNecessary(text_.length() - trimmed_text.length(), @@ -95,8 +96,9 @@ AutocompleteInput::~AutocompleteInput() { } // static -size_t AutocompleteInput::RemoveForcedQueryStringIfNecessary(Type type, - string16* text) { +size_t AutocompleteInput::RemoveForcedQueryStringIfNecessary( + Type type, + base::string16* text) { if (type != FORCED_QUERY || text->empty() || (*text)[0] != L'?') return 0; // Drop the leading '?'. @@ -127,7 +129,7 @@ AutocompleteInput::Type AutocompleteInput::Parse( base::string16* scheme, GURL* canonicalized_url) { size_t first_non_white = text.find_first_not_of(base::kWhitespaceUTF16, 0); - if (first_non_white == string16::npos) + if (first_non_white == base::string16::npos) return INVALID; // All whitespace. if (text.at(first_non_white) == L'?') { @@ -143,7 +145,7 @@ AutocompleteInput::Type AutocompleteInput::Parse( url_parse::Parsed local_parts; if (!parts) parts = &local_parts; - const string16 parsed_scheme(URLFixerUpper::SegmentURL(text, parts)); + const base::string16 parsed_scheme(URLFixerUpper::SegmentURL(text, parts)); if (scheme) *scheme = parsed_scheme; if (canonicalized_url) { @@ -208,11 +210,11 @@ AutocompleteInput::Type AutocompleteInput::Parse( default: { // We don't know about this scheme. It might be that the user typed a // URL of the form "username:password@foo.com". - const string16 http_scheme_prefix = + const base::string16 http_scheme_prefix = ASCIIToUTF16(std::string(content::kHttpScheme) + content::kStandardSchemeSeparator); url_parse::Parsed http_parts; - string16 http_scheme; + base::string16 http_scheme; GURL http_canonicalized_url; Type http_type = Parse(http_scheme_prefix + text, desired_tld, &http_parts, &http_scheme, @@ -269,7 +271,7 @@ AutocompleteInput::Type AutocompleteInput::Parse( // Likewise, the RCDS can reject certain obviously-invalid hosts. (We also // use the registry length later below.) - const string16 host(text.substr(parts->host.begin, parts->host.len)); + const base::string16 host(text.substr(parts->host.begin, parts->host.len)); const size_t registry_length = net::registry_controlled_domains::GetRegistryLength( UTF16ToUTF8(host), @@ -278,7 +280,7 @@ AutocompleteInput::Type AutocompleteInput::Parse( if (registry_length == std::string::npos) { // Try to append the desired_tld. if (!desired_tld.empty()) { - string16 host_with_tld(host); + base::string16 host_with_tld(host); if (host[host.length() - 1] != '.') host_with_tld += '.'; host_with_tld += desired_tld; @@ -324,8 +326,8 @@ AutocompleteInput::Type AutocompleteInput::Parse( // TLD // These are rare, though probably possible in intranets. return (parts->scheme.is_nonempty() || - ((registry_length != 0) && (host.find(' ') == string16::npos))) ? - UNKNOWN : QUERY; + ((registry_length != 0) && + (host.find(' ') == base::string16::npos))) ? UNKNOWN : QUERY; } // A port number is a good indicator that this is a URL. However, it might @@ -423,12 +425,12 @@ AutocompleteInput::Type AutocompleteInput::Parse( // static void AutocompleteInput::ParseForEmphasizeComponents( - const string16& text, + const base::string16& text, url_parse::Component* scheme, url_parse::Component* host) { url_parse::Parsed parts; - string16 scheme_str; - Parse(text, string16(), &parts, &scheme_str, NULL); + base::string16 scheme_str; + Parse(text, base::string16(), &parts, &scheme_str, NULL); *scheme = parts.scheme; *host = parts.host; @@ -439,9 +441,9 @@ void AutocompleteInput::ParseForEmphasizeComponents( if (LowerCaseEqualsASCII(scheme_str, content::kViewSourceScheme) && (static_cast<int>(text.length()) > after_scheme_and_colon)) { // Obtain the URL prefixed by view-source and parse it. - string16 real_url(text.substr(after_scheme_and_colon)); + base::string16 real_url(text.substr(after_scheme_and_colon)); url_parse::Parsed real_parts; - AutocompleteInput::Parse(real_url, string16(), &real_parts, NULL, NULL); + AutocompleteInput::Parse(real_url, base::string16(), &real_parts, NULL, NULL); if (real_parts.scheme.is_nonempty() || real_parts.host.is_nonempty()) { if (real_parts.scheme.is_nonempty()) { *scheme = url_parse::Component( @@ -465,15 +467,15 @@ void AutocompleteInput::ParseForEmphasizeComponents( } // static -string16 AutocompleteInput::FormattedStringWithEquivalentMeaning( +base::string16 AutocompleteInput::FormattedStringWithEquivalentMeaning( const GURL& url, - const string16& formatted_url) { + const base::string16& formatted_url) { if (!net::CanStripTrailingSlash(url)) return formatted_url; - const string16 url_with_path(formatted_url + char16('/')); - return (AutocompleteInput::Parse(formatted_url, string16(), NULL, NULL, + const base::string16 url_with_path(formatted_url + char16('/')); + return (AutocompleteInput::Parse(formatted_url, base::string16(), NULL, NULL, NULL) == - AutocompleteInput::Parse(url_with_path, string16(), NULL, NULL, + AutocompleteInput::Parse(url_with_path, base::string16(), NULL, NULL, NULL)) ? formatted_url : url_with_path; } @@ -499,7 +501,7 @@ int AutocompleteInput::NumNonHostComponents(const url_parse::Parsed& parts) { } // static -bool AutocompleteInput::HasHTTPScheme(const string16& input) { +bool AutocompleteInput::HasHTTPScheme(const base::string16& input) { std::string utf8_input(UTF16ToUTF8(input)); url_parse::Component scheme; if (url_util::FindAndCompareScheme(utf8_input, content::kViewSourceScheme, @@ -508,10 +510,11 @@ bool AutocompleteInput::HasHTTPScheme(const string16& input) { return url_util::FindAndCompareScheme(utf8_input, content::kHttpScheme, NULL); } -void AutocompleteInput::UpdateText(const string16& text, +void AutocompleteInput::UpdateText(const base::string16& text, size_t cursor_position, const url_parse::Parsed& parts) { - DCHECK(cursor_position <= text.length() || cursor_position == string16::npos) + DCHECK(cursor_position <= text.length() || + cursor_position == base::string16::npos) << "Text: '" << text << "', cp: " << cursor_position; text_ = text; cursor_position_ = cursor_position; @@ -520,7 +523,7 @@ void AutocompleteInput::UpdateText(const string16& text, void AutocompleteInput::Clear() { text_.clear(); - cursor_position_ = string16::npos; + cursor_position_ = base::string16::npos; current_url_ = GURL(); current_page_classification_ = AutocompleteInput::INVALID_SPEC; type_ = INVALID; diff --git a/chrome/browser/autocomplete/autocomplete_input.h b/chrome/browser/autocomplete/autocomplete_input.h index 1e1a64d..fde6aa8 100644 --- a/chrome/browser/autocomplete/autocomplete_input.h +++ b/chrome/browser/autocomplete/autocomplete_input.h @@ -133,9 +133,9 @@ class AutocompleteInput { // If |matches_requested| is BEST_MATCH or SYNCHRONOUS_MATCHES the controller // asks the providers to only return matches which are synchronously // available, which should mean that all providers will be done immediately. - AutocompleteInput(const string16& text, + AutocompleteInput(const base::string16& text, size_t cursor_position, - const string16& desired_tld, + const base::string16& desired_tld, const GURL& current_url, PageClassification current_page_classification, bool prevent_inline_autocomplete, @@ -146,7 +146,8 @@ class AutocompleteInput { // If type is |FORCED_QUERY| and |text| starts with '?', it is removed. // Returns number of leading characters removed. - static size_t RemoveForcedQueryStringIfNecessary(Type type, string16* text); + static size_t RemoveForcedQueryStringIfNecessary(Type type, + base::string16* text); // Converts |type| to a string representation. Used in logging. static std::string TypeToString(Type type); @@ -156,17 +157,17 @@ class AutocompleteInput { // it is non-NULL. The scheme is stored in |scheme| if it is non-NULL. The // canonicalized URL is stored in |canonicalized_url|; however, this URL is // not guaranteed to be valid, especially if the parsed type is, e.g., QUERY. - static Type Parse(const string16& text, - const string16& desired_tld, + static Type Parse(const base::string16& text, + const base::string16& desired_tld, url_parse::Parsed* parts, - string16* scheme, + base::string16* scheme, GURL* canonicalized_url); // Parses |text| and fill |scheme| and |host| by the positions of them. // The results are almost as same as the result of Parse(), but if the scheme // is view-source, this function returns the positions of scheme and host // in the URL qualified by "view-source:" prefix. - static void ParseForEmphasizeComponents(const string16& text, + static void ParseForEmphasizeComponents(const base::string16& text, url_parse::Component* scheme, url_parse::Component* host); @@ -176,18 +177,18 @@ class AutocompleteInput { // function with the URL and its formatted string, and it will return a // formatted string with the same meaning as the original URL (i.e. it will // re-append a slash if necessary). - static string16 FormattedStringWithEquivalentMeaning( + static base::string16 FormattedStringWithEquivalentMeaning( const GURL& url, - const string16& formatted_url); + const base::string16& formatted_url); // Returns the number of non-empty components in |parts| besides the host. static int NumNonHostComponents(const url_parse::Parsed& parts); // Returns whether |text| begins "http:" or "view-source:http:". - static bool HasHTTPScheme(const string16& text); + static bool HasHTTPScheme(const base::string16& text); // User-provided text to be completed. - const string16& text() const { return text_; } + const base::string16& text() const { return text_; } // Returns 0-based cursor position within |text_| or string16::npos if not // used. @@ -196,7 +197,7 @@ class AutocompleteInput { // Use of this setter is risky, since no other internal state is updated // besides |text_|, |cursor_position_| and |parts_|. Only callers who know // that they're not changing the type/scheme/etc. should use this. - void UpdateText(const string16& text, + void UpdateText(const base::string16& text, size_t cursor_position, const url_parse::Parsed& parts); @@ -217,7 +218,7 @@ class AutocompleteInput { // The scheme parsed from the provided text; only meaningful when type_ is // URL. - const string16& scheme() const { return scheme_; } + const base::string16& scheme() const { return scheme_; } // The input as an URL to navigate to, if possible. const GURL& canonicalized_url() const { return canonicalized_url_; } @@ -247,13 +248,13 @@ class AutocompleteInput { // NOTE: Whenever adding a new field here, please make sure to update Clear() // method. - string16 text_; + base::string16 text_; size_t cursor_position_; GURL current_url_; AutocompleteInput::PageClassification current_page_classification_; Type type_; url_parse::Parsed parts_; - string16 scheme_; + base::string16 scheme_; GURL canonicalized_url_; bool prevent_inline_autocomplete_; bool prefer_keyword_; diff --git a/chrome/browser/autocomplete/autocomplete_input_unittest.cc b/chrome/browser/autocomplete/autocomplete_input_unittest.cc index 9d7fcfd..f3110a9 100644 --- a/chrome/browser/autocomplete/autocomplete_input_unittest.cc +++ b/chrome/browser/autocomplete/autocomplete_input_unittest.cc @@ -13,10 +13,10 @@ TEST(AutocompleteInputTest, InputType) { struct test_data { - const string16 input; + const base::string16 input; const AutocompleteInput::Type type; } input_cases[] = { - { string16(), AutocompleteInput::INVALID }, + { base::string16(), AutocompleteInput::INVALID }, { ASCIIToUTF16("?"), AutocompleteInput::FORCED_QUERY }, { ASCIIToUTF16("?foo"), AutocompleteInput::FORCED_QUERY }, { ASCIIToUTF16("?foo bar"), AutocompleteInput::FORCED_QUERY }, @@ -121,16 +121,17 @@ TEST(AutocompleteInputTest, InputType) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input_cases); ++i) { SCOPED_TRACE(input_cases[i].input); - AutocompleteInput input(input_cases[i].input, string16::npos, string16(), - GURL(), AutocompleteInput::INVALID_SPEC, true, - false, true, AutocompleteInput::ALL_MATCHES); + AutocompleteInput input(input_cases[i].input, base::string16::npos, + base::string16(), GURL(), + AutocompleteInput::INVALID_SPEC, true, false, true, + AutocompleteInput::ALL_MATCHES); EXPECT_EQ(input_cases[i].type, input.type()); } } TEST(AutocompleteInputTest, InputTypeWithDesiredTLD) { struct test_data { - const string16 input; + const base::string16 input; const AutocompleteInput::Type type; const std::string spec; // Unused if not a URL. } input_cases[] = { @@ -149,7 +150,7 @@ TEST(AutocompleteInputTest, InputTypeWithDesiredTLD) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input_cases); ++i) { SCOPED_TRACE(input_cases[i].input); - AutocompleteInput input(input_cases[i].input, string16::npos, + AutocompleteInput input(input_cases[i].input, base::string16::npos, ASCIIToUTF16("com"), GURL(), AutocompleteInput::INVALID_SPEC, true, false, true, AutocompleteInput::ALL_MATCHES); @@ -162,8 +163,9 @@ TEST(AutocompleteInputTest, InputTypeWithDesiredTLD) { // This tests for a regression where certain input in the omnibox caused us to // crash. As long as the test completes without crashing, we're fine. TEST(AutocompleteInputTest, InputCrash) { - AutocompleteInput input(WideToUTF16(L"\uff65@s"), string16::npos, string16(), - GURL(), AutocompleteInput::INVALID_SPEC, true, false, + AutocompleteInput input(WideToUTF16(L"\uff65@s"), base::string16::npos, + base::string16(), GURL(), + AutocompleteInput::INVALID_SPEC, true, false, true, AutocompleteInput::ALL_MATCHES); } @@ -171,11 +173,11 @@ TEST(AutocompleteInputTest, ParseForEmphasizeComponent) { using url_parse::Component; Component kInvalidComponent(0, -1); struct test_data { - const string16 input; + const base::string16 input; const Component scheme; const Component host; } input_cases[] = { - { string16(), kInvalidComponent, kInvalidComponent }, + { base::string16(), kInvalidComponent, kInvalidComponent }, { ASCIIToUTF16("?"), kInvalidComponent, kInvalidComponent }, { ASCIIToUTF16("?http://foo.com/bar"), kInvalidComponent, kInvalidComponent }, @@ -205,8 +207,9 @@ TEST(AutocompleteInputTest, ParseForEmphasizeComponent) { AutocompleteInput::ParseForEmphasizeComponents(input_cases[i].input, &scheme, &host); - AutocompleteInput input(input_cases[i].input, string16::npos, string16(), - GURL(), AutocompleteInput::INVALID_SPEC, true, + AutocompleteInput input(input_cases[i].input, base::string16::npos, + base::string16(), GURL(), + AutocompleteInput::INVALID_SPEC, true, false, true, AutocompleteInput::ALL_MATCHES); EXPECT_EQ(input_cases[i].scheme.begin, scheme.begin); EXPECT_EQ(input_cases[i].scheme.len, scheme.len); @@ -217,13 +220,13 @@ TEST(AutocompleteInputTest, ParseForEmphasizeComponent) { TEST(AutocompleteInputTest, InputTypeWithCursorPosition) { struct test_data { - const string16 input; + const base::string16 input; size_t cursor_position; - const string16 normalized_input; + const base::string16 normalized_input; size_t normalized_cursor_position; } input_cases[] = { - { ASCIIToUTF16("foo bar"), string16::npos, - ASCIIToUTF16("foo bar"), string16::npos }, + { ASCIIToUTF16("foo bar"), base::string16::npos, + ASCIIToUTF16("foo bar"), base::string16::npos }, // regular case, no changes. { ASCIIToUTF16("foo bar"), 3, ASCIIToUTF16("foo bar"), 3 }, @@ -244,7 +247,8 @@ TEST(AutocompleteInputTest, InputTypeWithCursorPosition) { SCOPED_TRACE(input_cases[i].input); AutocompleteInput input(input_cases[i].input, input_cases[i].cursor_position, - string16(), GURL(), AutocompleteInput::INVALID_SPEC, + base::string16(), GURL(), + AutocompleteInput::INVALID_SPEC, true, false, true, AutocompleteInput::ALL_MATCHES); EXPECT_EQ(input_cases[i].normalized_input, input.text()); EXPECT_EQ(input_cases[i].normalized_cursor_position, diff --git a/chrome/browser/autocomplete/autocomplete_match.cc b/chrome/browser/autocomplete/autocomplete_match.cc index 6d5544d..5c1c194 100644 --- a/chrome/browser/autocomplete/autocomplete_match.cc +++ b/chrome/browser/autocomplete/autocomplete_match.cc @@ -196,8 +196,8 @@ bool AutocompleteMatch::DestinationsEqual(const AutocompleteMatch& elem1, // static void AutocompleteMatch::ClassifyMatchInString( - const string16& find_text, - const string16& text, + const base::string16& find_text, + const base::string16& text, int style, ACMatchClassifications* classification) { ClassifyLocationInString(text.find(find_text), find_text.length(), @@ -224,7 +224,7 @@ void AutocompleteMatch::ClassifyLocationInString( } // Mark matching portion of string. - if (match_location == string16::npos) { + if (match_location == base::string16::npos) { // No match, above classification will suffice for whole string. return; } @@ -320,10 +320,10 @@ void AutocompleteMatch::AddLastClassificationIfNecessary( } // static -string16 AutocompleteMatch::SanitizeString(const string16& text) { +base::string16 AutocompleteMatch::SanitizeString(const base::string16& text) { // NOTE: This logic is mirrored by |sanitizeString()| in // omnibox_custom_bindings.js. - string16 result; + base::string16 result; TrimWhitespace(text, TRIM_LEADING, &result); base::RemoveChars(result, kInvalidChars, &result); return result; @@ -349,7 +349,7 @@ void AutocompleteMatch::ComputeStrippedDestinationURL(Profile* profile) { // provider matches. TemplateURL* template_url = GetTemplateURL(profile, true); if (template_url != NULL && template_url->SupportsReplacement()) { - string16 search_terms; + base::string16 search_terms; if (template_url->ExtractSearchTermsFromURL(stripped_destination_url, &search_terms)) { stripped_destination_url = @@ -389,19 +389,19 @@ void AutocompleteMatch::ComputeStrippedDestinationURL(Profile* profile) { } void AutocompleteMatch::GetKeywordUIState(Profile* profile, - string16* keyword, + base::string16* keyword, bool* is_keyword_hint) const { *is_keyword_hint = associated_keyword.get() != NULL; keyword->assign(*is_keyword_hint ? associated_keyword->keyword : GetSubstitutingExplicitlyInvokedKeyword(profile)); } -string16 AutocompleteMatch::GetSubstitutingExplicitlyInvokedKeyword( +base::string16 AutocompleteMatch::GetSubstitutingExplicitlyInvokedKeyword( Profile* profile) const { if (transition != content::PAGE_TRANSITION_KEYWORD) - return string16(); + return base::string16(); const TemplateURL* t_url = GetTemplateURL(profile, false); - return (t_url && t_url->SupportsReplacement()) ? keyword : string16(); + return (t_url && t_url->SupportsReplacement()) ? keyword : base::string16(); } TemplateURL* AutocompleteMatch::GetTemplateURL( @@ -461,7 +461,7 @@ void AutocompleteMatch::Validate() const { } void AutocompleteMatch::ValidateClassifications( - const string16& text, + const base::string16& text, const ACMatchClassifications& classifications) const { if (text.empty()) { DCHECK(classifications.empty()); diff --git a/chrome/browser/autocomplete/autocomplete_match.h b/chrome/browser/autocomplete/autocomplete_match.h index 38108dd..ad91c259a 100644 --- a/chrome/browser/autocomplete/autocomplete_match.h +++ b/chrome/browser/autocomplete/autocomplete_match.h @@ -117,8 +117,8 @@ struct AutocompleteMatch { // Fills in the classifications for |text|, using |style| as the base style // and marking the first instance of |find_text| as a match. (This match // will also not be dimmed, if |style| has DIM set.) - static void ClassifyMatchInString(const string16& find_text, - const string16& text, + static void ClassifyMatchInString(const base::string16& find_text, + const base::string16& text, int style, ACMatchClassifications* classifications); @@ -156,7 +156,7 @@ struct AutocompleteMatch { // Removes invalid characters from |text|. Should be called on strings coming // from external sources (such as extensions) before assigning to |contents| // or |description|. - static string16 SanitizeString(const string16& text); + static base::string16 SanitizeString(const base::string16& text); // Convenience function to check if |type| is a search (as opposed to a URL or // an extension). @@ -187,7 +187,7 @@ struct AutocompleteMatch { // represent searches using the default search engine. See also // GetSubstitutingExplicitlyInvokedKeyword(). void GetKeywordUIState(Profile* profile, - string16* keyword, + base::string16* keyword, bool* is_keyword_hint) const; // Returns |keyword|, but only if it represents a substituting keyword that @@ -196,7 +196,8 @@ struct AutocompleteMatch { // invoke its keyword), this returns the empty string. The result is that // this function returns a non-empty string in the same cases as when the UI // should show up as being "in keyword mode". - string16 GetSubstitutingExplicitlyInvokedKeyword(Profile* profile) const; + base::string16 GetSubstitutingExplicitlyInvokedKeyword( + Profile* profile) const; // Returns the TemplateURL associated with this match. This may be NULL if // the match has no keyword OR if the keyword no longer corresponds to a valid @@ -254,11 +255,11 @@ struct AutocompleteMatch { // This string is loaded into the location bar when the item is selected // by pressing the arrow keys. This may be different than a URL, for example, // for search suggestions, this would just be the search terms. - string16 fill_into_edit; + base::string16 fill_into_edit; // The inline autocompletion to display after the user's typing in the // omnibox, if this match becomes the default match. It may be empty. - string16 inline_autocompletion; + base::string16 inline_autocompletion; // If false, the omnibox should prevent this match from being the // default match. Providers should set this to true only if the @@ -280,11 +281,11 @@ struct AutocompleteMatch { GURL stripped_destination_url; // The main text displayed in the address bar dropdown. - string16 contents; + base::string16 contents; ACMatchClassifications contents_class; // Additional helper text for each entry, such as a title or description. - string16 description; + base::string16 description; ACMatchClassifications description_class; // The transition type to use when the user opens this match. By default @@ -315,7 +316,7 @@ struct AutocompleteMatch { // modified while the AutocompleteMatch is alive. This means anyone who // accesses it must perform any necessary sanity checks before blindly using // it! - string16 keyword; + base::string16 keyword; // True if the user has starred the destination URL. bool starred; @@ -342,7 +343,7 @@ struct AutocompleteMatch { // Checks one text/classifications pair for valid values. void ValidateClassifications( - const string16& text, + const base::string16& text, const ACMatchClassifications& classifications) const; #endif }; diff --git a/chrome/browser/autocomplete/autocomplete_provider.cc b/chrome/browser/autocomplete/autocomplete_provider.cc index 859b7e4..c97e1cc 100644 --- a/chrome/browser/autocomplete/autocomplete_provider.cc +++ b/chrome/browser/autocomplete/autocomplete_provider.cc @@ -107,7 +107,7 @@ void AutocompleteProvider::AddProviderInfo(ProvidersInfo* provider_info) const { void AutocompleteProvider::ResetSession() { } -string16 AutocompleteProvider::StringForURLDisplay(const GURL& url, +base::string16 AutocompleteProvider::StringForURLDisplay(const GURL& url, bool check_accept_lang, bool trim_http) const { std::string languages = (check_accept_lang && profile_) ? diff --git a/chrome/browser/autocomplete/autocomplete_provider.h b/chrome/browser/autocomplete/autocomplete_provider.h index 02668b7..76d289c 100644 --- a/chrome/browser/autocomplete/autocomplete_provider.h +++ b/chrome/browser/autocomplete/autocomplete_provider.h @@ -210,9 +210,9 @@ class AutocompleteProvider // A convenience function to call net::FormatUrl() with the current set of // "Accept Languages" when check_accept_lang is true. Otherwise, it's called // with an empty list. - string16 StringForURLDisplay(const GURL& url, - bool check_accept_lang, - bool trim_http) const; + base::string16 StringForURLDisplay(const GURL& url, + bool check_accept_lang, + bool trim_http) const; // Returns the set of matches for the current query. const ACMatches& matches() const { return matches_; } diff --git a/chrome/browser/autocomplete/autocomplete_provider_unittest.cc b/chrome/browser/autocomplete/autocomplete_provider_unittest.cc index 2c118a1..c5dff86 100644 --- a/chrome/browser/autocomplete/autocomplete_provider_unittest.cc +++ b/chrome/browser/autocomplete/autocomplete_provider_unittest.cc @@ -44,9 +44,9 @@ const char kTestTemplateURLKeyword[] = "t"; // refcounted so that it can also be a task on the message loop. class TestProvider : public AutocompleteProvider { public: - TestProvider(int relevance, const string16& prefix, + TestProvider(int relevance, const base::string16& prefix, Profile* profile, - const string16 match_keyword) + const base::string16 match_keyword) : AutocompleteProvider(NULL, profile, AutocompleteProvider::TYPE_SEARCH), relevance_(relevance), prefix_(prefix), @@ -73,8 +73,8 @@ class TestProvider : public AutocompleteProvider { const TemplateURLRef::SearchTermsArgs& search_terms_args); int relevance_; - const string16 prefix_; - const string16 match_keyword_; + const base::string16 prefix_; + const base::string16 match_keyword_; }; void TestProvider::Start(const AutocompleteInput& input, @@ -115,7 +115,8 @@ void TestProvider::AddResults(int start_at, int num) { AddResultsWithSearchTermsArgs(start_at, num, AutocompleteMatchType::URL_WHAT_YOU_TYPED, - TemplateURLRef::SearchTermsArgs(string16())); + TemplateURLRef::SearchTermsArgs( + base::string16())); } void TestProvider::AddResultsWithSearchTermsArgs( @@ -151,8 +152,8 @@ class AutocompleteProviderTest : public testing::Test, public content::NotificationObserver { protected: struct KeywordTestData { - const string16 fill_into_edit; - const string16 keyword; + const base::string16 fill_into_edit; + const base::string16 keyword; const bool expected_keyword_result; }; @@ -163,7 +164,7 @@ class AutocompleteProviderTest : public testing::Test, protected: // Registers a test TemplateURL under the given keyword. - void RegisterTemplateURL(const string16 keyword, + void RegisterTemplateURL(const base::string16 keyword, const std::string& template_url); // Resets |controller_| with two TestProviders. |provider1_ptr| and @@ -182,7 +183,7 @@ class AutocompleteProviderTest : public testing::Test, const AssistedQueryStatsTestData* aqs_test_data, size_t size); - void RunQuery(const string16 query); + void RunQuery(const base::string16 query); void ResetControllerWithKeywordAndSearchProviders(); void ResetControllerWithKeywordProvider(); @@ -210,7 +211,7 @@ class AutocompleteProviderTest : public testing::Test, }; void AutocompleteProviderTest::RegisterTemplateURL( - const string16 keyword, + const base::string16 keyword, const std::string& template_url) { TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( &profile_, &TemplateURLServiceFactory::BuildInstanceFor); @@ -259,7 +260,7 @@ void AutocompleteProviderTest::ResetControllerWithTestProviders( kResultsPerProvider * 2, same_destinations ? ASCIIToUTF16("http://a") : ASCIIToUTF16("http://b"), &profile_, - string16()); + base::string16()); provider2->AddRef(); providers.push_back(provider2); @@ -381,7 +382,7 @@ void AutocompleteProviderTest::RunAssistedQueryStatsTest( match.allowed_to_be_default_match = true; match.keyword = ASCIIToUTF16(kTestTemplateURLKeyword); match.search_terms_args.reset( - new TemplateURLRef::SearchTermsArgs(string16())); + new TemplateURLRef::SearchTermsArgs(base::string16())); matches.push_back(match); } result_.Reset(); @@ -397,10 +398,10 @@ void AutocompleteProviderTest::RunAssistedQueryStatsTest( } } -void AutocompleteProviderTest::RunQuery(const string16 query) { +void AutocompleteProviderTest::RunQuery(const base::string16 query) { result_.Reset(); controller_->Start(AutocompleteInput( - query, string16::npos, string16(), GURL(), + query, base::string16::npos, base::string16(), GURL(), AutocompleteInput::INVALID_SPEC, true, false, true, AutocompleteInput::ALL_MATCHES)); @@ -419,7 +420,7 @@ void AutocompleteProviderTest::RunExactKeymatchTest( // be from SearchProvider. (It provides all verbatim search matches, // keyword or not.) controller_->Start(AutocompleteInput( - ASCIIToUTF16("k test"), string16::npos, string16(), GURL(), + ASCIIToUTF16("k test"), base::string16::npos, base::string16(), GURL(), AutocompleteInput::INVALID_SPEC, true, false, allow_exact_keyword_match, AutocompleteInput::SYNCHRONOUS_MATCHES)); EXPECT_TRUE(controller_->done()); @@ -527,9 +528,9 @@ TEST_F(AutocompleteProviderTest, RedundantKeywordsIgnoredInResult) { { KeywordTestData duplicate_url[] = { - { ASCIIToUTF16("fo"), string16(), false }, - { ASCIIToUTF16("foo.com"), string16(), true }, - { ASCIIToUTF16("foo.com"), string16(), false } + { ASCIIToUTF16("fo"), base::string16(), false }, + { ASCIIToUTF16("foo.com"), base::string16(), true }, + { ASCIIToUTF16("foo.com"), base::string16(), false } }; SCOPED_TRACE("Duplicate url"); @@ -539,7 +540,7 @@ TEST_F(AutocompleteProviderTest, RedundantKeywordsIgnoredInResult) { { KeywordTestData keyword_match[] = { { ASCIIToUTF16("foo.com"), ASCIIToUTF16("foo.com"), false }, - { ASCIIToUTF16("foo.com"), string16(), false } + { ASCIIToUTF16("foo.com"), base::string16(), false } }; SCOPED_TRACE("Duplicate url with keyword match"); @@ -548,10 +549,10 @@ TEST_F(AutocompleteProviderTest, RedundantKeywordsIgnoredInResult) { { KeywordTestData multiple_keyword[] = { - { ASCIIToUTF16("fo"), string16(), false }, - { ASCIIToUTF16("foo.com"), string16(), true }, - { ASCIIToUTF16("foo.com"), string16(), false }, - { ASCIIToUTF16("bar.com"), string16(), true }, + { ASCIIToUTF16("fo"), base::string16(), false }, + { ASCIIToUTF16("foo.com"), base::string16(), true }, + { ASCIIToUTF16("foo.com"), base::string16(), false }, + { ASCIIToUTF16("bar.com"), base::string16(), true }, }; SCOPED_TRACE("Duplicate url with multiple keywords"); @@ -628,7 +629,7 @@ TEST_F(AutocompleteProviderTest, GetDestinationURL) { // search_terms_args needs to be set. match.search_terms_args.reset( - new TemplateURLRef::SearchTermsArgs(string16())); + new TemplateURLRef::SearchTermsArgs(base::string16())); url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); EXPECT_TRUE(url.path().empty()); diff --git a/chrome/browser/autocomplete/autocomplete_result.cc b/chrome/browser/autocomplete/autocomplete_result.cc index 7078f55..675a96c 100644 --- a/chrome/browser/autocomplete/autocomplete_result.cc +++ b/chrome/browser/autocomplete/autocomplete_result.cc @@ -194,10 +194,10 @@ void AutocompleteResult::SortAndCull(const AutocompleteInput& input, default_match_ = matches_.begin(); if (default_match_ != matches_.end()) { - const string16 debug_info = ASCIIToUTF16("fill_into_edit=") + + const base::string16 debug_info = ASCIIToUTF16("fill_into_edit=") + default_match_->fill_into_edit + ASCIIToUTF16(", provider=") + ((default_match_->provider != NULL) ? - ASCIIToUTF16(default_match_->provider->GetName()) : string16()) + + ASCIIToUTF16(default_match_->provider->GetName()) : base::string16()) + ASCIIToUTF16(", input=") + input.text(); DCHECK(default_match_->allowed_to_be_default_match) << debug_info; // We shouldn't get query matches for URL inputs, or non-query matches diff --git a/chrome/browser/autocomplete/autocomplete_result_unittest.cc b/chrome/browser/autocomplete/autocomplete_result_unittest.cc index ab152fb..e3fa9bc 100644 --- a/chrome/browser/autocomplete/autocomplete_result_unittest.cc +++ b/chrome/browser/autocomplete/autocomplete_result_unittest.cc @@ -131,7 +131,8 @@ void AutocompleteResultTest::RunCopyOldMatchesTest( const TestData* last, size_t last_size, const TestData* current, size_t current_size, const TestData* expected, size_t expected_size) { - AutocompleteInput input(ASCIIToUTF16("a"), string16::npos, string16(), GURL(), + AutocompleteInput input(ASCIIToUTF16("a"), base::string16::npos, + base::string16(), GURL(), AutocompleteInput::INVALID_SPEC, false, false, false, AutocompleteInput::ALL_MATCHES); @@ -166,7 +167,8 @@ TEST_F(AutocompleteResultTest, Swap) { AutocompleteMatch match; match.relevance = 1; match.allowed_to_be_default_match = true; - AutocompleteInput input(ASCIIToUTF16("a"), string16::npos, string16(), GURL(), + AutocompleteInput input(ASCIIToUTF16("a"), base::string16::npos, + base::string16(), GURL(), AutocompleteInput::INVALID_SPEC, false, false, false, AutocompleteInput::ALL_MATCHES); matches.push_back(match); @@ -248,7 +250,8 @@ TEST_F(AutocompleteResultTest, SortAndCullEmptyDestinationURLs) { AutocompleteResult result; result.AppendMatches(matches); - AutocompleteInput input(string16(), string16::npos, string16(), GURL(), + AutocompleteInput input(base::string16(), base::string16::npos, + base::string16(), GURL(), AutocompleteInput::INVALID_SPEC, false, false, false, AutocompleteInput::ALL_MATCHES); result.SortAndCull(input, test_util_.profile()); @@ -293,7 +296,8 @@ TEST_F(AutocompleteResultTest, SortAndCullDuplicateSearchURLs) { AutocompleteResult result; result.AppendMatches(matches); - AutocompleteInput input(string16(), string16::npos, string16(), GURL(), + AutocompleteInput input(base::string16(), base::string16::npos, + base::string16(), GURL(), AutocompleteInput::INVALID_SPEC, false, false, false, AutocompleteInput::ALL_MATCHES); result.SortAndCull(input, test_util_.profile()); @@ -360,7 +364,8 @@ TEST_F(AutocompleteResultTest, SortAndCullWithDemotionsByType) { AutocompleteResult result; result.AppendMatches(matches); - AutocompleteInput input(string16(), string16::npos, string16(), GURL(), + AutocompleteInput input(base::string16(), base::string16::npos, + base::string16(), GURL(), AutocompleteInput::HOME_PAGE, false, false, false, AutocompleteInput::ALL_MATCHES); result.SortAndCull(input, test_util_.profile()); @@ -409,7 +414,8 @@ TEST_F(AutocompleteResultTest, SortAndCullWithUndemotableTypes) { AutocompleteResult result; result.AppendMatches(matches); - AutocompleteInput input(string16(), string16::npos, string16(), GURL(), + AutocompleteInput input(base::string16(), base::string16::npos, + base::string16(), GURL(), AutocompleteInput::HOME_PAGE, false, false, false, AutocompleteInput::ALL_MATCHES); result.SortAndCull(input, test_util_.profile()); @@ -452,7 +458,8 @@ TEST_F(AutocompleteResultTest, SortAndCullReorderForDefaultMatch) { PopulateAutocompleteMatches(data, arraysize(data), &matches); AutocompleteResult result; result.AppendMatches(matches); - AutocompleteInput input(string16(), string16::npos, string16(), GURL(), + AutocompleteInput input(base::string16(), base::string16::npos, + base::string16(), GURL(), AutocompleteInput::HOME_PAGE, false, false, false, AutocompleteInput::ALL_MATCHES); result.SortAndCull(input, test_util_.profile()); @@ -467,7 +474,8 @@ TEST_F(AutocompleteResultTest, SortAndCullReorderForDefaultMatch) { matches[1].allowed_to_be_default_match = false; AutocompleteResult result; result.AppendMatches(matches); - AutocompleteInput input(string16(), string16::npos, string16(), GURL(), + AutocompleteInput input(base::string16(), base::string16::npos, + base::string16(), GURL(), AutocompleteInput::HOME_PAGE, false, false, false, AutocompleteInput::ALL_MATCHES); result.SortAndCull(input, test_util_.profile()); diff --git a/chrome/browser/autocomplete/bookmark_provider.cc b/chrome/browser/autocomplete/bookmark_provider.cc index 0ed0f22..227afac 100644 --- a/chrome/browser/autocomplete/bookmark_provider.cc +++ b/chrome/browser/autocomplete/bookmark_provider.cc @@ -164,7 +164,7 @@ AutocompleteMatch BookmarkProvider::TitleMatchToACMatch( // unlikely to be what the user intends. AutocompleteMatch match(this, 0, false, AutocompleteMatchType::BOOKMARK_TITLE); - const string16& title(title_match.node->GetTitle()); + const base::string16& title(title_match.node->GetTitle()); DCHECK(!title.empty()); const GURL& url(title_match.node->url()); match.destination_url = url; diff --git a/chrome/browser/autocomplete/bookmark_provider_unittest.cc b/chrome/browser/autocomplete/bookmark_provider_unittest.cc index b48bf39..8035ed3 100644 --- a/chrome/browser/autocomplete/bookmark_provider_unittest.cc +++ b/chrome/browser/autocomplete/bookmark_provider_unittest.cc @@ -115,8 +115,8 @@ std::string TestBookmarkPositionsAsString( // Return the positions in |matches| as a formatted string for unit test // diagnostic output. -string16 MatchesAsString16(const ACMatches& matches) { - string16 matches_string; +base::string16 MatchesAsString16(const ACMatches& matches) { + base::string16 matches_string; for (ACMatches::const_iterator i = matches.begin(); i != matches.end(); ++i) { matches_string.append(ASCIIToUTF16(" '")); matches_string.append(i->description); @@ -243,7 +243,7 @@ TEST_F(BookmarkProviderTest, Positions) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(query_data); ++i) { AutocompleteInput input(ASCIIToUTF16(query_data[i].query), - string16::npos, string16(), GURL(), + base::string16::npos, base::string16(), GURL(), AutocompleteInput::INVALID_SPEC, false, false, false, AutocompleteInput::ALL_MATCHES); provider_->Start(input, false); @@ -317,7 +317,7 @@ TEST_F(BookmarkProviderTest, Rankings) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(query_data); ++i) { AutocompleteInput input(ASCIIToUTF16(query_data[i].query), - string16::npos, string16(), GURL(), + base::string16::npos, base::string16(), GURL(), AutocompleteInput::INVALID_SPEC, false, false, false, AutocompleteInput::ALL_MATCHES); provider_->Start(input, false); diff --git a/chrome/browser/autocomplete/builtin_provider.cc b/chrome/browser/autocomplete/builtin_provider.cc index 533f117..f66be07 100644 --- a/chrome/browser/autocomplete/builtin_provider.cc +++ b/chrome/browser/autocomplete/builtin_provider.cc @@ -47,8 +47,8 @@ BuiltinProvider::BuiltinProvider(AutocompleteProviderListener* listener, for (std::vector<std::string>::iterator i(builtins.begin()); i != builtins.end(); ++i) builtins_.push_back(ASCIIToUTF16(*i)); - string16 settings(ASCIIToUTF16(chrome::kChromeUISettingsHost) + - ASCIIToUTF16("/")); + base::string16 settings(ASCIIToUTF16(chrome::kChromeUISettingsHost) + + ASCIIToUTF16("/")); for (size_t i = 0; i < arraysize(kChromeSettingsSubPages); i++) builtins_.push_back(settings + ASCIIToUTF16(kChromeSettingsSubPages[i])); } @@ -61,15 +61,15 @@ void BuiltinProvider::Start(const AutocompleteInput& input, (input.type() == AutocompleteInput::QUERY)) return; - const string16 kAbout = ASCIIToUTF16(chrome::kAboutScheme) + + const base::string16 kAbout = ASCIIToUTF16(chrome::kAboutScheme) + ASCIIToUTF16(content::kStandardSchemeSeparator); - const string16 kChrome = ASCIIToUTF16(chrome::kChromeUIScheme) + + const base::string16 kChrome = ASCIIToUTF16(chrome::kChromeUIScheme) + ASCIIToUTF16(content::kStandardSchemeSeparator); const int kUrl = ACMatchClassification::URL; const int kMatch = kUrl | ACMatchClassification::MATCH; - string16 text = input.text(); + base::string16 text = input.text(); bool starting_chrome = StartsWith(kChrome, text, false); if (starting_chrome || StartsWith(kAbout, text, false)) { ACMatchClassifications styles; @@ -82,9 +82,12 @@ void BuiltinProvider::Start(const AutocompleteInput& input, if (highlight) styles.push_back(ACMatchClassification(offset, kUrl)); // Include some common builtin chrome URLs as the user types the scheme. - AddMatch(ASCIIToUTF16(chrome::kChromeUIChromeURLsURL), string16(), styles); - AddMatch(ASCIIToUTF16(chrome::kChromeUISettingsURL), string16(), styles); - AddMatch(ASCIIToUTF16(chrome::kChromeUIVersionURL), string16(), styles); + AddMatch(ASCIIToUTF16(chrome::kChromeUIChromeURLsURL), base::string16(), + styles); + AddMatch(ASCIIToUTF16(chrome::kChromeUISettingsURL), base::string16(), + styles); + AddMatch(ASCIIToUTF16(chrome::kChromeUIVersionURL), base::string16(), + styles); } else { // Match input about: or chrome: URL input against builtin chrome URLs. GURL url = URLFixerUpper::FixupURL(UTF16ToUTF8(text), std::string()); @@ -93,7 +96,7 @@ void BuiltinProvider::Start(const AutocompleteInput& input, if (url.SchemeIs(chrome::kChromeUIScheme) && url.has_host() && !url.has_query() && !url.has_ref()) { // Include the path for sub-pages (e.g. "chrome://settings/browser"). - string16 host_and_path = UTF8ToUTF16(url.host() + url.path()); + base::string16 host_and_path = UTF8ToUTF16(url.host() + url.path()); base::TrimString(host_and_path, ASCIIToUTF16("/").c_str(), &host_and_path); size_t match_length = kChrome.length() + host_and_path.length(); @@ -103,7 +106,7 @@ void BuiltinProvider::Start(const AutocompleteInput& input, ACMatchClassifications styles; // Highlight the "chrome://" scheme, even for input "about:foo". styles.push_back(ACMatchClassification(0, kMatch)); - string16 match_string = kChrome + *i; + base::string16 match_string = kChrome + *i; if (match_string.length() > match_length) styles.push_back(ACMatchClassification(match_length, kUrl)); AddMatch(match_string, match_string.substr(match_length), styles); @@ -125,8 +128,8 @@ void BuiltinProvider::Start(const AutocompleteInput& input, BuiltinProvider::~BuiltinProvider() {} -void BuiltinProvider::AddMatch(const string16& match_string, - const string16& inline_completion, +void BuiltinProvider::AddMatch(const base::string16& match_string, + const base::string16& inline_completion, const ACMatchClassifications& styles) { AutocompleteMatch match(this, kRelevance, false, AutocompleteMatchType::NAVSUGGEST); diff --git a/chrome/browser/autocomplete/builtin_provider.h b/chrome/browser/autocomplete/builtin_provider.h index 260a3aa..2d544ab 100644 --- a/chrome/browser/autocomplete/builtin_provider.h +++ b/chrome/browser/autocomplete/builtin_provider.h @@ -26,12 +26,12 @@ class BuiltinProvider : public AutocompleteProvider { private: virtual ~BuiltinProvider(); - typedef std::vector<string16> Builtins; + typedef std::vector<base::string16> Builtins; static const int kRelevance; - void AddMatch(const string16& match_string, - const string16& inline_completion, + void AddMatch(const base::string16& match_string, + const base::string16& inline_completion, const ACMatchClassifications& styles); Builtins builtins_; diff --git a/chrome/browser/autocomplete/builtin_provider_unittest.cc b/chrome/browser/autocomplete/builtin_provider_unittest.cc index b5693ba..5cfa008 100644 --- a/chrome/browser/autocomplete/builtin_provider_unittest.cc +++ b/chrome/browser/autocomplete/builtin_provider_unittest.cc @@ -14,6 +14,8 @@ #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" +using base::string16; + class BuiltinProviderTest : public testing::Test { protected: template<class ResultType> diff --git a/chrome/browser/autocomplete/contact_provider_chromeos.cc b/chrome/browser/autocomplete/contact_provider_chromeos.cc index afa14ba..9def30b 100644 --- a/chrome/browser/autocomplete/contact_provider_chromeos.cc +++ b/chrome/browser/autocomplete/contact_provider_chromeos.cc @@ -33,9 +33,9 @@ int kAffinityRelevanceBoost = 200; // Returns true if |word_to_find| is a prefix of |name_to_search| and marks the // matching text in |classifications| (which corresponds to the contact's full // name). |name_index_in_full_name| contains |name_to_search|'s index within -// the full name or string16::npos if it doesn't appear in it. -bool WordIsNamePrefix(const string16& word_to_find, - const string16& name_to_search, +// the full name or base::string16::npos if it doesn't appear in it. +bool WordIsNamePrefix(const base::string16& word_to_find, + const base::string16& name_to_search, size_t name_index_in_full_name, size_t full_name_length, ACMatchClassifications* classifications) { @@ -47,7 +47,7 @@ bool WordIsNamePrefix(const string16& word_to_find, name_to_search, &match_index, &match_length) || (match_index != 0)) return false; - if (name_index_in_full_name != string16::npos) { + if (name_index_in_full_name != base::string16::npos) { AutocompleteMatch::ACMatchClassifications new_class; AutocompleteMatch::ClassifyLocationInString(name_index_in_full_name, match_length, full_name_length, 0, &new_class); @@ -65,16 +65,16 @@ const char ContactProvider::kMatchContactIdKey[] = "contact_id"; // Cached information about a contact. struct ContactProvider::ContactData { - ContactData(const string16& full_name, - const string16& given_name, - const string16& family_name, + ContactData(const base::string16& full_name, + const base::string16& given_name, + const base::string16& family_name, const std::string& contact_id, float affinity) : full_name(full_name), given_name(given_name), family_name(family_name), - given_name_index(string16::npos), - family_name_index(string16::npos), + given_name_index(base::string16::npos), + family_name_index(base::string16::npos), contact_id(contact_id), affinity(affinity) { base::i18n::StringSearchIgnoringCaseAndAccents( @@ -83,12 +83,12 @@ struct ContactProvider::ContactData { family_name, full_name, &family_name_index, NULL); } - string16 full_name; - string16 given_name; - string16 family_name; + base::string16 full_name; + base::string16 given_name; + base::string16 family_name; // Indices into |full_name| where |given_name| and |family_name| first appear, - // or string16::npos if they don't appear in it. + // or base::string16::npos if they don't appear in it. size_t given_name_index; size_t family_name_index; @@ -121,7 +121,7 @@ void ContactProvider::Start(const AutocompleteInput& input, input.type() != AutocompleteInput::FORCED_QUERY) return; - std::vector<string16> input_words; + std::vector<base::string16> input_words; base::i18n::BreakIterator break_iterator( input.text(), base::i18n::BreakIterator::BREAK_WORD); @@ -171,11 +171,11 @@ void ContactProvider::RefreshContacts() { for (contacts::ContactPointers::const_iterator it = contacts->begin(); it != contacts->end(); ++it) { const contacts::Contact& contact = **it; - string16 full_name = + base::string16 full_name = AutocompleteMatch::SanitizeString(UTF8ToUTF16(contact.full_name())); - string16 given_name = + base::string16 given_name = AutocompleteMatch::SanitizeString(UTF8ToUTF16(contact.given_name())); - string16 family_name = + base::string16 family_name = AutocompleteMatch::SanitizeString(UTF8ToUTF16(contact.family_name())); float affinity = contact.has_affinity() ? contact.affinity() : kDefaultAffinity; @@ -191,7 +191,7 @@ void ContactProvider::RefreshContacts() { void ContactProvider::AddContactIfMatched( const AutocompleteInput& input, - const std::vector<string16>& input_words, + const std::vector<base::string16>& input_words, const ContactData& contact) { // First, check if the whole input string is a prefix of the full name. // TODO(derat): Consider additionally segmenting the full name so we can match @@ -209,7 +209,7 @@ void ContactProvider::AddContactIfMatched( // don't overlap (e.g. the query "bob b" against a contact with full name // "Bob G. Bryson", given name "Bob", and family name "Bryson" should result // in classifications "_Bob_ G. _B_ryson" rather than "_Bob_ G. Bryson". - for (std::vector<string16>::const_iterator it = input_words.begin(); + for (std::vector<base::string16>::const_iterator it = input_words.begin(); it != input_words.end(); ++it) { if (!WordIsNamePrefix(*it, contact.given_name, contact.given_name_index, contact.full_name.size(), &classifications) && diff --git a/chrome/browser/autocomplete/contact_provider_chromeos.h b/chrome/browser/autocomplete/contact_provider_chromeos.h index 1a14a38..9ecb9db 100644 --- a/chrome/browser/autocomplete/contact_provider_chromeos.h +++ b/chrome/browser/autocomplete/contact_provider_chromeos.h @@ -59,7 +59,7 @@ class ContactProvider : public AutocompleteProvider, // is matched by |input|. |input_words| is |input.text()| split on word // boundaries. void AddContactIfMatched(const AutocompleteInput& input, - const std::vector<string16>& input_words, + const std::vector<base::string16>& input_words, const ContactData& contact); // Returns an AutocompleteMatch object corresponding to the passed-in data. diff --git a/chrome/browser/autocomplete/contact_provider_chromeos_unittest.cc b/chrome/browser/autocomplete/contact_provider_chromeos_unittest.cc index 0978210..e3b0df8 100644 --- a/chrome/browser/autocomplete/contact_provider_chromeos_unittest.cc +++ b/chrome/browser/autocomplete/contact_provider_chromeos_unittest.cc @@ -66,8 +66,8 @@ class ContactProviderTest : public testing::Test { void StartQuery(const std::string& utf8_text) { contact_provider_->Start( AutocompleteInput(UTF8ToUTF16(utf8_text), - string16::npos, - string16(), + base::string16::npos, + base::string16(), GURL(), AutocompleteInput::INVALID_SPEC, false, diff --git a/chrome/browser/autocomplete/extension_app_provider.cc b/chrome/browser/autocomplete/extension_app_provider.cc index 176e747..e51bfbe 100644 --- a/chrome/browser/autocomplete/extension_app_provider.cc +++ b/chrome/browser/autocomplete/extension_app_provider.cc @@ -93,7 +93,7 @@ AutocompleteMatch ExtensionAppProvider::CreateAutocompleteMatch( match.relevance = CalculateRelevance( input.type(), input.text().length(), - name_match_index != string16::npos ? + name_match_index != base::string16::npos ? app.name.length() : app.launch_url.length(), match.destination_url); return match; @@ -113,25 +113,27 @@ void ExtensionAppProvider::Start(const AutocompleteInput& input, for (ExtensionApps::const_iterator app = extension_apps_.begin(); app != extension_apps_.end(); ++app) { // See if the input matches this extension application. - const string16& name = app->name; - string16::const_iterator name_iter = std::search(name.begin(), name.end(), - input.text().begin(), input.text().end(), - base::CaseInsensitiveCompare<char16>()); + const base::string16& name = app->name; + base::string16::const_iterator name_iter = + std::search(name.begin(), name.end(), + input.text().begin(), input.text().end(), + base::CaseInsensitiveCompare<char16>()); bool matches_name = name_iter != name.end(); size_t name_match_index = matches_name ? - static_cast<size_t>(name_iter - name.begin()) : string16::npos; + static_cast<size_t>(name_iter - name.begin()) : base::string16::npos; bool matches_url = false; - size_t url_match_index = string16::npos; + size_t url_match_index = base::string16::npos; if (app->should_match_against_launch_url) { - const string16& url = app->launch_url; - string16::const_iterator url_iter = std::search(url.begin(), url.end(), - input.text().begin(), input.text().end(), - base::CaseInsensitiveCompare<char16>()); + const base::string16& url = app->launch_url; + base::string16::const_iterator url_iter = + std::search(url.begin(), url.end(), + input.text().begin(), input.text().end(), + base::CaseInsensitiveCompare<char16>()); matches_url = url_iter != url.end() && input.type() != AutocompleteInput::FORCED_QUERY; url_match_index = matches_url ? - static_cast<size_t>(url_iter - url.begin()) : string16::npos; + static_cast<size_t>(url_iter - url.begin()) : base::string16::npos; } if (matches_name || matches_url) { diff --git a/chrome/browser/autocomplete/extension_app_provider.h b/chrome/browser/autocomplete/extension_app_provider.h index 8202b4a..5dbcc26 100644 --- a/chrome/browser/autocomplete/extension_app_provider.h +++ b/chrome/browser/autocomplete/extension_app_provider.h @@ -46,10 +46,10 @@ class ExtensionAppProvider : public AutocompleteProvider, // eligible apps. struct ExtensionApp { // App's name. - string16 name; + base::string16 name; // App's launch URL (for platform apps, which don't have a launch URL, this // just points to the app's origin). - string16 launch_url; + base::string16 launch_url; // If false, then the launch_url will not be considered for matching, // not shown next to the match, and not displayed as the editable text if // the user selects the match with the arrow keys. diff --git a/chrome/browser/autocomplete/extension_app_provider_unittest.cc b/chrome/browser/autocomplete/extension_app_provider_unittest.cc index d66dcf7..24e8bd7 100644 --- a/chrome/browser/autocomplete/extension_app_provider_unittest.cc +++ b/chrome/browser/autocomplete/extension_app_provider_unittest.cc @@ -17,7 +17,7 @@ class ExtensionAppProviderTest : public testing::Test { protected: struct test_data { - const string16 input; + const base::string16 input; const size_t num_results; const GURL output[3]; }; @@ -86,8 +86,9 @@ void ExtensionAppProviderTest::RunTest( int num_cases) { ACMatches matches; for (int i = 0; i < num_cases; ++i) { - AutocompleteInput input(keyword_cases[i].input, string16::npos, string16(), - GURL(), AutocompleteInput::INVALID_SPEC, true, + AutocompleteInput input(keyword_cases[i].input, base::string16::npos, + base::string16(), GURL(), + AutocompleteInput::INVALID_SPEC, true, false, true, AutocompleteInput::ALL_MATCHES); app_provider_->Start(input, false); EXPECT_TRUE(app_provider_->done()); @@ -136,10 +137,11 @@ TEST_F(ExtensionAppProviderTest, CreateMatchSanitize) { { "Test\r\t\nTest", "TestTest" }, }; - AutocompleteInput input(ASCIIToUTF16("Test"), string16::npos, string16(), - GURL(), AutocompleteInput::INVALID_SPEC, true, true, + AutocompleteInput input(ASCIIToUTF16("Test"), base::string16::npos, + base::string16(), GURL(), + AutocompleteInput::INVALID_SPEC, true, true, true, AutocompleteInput::BEST_MATCH); - string16 url(ASCIIToUTF16("http://example.com")); + base::string16 url(ASCIIToUTF16("http://example.com")); for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { ExtensionAppProvider::ExtensionApp extension_app = {ASCIIToUTF16(cases[i].name), url, true}; @@ -147,7 +149,7 @@ TEST_F(ExtensionAppProviderTest, CreateMatchSanitize) { app_provider_->CreateAutocompleteMatch(input, extension_app, 0, - string16::npos); + base::string16::npos); EXPECT_EQ(ASCIIToUTF16(cases[i].match_contents), match.contents); } } diff --git a/chrome/browser/autocomplete/history_provider.cc b/chrome/browser/autocomplete/history_provider.cc index efd6bb9..7474ce7 100644 --- a/chrome/browser/autocomplete/history_provider.cc +++ b/chrome/browser/autocomplete/history_provider.cc @@ -65,7 +65,7 @@ void HistoryProvider::DeleteMatchFromMatches(const AutocompleteMatch& match) { // static bool HistoryProvider::FixupUserInput(AutocompleteInput* input) { - const string16& input_text = input->text(); + const base::string16& input_text = input->text(); // Fixup and canonicalize user input. const GURL canonical_gurl(URLFixerUpper::FixupURL(UTF16ToUTF8(input_text), std::string())); @@ -93,7 +93,7 @@ bool HistoryProvider::FixupUserInput(AutocompleteInput* input) { canonical_gurl_str.replace(parts.host.begin, parts.host.len, original_hostname); } - string16 output = UTF8ToUTF16(canonical_gurl_str); + base::string16 output = UTF8ToUTF16(canonical_gurl_str); // Don't prepend a scheme when the user didn't have one. Since the fixer // upper only prepends the "http" scheme, that's all we need to check for. if (!AutocompleteInput::HasHTTPScheme(input_text)) @@ -115,12 +115,13 @@ bool HistoryProvider::FixupUserInput(AutocompleteInput* input) { // harm in making sure. const size_t last_input_nonslash = input_text.find_last_not_of(ASCIIToUTF16("/\\")); - const size_t num_input_slashes = (last_input_nonslash == string16::npos) ? + const size_t num_input_slashes = + (last_input_nonslash == base::string16::npos) ? input_text.length() : (input_text.length() - 1 - last_input_nonslash); const size_t last_output_nonslash = output.find_last_not_of(ASCIIToUTF16("/\\")); const size_t num_output_slashes = - (last_output_nonslash == string16::npos) ? + (last_output_nonslash == base::string16::npos) ? output.length() : (output.length() - 1 - last_output_nonslash); if (num_output_slashes < num_input_slashes) output.append(num_input_slashes - num_output_slashes, '/'); @@ -129,18 +130,18 @@ bool HistoryProvider::FixupUserInput(AutocompleteInput* input) { url_parse::Parsed parts; URLFixerUpper::SegmentURL(output, &parts); - input->UpdateText(output, string16::npos, parts); + input->UpdateText(output, base::string16::npos, parts); return !output.empty(); } // static -size_t HistoryProvider::TrimHttpPrefix(string16* url) { +size_t HistoryProvider::TrimHttpPrefix(base::string16* url) { // Find any "http:". if (!AutocompleteInput::HasHTTPScheme(*url)) return 0; size_t scheme_pos = url->find(ASCIIToUTF16(content::kHttpScheme) + char16(':')); - DCHECK_NE(string16::npos, scheme_pos); + DCHECK_NE(base::string16::npos, scheme_pos); // Erase scheme plus up to two slashes. size_t prefix_end = scheme_pos + strlen(content::kHttpScheme) + 1; diff --git a/chrome/browser/autocomplete/history_provider.h b/chrome/browser/autocomplete/history_provider.h index 9a72b86..705ab4c 100644 --- a/chrome/browser/autocomplete/history_provider.h +++ b/chrome/browser/autocomplete/history_provider.h @@ -46,7 +46,7 @@ class HistoryProvider : public AutocompleteProvider { // number of characters that were trimmed. // NOTE: For a view-source: URL, this will trim from after "view-source:" and // return 0. - static size_t TrimHttpPrefix(string16* url); + static size_t TrimHttpPrefix(base::string16* url); // Returns true if inline autocompletion should be prevented. Use this instead // of |input.prevent_inline_autocomplete| if the input is passed through diff --git a/chrome/browser/autocomplete/history_provider_util.cc b/chrome/browser/autocomplete/history_provider_util.cc index 371d7b9..439248d 100644 --- a/chrome/browser/autocomplete/history_provider_util.cc +++ b/chrome/browser/autocomplete/history_provider_util.cc @@ -10,7 +10,7 @@ namespace history { HistoryMatch::HistoryMatch() : url_info(), - input_location(string16::npos), + input_location(base::string16::npos), match_in_scheme(false), innermost_match(true), promoted(false) { diff --git a/chrome/browser/autocomplete/history_quick_provider_unittest.cc b/chrome/browser/autocomplete/history_quick_provider_unittest.cc index e33533f..d571bfa 100644 --- a/chrome/browser/autocomplete/history_quick_provider_unittest.cc +++ b/chrome/browser/autocomplete/history_quick_provider_unittest.cc @@ -132,10 +132,10 @@ class HistoryQuickProviderTest : public testing::Test, // Runs an autocomplete query on |text| and checks to see that the returned // results' destination URLs match those provided. |expected_urls| does not // need to be in sorted order. - void RunTest(const string16 text, + void RunTest(const base::string16 text, std::vector<std::string> expected_urls, bool can_inline_top_result, - string16 expected_fill_into_edit); + base::string16 expected_fill_into_edit); base::MessageLoopForUI message_loop_; content::TestBrowserThread ui_thread_; @@ -237,15 +237,15 @@ void HistoryQuickProviderTest::SetShouldContain::operator()( } -void HistoryQuickProviderTest::RunTest(const string16 text, +void HistoryQuickProviderTest::RunTest(const base::string16 text, std::vector<std::string> expected_urls, bool can_inline_top_result, - string16 expected_fill_into_edit) { + base::string16 expected_fill_into_edit) { SCOPED_TRACE(text); // Minimal hint to query being run. base::MessageLoop::current()->RunUntilIdle(); - AutocompleteInput input(text, string16::npos, string16(), GURL(), - AutocompleteInput::INVALID_SPEC, false, false, true, - AutocompleteInput::ALL_MATCHES); + AutocompleteInput input(text, base::string16::npos, base::string16(), + GURL(), AutocompleteInput::INVALID_SPEC, false, + false, true, AutocompleteInput::ALL_MATCHES); provider_->Start(input, false); EXPECT_TRUE(provider_->done()); @@ -294,7 +294,7 @@ void HistoryQuickProviderTest::RunTest(const string16 text, << "fill_into_edit was: '" << ac_matches_[0].fill_into_edit << "' but we expected '" << expected_fill_into_edit << "'."; size_t text_pos = expected_fill_into_edit.find(text); - ASSERT_NE(string16::npos, text_pos); + ASSERT_NE(base::string16::npos, text_pos); EXPECT_EQ(ac_matches_[0].fill_into_edit.substr(text_pos + text.size()), ac_matches_[0].inline_autocompletion); } else { @@ -555,7 +555,7 @@ TEST_F(HistoryQuickProviderTest, CullSearchResults) { // A search results page should not be returned when typing a query. std::vector<std::string> expected_urls; expected_urls.push_back("http://anotherengine.com/?q=thequery"); - RunTest(ASCIIToUTF16("thequery"), expected_urls, false, string16()); + RunTest(ASCIIToUTF16("thequery"), expected_urls, false, base::string16()); // A search results page should not be returned when typing the engine URL. expected_urls.clear(); diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc index 45c660b..b85e499 100644 --- a/chrome/browser/autocomplete/history_url_provider.cc +++ b/chrome/browser/autocomplete/history_url_provider.cc @@ -86,7 +86,7 @@ bool CreateOrPromoteMatch(const history::URLRow& info, // URL to just a host. If this host still matches the user input, return it. // Returns the empty string on failure. GURL ConvertToHostOnly(const history::HistoryMatch& match, - const string16& input) { + const base::string16& input) { // See if we should try to do host-only suggestions for this URL. Nonstandard // schemes means there's no authority section, so suggesting the host name // is useless. File URLs are standard, but host suggestion is not useful for @@ -101,7 +101,7 @@ GURL ConvertToHostOnly(const history::HistoryMatch& match, if ((host.spec().length() < (match.input_location + input.length()))) return GURL(); // User typing is longer than this host suggestion. - const string16 spec = UTF8ToUTF16(host.spec()); + const base::string16 spec = UTF8ToUTF16(host.spec()); if (spec.compare(match.input_location, input.length(), input)) return GURL(); // User typing is no longer a prefix. @@ -204,7 +204,7 @@ class SearchTermsDataSnapshot : public SearchTermsData { virtual std::string GoogleBaseURLValue() const OVERRIDE; virtual std::string GetApplicationLocale() const OVERRIDE; - virtual string16 GetRlzParameterValue() const OVERRIDE; + virtual base::string16 GetRlzParameterValue() const OVERRIDE; virtual std::string GetSearchClient() const OVERRIDE; virtual std::string ForceInstantResultsParam( bool for_prerender) const OVERRIDE; @@ -214,7 +214,7 @@ class SearchTermsDataSnapshot : public SearchTermsData { private: std::string google_base_url_value_; std::string application_locale_; - string16 rlz_parameter_value_; + base::string16 rlz_parameter_value_; std::string search_client_; std::string force_instant_results_param_; std::string instant_extended_enabled_param_; @@ -246,7 +246,7 @@ std::string SearchTermsDataSnapshot::GetApplicationLocale() const { return application_locale_; } -string16 SearchTermsDataSnapshot::GetRlzParameterValue() const { +base::string16 SearchTermsDataSnapshot::GetRlzParameterValue() const { return rlz_parameter_value_; } @@ -399,7 +399,7 @@ void HistoryURLProvider::Stop(bool clear_cached_results) { } AutocompleteMatch HistoryURLProvider::SuggestExactInput( - const string16& text, + const base::string16& text, const GURL& destination_url, bool trim_http) { AutocompleteMatch match(this, 0, false, @@ -415,7 +415,8 @@ AutocompleteMatch HistoryURLProvider::SuggestExactInput( // slightly different behavior as well (the latter will strip even without // two slashes after the scheme). DCHECK(!trim_http || !AutocompleteInput::HasHTTPScheme(text)); - string16 display_string(StringForURLDisplay(destination_url, false, false)); + base::string16 display_string( + StringForURLDisplay(destination_url, false, false)); const size_t offset = trim_http ? TrimHttpPrefix(&display_string) : 0; match.fill_into_edit = AutocompleteInput::FormattedStringWithEquivalentMeaning(destination_url, @@ -527,7 +528,8 @@ void HistoryURLProvider::DoAutocomplete(history::HistoryBackend* backend, for (history::URLRows::const_iterator j(url_matches.begin()); j != url_matches.end(); ++j) { const URLPrefix* best_prefix = - URLPrefix::BestURLPrefix(UTF8ToUTF16(j->url().spec()), string16()); + URLPrefix::BestURLPrefix(UTF8ToUTF16(j->url().spec()), + base::string16()); DCHECK(best_prefix != NULL); history_matches.push_back(history::HistoryMatch(*j, i->prefix.length(), i->num_components == 0, @@ -825,8 +827,8 @@ bool HistoryURLProvider::FixupExactSuggestion( return false; // Put it on the front of the HistoryMatches for redirect culling. - CreateOrPromoteMatch(classifier.url_row(), string16::npos, false, matches, - true, true); + CreateOrPromoteMatch(classifier.url_row(), base::string16::npos, false, + matches, true, true); return true; } @@ -1060,7 +1062,7 @@ AutocompleteMatch HistoryURLProvider::HistoryMatchToACMatch( net::UnescapeRule::SPACES, NULL, NULL, &inline_autocomplete_offset)); if (!params.prevent_inline_autocomplete && - (inline_autocomplete_offset != string16::npos)) { + (inline_autocomplete_offset != base::string16::npos)) { DCHECK(inline_autocomplete_offset <= match.fill_into_edit.length()); match.inline_autocompletion = match.fill_into_edit.substr(inline_autocomplete_offset); @@ -1068,21 +1070,21 @@ AutocompleteMatch HistoryURLProvider::HistoryMatchToACMatch( // The latter part of the test effectively asks "is the inline completion // empty?" (i.e., is this match effectively the what-you-typed match?). match.allowed_to_be_default_match = !params.prevent_inline_autocomplete || - ((inline_autocomplete_offset != string16::npos) && + ((inline_autocomplete_offset != base::string16::npos) && (inline_autocomplete_offset >= match.fill_into_edit.length())); size_t match_start = history_match.input_location; match.contents = net::FormatUrl(info.url(), languages, format_types, net::UnescapeRule::SPACES, NULL, NULL, &match_start); - if ((match_start != string16::npos) && - (inline_autocomplete_offset != string16::npos) && + if ((match_start != base::string16::npos) && + (inline_autocomplete_offset != base::string16::npos) && (inline_autocomplete_offset != match_start)) { DCHECK(inline_autocomplete_offset > match_start); AutocompleteMatch::ClassifyLocationInString(match_start, inline_autocomplete_offset - match_start, match.contents.length(), ACMatchClassification::URL, &match.contents_class); } else { - AutocompleteMatch::ClassifyLocationInString(string16::npos, 0, + AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, match.contents.length(), ACMatchClassification::URL, &match.contents_class); } @@ -1095,9 +1097,9 @@ AutocompleteMatch HistoryURLProvider::HistoryMatchToACMatch( // static ACMatchClassifications HistoryURLProvider::ClassifyDescription( - const string16& input_text, - const string16& description) { - string16 clean_description = history::CleanUpTitleForMatching(description); + const base::string16& input_text, + const base::string16& description) { + base::string16 clean_description = history::CleanUpTitleForMatching(description); history::TermMatches description_matches(SortAndDeoverlapMatches( history::MatchTermInString(input_text, clean_description, 0))); history::WordStarts description_word_starts; diff --git a/chrome/browser/autocomplete/history_url_provider.h b/chrome/browser/autocomplete/history_url_provider.h index 610d35b..3926e03 100644 --- a/chrome/browser/autocomplete/history_url_provider.h +++ b/chrome/browser/autocomplete/history_url_provider.h @@ -173,7 +173,7 @@ class HistoryURLProvider : public HistoryProvider { // set to true if |text| contains an http prefix. // NOTE: This does not set the relevance of the returned match, as different // callers want different behavior. Callers must set this manually. - AutocompleteMatch SuggestExactInput(const string16& text, + AutocompleteMatch SuggestExactInput(const base::string16& text, const GURL& destination_url, bool trim_http); @@ -294,8 +294,8 @@ class HistoryURLProvider : public HistoryProvider { // Returns a set of classifications that highlight all the occurrences // of |input_text| at word breaks in |description|. static ACMatchClassifications ClassifyDescription( - const string16& input_text, - const string16& description); + const base::string16& input_text, + const base::string16& description); // Params for the current query. The provider should not free this directly; // instead, it is passed as a parameter through the history backend, and the diff --git a/chrome/browser/autocomplete/search_provider.h b/chrome/browser/autocomplete/search_provider.h index 256d3f3..adf3004 100644 --- a/chrome/browser/autocomplete/search_provider.h +++ b/chrome/browser/autocomplete/search_provider.h @@ -85,14 +85,14 @@ class SearchProvider : public AutocompleteProvider, static AutocompleteMatch CreateSearchSuggestion( AutocompleteProvider* autocomplete_provider, const AutocompleteInput& input, - const string16& input_text, + const base::string16& input_text, int relevance, AutocompleteMatch::Type type, bool is_keyword, - const string16& match_contents, - const string16& annotation, + const base::string16& match_contents, + const base::string16& annotation, const TemplateURL* template_url, - const string16& query_string, + const base::string16& query_string, const std::string& suggest_query_params, int accepted_suggestion, int omnibox_start_margin, @@ -151,22 +151,22 @@ class SearchProvider : public AutocompleteProvider, // Returns true if the specified providers match the two providers cached // by this class. - bool equal(const string16& default_provider, - const string16& keyword_provider) const { + bool equal(const base::string16& default_provider, + const base::string16& keyword_provider) const { return (default_provider == default_provider_) && (keyword_provider == keyword_provider_); } // Resets the cached providers. - void set(const string16& default_provider, - const string16& keyword_provider) { + void set(const base::string16& default_provider, + const base::string16& keyword_provider) { default_provider_ = default_provider; keyword_provider_ = keyword_provider; } TemplateURLService* template_url_service() { return template_url_service_; } - const string16& default_provider() const { return default_provider_; } - const string16& keyword_provider() const { return keyword_provider_; } + const base::string16& default_provider() const { return default_provider_; } + const base::string16& keyword_provider() const { return keyword_provider_; } // NOTE: These may return NULL even if the provider members are nonempty! const TemplateURL* GetDefaultProviderURL() const; @@ -180,8 +180,8 @@ class SearchProvider : public AutocompleteProvider, // Cached across the life of a query so we behave consistently even if the // user changes their default while the query is running. - string16 default_provider_; - string16 keyword_provider_; + base::string16 default_provider_; + base::string16 keyword_provider_; DISALLOW_COPY_AND_ASSIGN(Providers); }; @@ -212,7 +212,7 @@ class SearchProvider : public AutocompleteProvider, // Returns if this result is inlineable against the current input |input|. // Non-inlineable results are stale. - virtual bool IsInlineable(const string16& input) const = 0; + virtual bool IsInlineable(const base::string16& input) const = 0; // Returns the default relevance value for this result (which may // be left over from a previous omnibox input) given the current @@ -239,9 +239,9 @@ class SearchProvider : public AutocompleteProvider, class SuggestResult : public Result { public: - SuggestResult(const string16& suggestion, - const string16& match_contents, - const string16& annotation, + SuggestResult(const base::string16& suggestion, + const base::string16& match_contents, + const base::string16& annotation, const std::string& suggest_query_params, const std::string& deletion_url, bool from_keyword_provider, @@ -250,9 +250,9 @@ class SearchProvider : public AutocompleteProvider, bool should_prefetch); virtual ~SuggestResult(); - const string16& suggestion() const { return suggestion_; } - const string16& match_contents() const { return match_contents_; } - const string16& annotation() const { return annotation_; } + const base::string16& suggestion() const { return suggestion_; } + const base::string16& match_contents() const { return match_contents_; } + const base::string16& annotation() const { return annotation_; } const std::string& suggest_query_params() const { return suggest_query_params_; } @@ -260,22 +260,22 @@ class SearchProvider : public AutocompleteProvider, bool should_prefetch() const { return should_prefetch_; } // Result: - virtual bool IsInlineable(const string16& input) const OVERRIDE; + virtual bool IsInlineable(const base::string16& input) const OVERRIDE; virtual int CalculateRelevance( const AutocompleteInput& input, bool keyword_provider_requested) const OVERRIDE; private: // The search terms to be used for this suggestion. - string16 suggestion_; + base::string16 suggestion_; // The contents to be displayed in the autocomplete match. - string16 match_contents_; + base::string16 match_contents_; // Optional annotation for the |match_contents_| for disambiguation. // This may be displayed in the autocomplete match contents, but is defined // separately to facilitate different formatting. - string16 annotation_; + base::string16 annotation_; // Optional additional parameters to be added to the search URL. std::string suggest_query_params_; @@ -295,18 +295,18 @@ class SearchProvider : public AutocompleteProvider, // compute |formatted_url_|. NavigationResult(const AutocompleteProvider& provider, const GURL& url, - const string16& description, + const base::string16& description, bool from_keyword_provider, int relevance, bool relevance_from_server); virtual ~NavigationResult(); const GURL& url() const { return url_; } - const string16& description() const { return description_; } - const string16& formatted_url() const { return formatted_url_; } + const base::string16& description() const { return description_; } + const base::string16& formatted_url() const { return formatted_url_; } // Result: - virtual bool IsInlineable(const string16& input) const OVERRIDE; + virtual bool IsInlineable(const base::string16& input) const OVERRIDE; virtual int CalculateRelevance( const AutocompleteInput& input, bool keyword_provider_requested) const OVERRIDE; @@ -317,10 +317,10 @@ class SearchProvider : public AutocompleteProvider, // The properly formatted ("fixed up") URL string with equivalent meaning // to the one in |url_|. - string16 formatted_url_; + base::string16 formatted_url_; // The suggested navigational result description; generally the site name. - string16 description_; + base::string16 description_; }; class CompareScoredResults; @@ -369,7 +369,7 @@ class SearchProvider : public AutocompleteProvider, // Removes non-inlineable results until either the top result can inline // autocomplete the current input or verbatim outscores the top result. - static void RemoveStaleResults(const string16& input, + static void RemoveStaleResults(const base::string16& input, int verbatim_relevance, SuggestResults* suggest_results, NavigationResults* navigation_results); @@ -493,7 +493,7 @@ class SearchProvider : public AutocompleteProvider, SuggestResults ScoreHistoryResults(const HistoryResults& results, bool base_prevent_inline_autocomplete, bool input_multiple_words, - const string16& input_text, + const base::string16& input_text, bool is_keyword); // Adds matches for |results| to |map|. @@ -540,16 +540,16 @@ class SearchProvider : public AutocompleteProvider, // Creates an AutocompleteMatch for "Search <engine> for |query_string|" with // the supplied relevance. Adds this match to |map|; if such a match already // exists, whichever one has lower relevance is eliminated. - void AddMatchToMap(const string16& input_text, + void AddMatchToMap(const base::string16& input_text, int relevance, bool relevance_from_server, bool should_prefetch, const std::string& metadata, AutocompleteMatch::Type type, bool is_keyword, - const string16& match_contents, - const string16& annotation, - const string16& query_string, + const base::string16& match_contents, + const base::string16& annotation, + const base::string16& query_string, int accepted_suggestion, const std::string& suggest_query_params, const std::string& deletion_url, diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc index 7a13b44b..f064792 100644 --- a/chrome/browser/autocomplete/search_provider_unittest.cc +++ b/chrome/browser/autocomplete/search_provider_unittest.cc @@ -109,7 +109,7 @@ class SearchProviderTest : public testing::Test, ResultInfo(GURL gurl, AutocompleteMatch::Type result_type, bool allowed_to_be_default_match, - string16 fill_into_edit) + base::string16 fill_into_edit) : gurl(gurl), result_type(result_type), allowed_to_be_default_match(allowed_to_be_default_match), @@ -119,11 +119,11 @@ class SearchProviderTest : public testing::Test, const GURL gurl; const AutocompleteMatch::Type result_type; const bool allowed_to_be_default_match; - const string16 fill_into_edit; + const base::string16 fill_into_edit; }; struct TestData { - const string16 input; + const base::string16 input; const size_t num_results; const ResultInfo output[3]; }; @@ -152,11 +152,11 @@ class SearchProviderTest : public testing::Test, // Adds a search for |term|, using the engine |t_url| to the history, and // returns the URL for that search. - GURL AddSearchToHistory(TemplateURL* t_url, string16 term, int visit_count); + GURL AddSearchToHistory(TemplateURL* t_url, base::string16 term, int visit_count); // Looks for a match in |provider_| with |contents| equal to |contents|. // Sets |match| to it if found. Returns whether |match| was set. - bool FindMatchWithContents(const string16& contents, + bool FindMatchWithContents(const base::string16& contents, AutocompleteMatch* match); // Looks for a match in |provider_| with destination |url|. Sets |match| to @@ -172,13 +172,13 @@ class SearchProviderTest : public testing::Test, void RunTillProviderDone(); // Invokes Start on provider_, then runs all pending tasks. - void QueryForInput(const string16& text, + void QueryForInput(const base::string16& text, bool prevent_inline_autocomplete, bool prefer_keyword); // Calls QueryForInput(), finishes any suggest query, then if |wyt_match| is // non-NULL, sets it to the "what you typed" entry for |text|. - void QueryForInputAndSetWYTMatch(const string16& text, + void QueryForInputAndSetWYTMatch(const base::string16& text, AutocompleteMatch* wyt_match); // Notifies the URLFetcher for the suggest query corresponding to the default @@ -202,10 +202,10 @@ class SearchProviderTest : public testing::Test, // See description above class for details of these fields. TemplateURL* default_t_url_; - const string16 term1_; + const base::string16 term1_; GURL term1_url_; TemplateURL* keyword_t_url_; - const string16 keyword_term_; + const base::string16 keyword_term_; GURL keyword_url_; content::TestBrowserThreadBundle thread_bundle_; @@ -291,13 +291,13 @@ void SearchProviderTest::RunTest(TestData* cases, bool prefer_keyword) { ACMatches matches; for (int i = 0; i < num_cases; ++i) { - AutocompleteInput input(cases[i].input, string16::npos, string16(), GURL(), + AutocompleteInput input(cases[i].input, base::string16::npos, base::string16(), GURL(), AutocompleteInput::INVALID_SPEC, false, prefer_keyword, true, AutocompleteInput::ALL_MATCHES); provider_->Start(input, false); matches = provider_->matches(); - string16 diagnostic_details = ASCIIToUTF16("Input was: ") + cases[i].input + + base::string16 diagnostic_details = ASCIIToUTF16("Input was: ") + cases[i].input + ASCIIToUTF16("; prefer_keyword was: ") + (prefer_keyword ? ASCIIToUTF16("true") : ASCIIToUTF16("false")); EXPECT_EQ(cases[i].num_results, matches.size()) << diagnostic_details; @@ -332,11 +332,11 @@ void SearchProviderTest::RunTillProviderDone() { run_loop.Run(); } -void SearchProviderTest::QueryForInput(const string16& text, +void SearchProviderTest::QueryForInput(const base::string16& text, bool prevent_inline_autocomplete, bool prefer_keyword) { // Start a query. - AutocompleteInput input(text, string16::npos, string16(), GURL(), + AutocompleteInput input(text, base::string16::npos, base::string16(), GURL(), AutocompleteInput::INVALID_SPEC, prevent_inline_autocomplete, prefer_keyword, true, AutocompleteInput::ALL_MATCHES); @@ -348,7 +348,7 @@ void SearchProviderTest::QueryForInput(const string16& text, } void SearchProviderTest::QueryForInputAndSetWYTMatch( - const string16& text, + const base::string16& text, AutocompleteMatch* wyt_match) { QueryForInput(text, false, false); profile_.BlockUntilHistoryProcessesPendingRequests(); @@ -363,7 +363,7 @@ void SearchProviderTest::QueryForInputAndSetWYTMatch( } GURL SearchProviderTest::AddSearchToHistory(TemplateURL* t_url, - string16 term, + base::string16 term, int visit_count) { HistoryService* history = HistoryServiceFactory::GetForProfile(&profile_, @@ -373,13 +373,13 @@ GURL SearchProviderTest::AddSearchToHistory(TemplateURL* t_url, static base::Time last_added_time; last_added_time = std::max(base::Time::Now(), last_added_time + base::TimeDelta::FromMicroseconds(1)); - history->AddPageWithDetails(search, string16(), visit_count, visit_count, + history->AddPageWithDetails(search, base::string16(), visit_count, visit_count, last_added_time, false, history::SOURCE_BROWSED); history->SetKeywordSearchTermsForURL(search, t_url->id(), term); return search; } -bool SearchProviderTest::FindMatchWithContents(const string16& contents, +bool SearchProviderTest::FindMatchWithContents(const base::string16& contents, AutocompleteMatch* match) { for (ACMatches::const_iterator i = provider_->matches().begin(); i != provider_->matches().end(); ++i) { @@ -464,7 +464,7 @@ void SearchProviderTest::ClearAllResults() { // Make sure we query history for the default provider and a URLFetcher is // created for the default provider suggest results. TEST_F(SearchProviderTest, QueryDefaultProvider) { - string16 term = term1_.substr(0, term1_.length() - 1); + base::string16 term = term1_.substr(0, term1_.length() - 1); QueryForInput(term, false, false); // Make sure the default providers suggest service was queried. @@ -507,7 +507,7 @@ TEST_F(SearchProviderTest, QueryDefaultProvider) { } TEST_F(SearchProviderTest, HonorPreventInlineAutocomplete) { - string16 term = term1_.substr(0, term1_.length() - 1); + base::string16 term = term1_.substr(0, term1_.length() - 1); QueryForInput(term, true, false); ASSERT_FALSE(provider_->matches().empty()); @@ -519,7 +519,7 @@ TEST_F(SearchProviderTest, HonorPreventInlineAutocomplete) { // Issues a query that matches the registered keyword and makes sure history // is queried as well as URLFetchers getting created. TEST_F(SearchProviderTest, QueryKeywordProvider) { - string16 term = keyword_term_.substr(0, keyword_term_.length() - 1); + base::string16 term = keyword_term_.substr(0, keyword_term_.length() - 1); QueryForInput(keyword_t_url_->keyword() + ASCIIToUTF16(" ") + term, false, false); @@ -625,7 +625,7 @@ TEST_F(SearchProviderTest, DontAutocompleteURLLikeTerms) { // Add the term as a url. HistoryServiceFactory::GetForProfile(&profile_, Profile::EXPLICIT_ACCESS)-> - AddPageWithDetails(GURL("http://docs.google.com"), string16(), 1, 1, + AddPageWithDetails(GURL("http://docs.google.com"), base::string16(), 1, 1, base::Time::Now(), false, history::SOURCE_BROWSED); profile_.BlockUntilHistoryProcessesPendingRequests(); @@ -857,7 +857,7 @@ TEST_F(SearchProviderTest, KeywordOrderingAndDescriptions) { AutocompleteController controller(&profile_, NULL, AutocompleteProvider::TYPE_SEARCH); controller.Start(AutocompleteInput( - ASCIIToUTF16("k t"), string16::npos, string16(), GURL(), + ASCIIToUTF16("k t"), base::string16::npos, base::string16(), GURL(), AutocompleteInput::INVALID_SPEC, false, false, true, AutocompleteInput::ALL_MATCHES)); const AutocompleteResult& result = controller.result(); @@ -2642,13 +2642,13 @@ TEST_F(SearchProviderTest, LocalAndRemoteRelevances) { // We hardcode the string "term1" below, so ensure that the search term that // got added to history already is that string. ASSERT_EQ(ASCIIToUTF16("term1"), term1_); - string16 term = term1_.substr(0, term1_.length() - 1); + base::string16 term = term1_.substr(0, term1_.length() - 1); AddSearchToHistory(default_t_url_, term + ASCIIToUTF16("2"), 2); profile_.BlockUntilHistoryProcessesPendingRequests(); struct { - const string16 input; + const base::string16 input; const std::string json; const std::string matches[6]; } cases[] = { @@ -3177,7 +3177,7 @@ TEST_F(SearchProviderTest, NavigationInline) { QueryForInput(ASCIIToUTF16(cases[i].input), false, false); AutocompleteMatch match( provider_->NavigationToMatch(SearchProvider::NavigationResult( - *provider_.get(), GURL(cases[i].url), string16(), false, 0, + *provider_.get(), GURL(cases[i].url), base::string16(), false, 0, false))); EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), match.inline_autocompletion); @@ -3189,10 +3189,10 @@ TEST_F(SearchProviderTest, NavigationInline) { // Verifies that "http://" is not trimmed for input that is a leading substring. TEST_F(SearchProviderTest, NavigationInlineSchemeSubstring) { - const string16 input(ASCIIToUTF16("ht")); - const string16 url(ASCIIToUTF16("http://a.com")); + const base::string16 input(ASCIIToUTF16("ht")); + const base::string16 url(ASCIIToUTF16("http://a.com")); const SearchProvider::NavigationResult result( - *provider_.get(), GURL(url), string16(), false, 0, false); + *provider_.get(), GURL(url), base::string16(), false, 0, false); // Check the offset and strings when inline autocompletion is allowed. QueryForInput(input, false, false); @@ -3216,7 +3216,7 @@ TEST_F(SearchProviderTest, NavigationInlineDomainClassify) { QueryForInput(ASCIIToUTF16("w"), false, false); AutocompleteMatch match( provider_->NavigationToMatch(SearchProvider::NavigationResult( - *provider_.get(), GURL("http://www.wow.com"), string16(), false, 0, + *provider_.get(), GURL("http://www.wow.com"), base::string16(), false, 0, false))); EXPECT_EQ(ASCIIToUTF16("ow.com"), match.inline_autocompletion); EXPECT_TRUE(match.allowed_to_be_default_match); @@ -3379,12 +3379,12 @@ TEST_F(SearchProviderTest, RemoveStaleResultsTest) { if (cases[i].results[j].is_navigation_result) { provider_->default_results_.navigation_results.push_back( SearchProvider::NavigationResult( - *provider_.get(), GURL(suggestion), string16(), false, + *provider_.get(), GURL(suggestion), base::string16(), false, cases[i].results[j].relevance, false)); } else { provider_->default_results_.suggest_results.push_back( - SearchProvider::SuggestResult(ASCIIToUTF16(suggestion), string16(), - string16(), std::string(), + SearchProvider::SuggestResult(ASCIIToUTF16(suggestion), base::string16(), + base::string16(), std::string(), std::string(), false, cases[i].results[j].relevance, false, false)); @@ -3392,7 +3392,7 @@ TEST_F(SearchProviderTest, RemoveStaleResultsTest) { } provider_->input_ = AutocompleteInput( - ASCIIToUTF16(cases[i].omnibox_input), string16::npos, string16(), + ASCIIToUTF16(cases[i].omnibox_input), base::string16::npos, base::string16(), GURL(), AutocompleteInput::INVALID_SPEC, false, false, true, AutocompleteInput::ALL_MATCHES); provider_->RemoveAllStaleResults(); @@ -3972,7 +3972,7 @@ TEST_F(SearchProviderTest, ParseDeletionUrl) { TEST_F(SearchProviderTest, ReflectsBookmarkBarState) { profile_.GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, false); - string16 term = term1_.substr(0, term1_.length() - 1); + base::string16 term = term1_.substr(0, term1_.length() - 1); QueryForInput(term, true, false); ASSERT_FALSE(provider_->matches().empty()); EXPECT_EQ(AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, diff --git a/chrome/browser/autocomplete/shortcuts_provider.cc b/chrome/browser/autocomplete/shortcuts_provider.cc index f28b1fc..b973edf 100644 --- a/chrome/browser/autocomplete/shortcuts_provider.cc +++ b/chrome/browser/autocomplete/shortcuts_provider.cc @@ -134,7 +134,7 @@ void ShortcutsProvider::GetMatches(const AutocompleteInput& input) { return; // Get the URLs from the shortcuts database with keys that partially or // completely match the search term. - string16 term_string(base::i18n::ToLower(input.text())); + base::string16 term_string(base::i18n::ToLower(input.text())); DCHECK(!term_string.empty()); int max_relevance; @@ -183,7 +183,7 @@ void ShortcutsProvider::GetMatches(const AutocompleteInput& input) { AutocompleteMatch ShortcutsProvider::ShortcutToACMatch( int relevance, - const string16& term_string, + const base::string16& term_string, const history::ShortcutsBackend::Shortcut& shortcut) { DCHECK(!term_string.empty()); AutocompleteMatch match(shortcut.match_core.ToMatch()); @@ -209,7 +209,7 @@ AutocompleteMatch ShortcutsProvider::ShortcutToACMatch( // static ShortcutsProvider::WordMap ShortcutsProvider::CreateWordMapForString( - const string16& text) { + const base::string16& text) { // First, convert |text| to a vector of the unique words in it. WordMap word_map; base::i18n::BreakIterator word_iter(text, @@ -240,9 +240,9 @@ ShortcutsProvider::WordMap ShortcutsProvider::CreateWordMapForString( // static ACMatchClassifications ShortcutsProvider::ClassifyAllMatchesInString( - const string16& find_text, + const base::string16& find_text, const WordMap& find_words, - const string16& text, + const base::string16& text, const ACMatchClassifications& original_class) { DCHECK(!find_text.empty()); DCHECK(!find_words.empty()); @@ -256,7 +256,7 @@ ACMatchClassifications ShortcutsProvider::ClassifyAllMatchesInString( // First check whether |text| begins with |find_text| and mark that whole // section as a match if so. - string16 text_lowercase(base::i18n::ToLower(text)); + base::string16 text_lowercase(base::i18n::ToLower(text)); ACMatchClassifications match_class; size_t last_position = 0; if (StartsWith(text_lowercase, find_text, true)) { @@ -290,7 +290,7 @@ ACMatchClassifications ShortcutsProvider::ClassifyAllMatchesInString( find_words.equal_range(text_lowercase[last_position])); size_t next_character = last_position + 1; for (WordMap::const_iterator i(range.first); i != range.second; ++i) { - const string16& word = i->second; + const base::string16& word = i->second; size_t word_end = last_position + word.length(); if ((word_end <= text_lowercase.length()) && !text_lowercase.compare(last_position, word.length(), word)) { @@ -315,7 +315,7 @@ ACMatchClassifications ShortcutsProvider::ClassifyAllMatchesInString( } history::ShortcutsBackend::ShortcutMap::const_iterator - ShortcutsProvider::FindFirstMatch(const string16& keyword, + ShortcutsProvider::FindFirstMatch(const base::string16& keyword, history::ShortcutsBackend* backend) { DCHECK(backend); history::ShortcutsBackend::ShortcutMap::const_iterator it = @@ -328,7 +328,7 @@ history::ShortcutsBackend::ShortcutMap::const_iterator } int ShortcutsProvider::CalculateScore( - const string16& terms, + const base::string16& terms, const history::ShortcutsBackend::Shortcut& shortcut, int max_relevance) { DCHECK(!terms.empty()); diff --git a/chrome/browser/autocomplete/shortcuts_provider.h b/chrome/browser/autocomplete/shortcuts_provider.h index fd56522..27f9d7f 100644 --- a/chrome/browser/autocomplete/shortcuts_provider.h +++ b/chrome/browser/autocomplete/shortcuts_provider.h @@ -40,7 +40,7 @@ class ShortcutsProvider friend class ClassifyTest; friend class history::ShortcutsProviderTest; - typedef std::multimap<char16, string16> WordMap; + typedef std::multimap<char16, base::string16> WordMap; virtual ~ShortcutsProvider(); @@ -52,14 +52,14 @@ class ShortcutsProvider AutocompleteMatch ShortcutToACMatch( int relevance, - const string16& terms, + const base::string16& terms, const history::ShortcutsBackend::Shortcut& shortcut); // Returns a map mapping characters to groups of words from |text| that start // with those characters, ordered lexicographically descending so that longer // words appear before their prefixes (if any) within a particular // equal_range(). - static WordMap CreateWordMapForString(const string16& text); + static WordMap CreateWordMapForString(const base::string16& text); // Given |text| and a corresponding base set of classifications // |original_class|, adds ACMatchClassification::MATCH markers for all @@ -82,19 +82,19 @@ class ShortcutsProvider // |find_text| (and thus |find_words|) are expected to be lowercase. |text| // will be lowercased in this function. static ACMatchClassifications ClassifyAllMatchesInString( - const string16& find_text, + const base::string16& find_text, const WordMap& find_words, - const string16& text, + const base::string16& text, const ACMatchClassifications& original_class); // Returns iterator to first item in |shortcuts_map_| matching |keyword|. // Returns shortcuts_map_.end() if there are no matches. history::ShortcutsBackend::ShortcutMap::const_iterator FindFirstMatch( - const string16& keyword, + const base::string16& keyword, history::ShortcutsBackend* backend); int CalculateScore( - const string16& terms, + const base::string16& terms, const history::ShortcutsBackend::Shortcut& shortcut, int max_relevance); diff --git a/chrome/browser/autocomplete/shortcuts_provider_unittest.cc b/chrome/browser/autocomplete/shortcuts_provider_unittest.cc index 3e9513d..889d521 100644 --- a/chrome/browser/autocomplete/shortcuts_provider_unittest.cc +++ b/chrome/browser/autocomplete/shortcuts_provider_unittest.cc @@ -155,17 +155,17 @@ struct TestShortcutInfo { // convenient. class ClassifyTest { public: - ClassifyTest(const string16& text, ACMatchClassifications matches); + ClassifyTest(const base::string16& text, ACMatchClassifications matches); ~ClassifyTest(); - ACMatchClassifications RunTest(const string16& find_text); + ACMatchClassifications RunTest(const base::string16& find_text); private: - const string16 text_; + const base::string16 text_; const ACMatchClassifications matches_; }; -ClassifyTest::ClassifyTest(const string16& text, ACMatchClassifications matches) +ClassifyTest::ClassifyTest(const base::string16& text, ACMatchClassifications matches) : text_(text), matches_(matches) { } @@ -173,7 +173,7 @@ ClassifyTest::ClassifyTest(const string16& text, ACMatchClassifications matches) ClassifyTest::~ClassifyTest() { } -ACMatchClassifications ClassifyTest::RunTest(const string16& find_text) { +ACMatchClassifications ClassifyTest::RunTest(const base::string16& find_text) { return ShortcutsProvider::ClassifyAllMatchesInString(find_text, ShortcutsProvider::CreateWordMapForString(find_text), text_, matches_); } @@ -215,7 +215,7 @@ class ShortcutsProviderTest : public testing::Test, // Runs an autocomplete query on |text| and checks to see that the returned // results' destination URLs match those provided. |expected_urls| does not // need to be in sorted order. - void RunTest(const string16 text, + void RunTest(const base::string16 text, const URLs& expected_urls, std::string expected_top_result); @@ -293,11 +293,11 @@ void ShortcutsProviderTest::SetShouldContain::operator()( EXPECT_EQ(1U, matches_.erase(expected)); } -void ShortcutsProviderTest::RunTest(const string16 text, +void ShortcutsProviderTest::RunTest(const base::string16 text, const URLs& expected_urls, std::string expected_top_result) { base::MessageLoop::current()->RunUntilIdle(); - AutocompleteInput input(text, string16::npos, string16(), GURL(), + AutocompleteInput input(text, base::string16::npos, base::string16(), GURL(), AutocompleteInput::INVALID_SPEC, false, false, true, AutocompleteInput::ALL_MATCHES); provider_->Start(input, false); @@ -345,7 +345,7 @@ int ShortcutsProviderTest::CalculateScore( // Actual tests --------------------------------------------------------------- TEST_F(ShortcutsProviderTest, SimpleSingleMatch) { - string16 text(ASCIIToUTF16("go")); + base::string16 text(ASCIIToUTF16("go")); std::string expected_url("http://www.google.com/"); URLs expected_urls; expected_urls.push_back(expected_url); @@ -353,7 +353,7 @@ TEST_F(ShortcutsProviderTest, SimpleSingleMatch) { } TEST_F(ShortcutsProviderTest, MultiMatch) { - string16 text(ASCIIToUTF16("NEWS")); + base::string16 text(ASCIIToUTF16("NEWS")); URLs expected_urls; // Scores high because of completion length. expected_urls.push_back("http://slashdot.org/"); @@ -366,7 +366,7 @@ TEST_F(ShortcutsProviderTest, MultiMatch) { } TEST_F(ShortcutsProviderTest, TypedCountMatches) { - string16 text(ASCIIToUTF16("just")); + base::string16 text(ASCIIToUTF16("just")); URLs expected_urls; expected_urls.push_back("http://www.testsite.com/b.html"); expected_urls.push_back("http://www.testsite.com/a.html"); @@ -375,7 +375,7 @@ TEST_F(ShortcutsProviderTest, TypedCountMatches) { } TEST_F(ShortcutsProviderTest, FragmentLengthMatches) { - string16 text(ASCIIToUTF16("just a")); + base::string16 text(ASCIIToUTF16("just a")); URLs expected_urls; expected_urls.push_back("http://www.testsite.com/d.html"); expected_urls.push_back("http://www.testsite.com/e.html"); @@ -384,7 +384,7 @@ TEST_F(ShortcutsProviderTest, FragmentLengthMatches) { } TEST_F(ShortcutsProviderTest, DaysAgoMatches) { - string16 text(ASCIIToUTF16("ago")); + base::string16 text(ASCIIToUTF16("ago")); URLs expected_urls; expected_urls.push_back("http://www.daysagotest.com/a.html"); expected_urls.push_back("http://www.daysagotest.com/b.html"); @@ -496,7 +496,7 @@ TEST_F(ShortcutsProviderTest, CalculateScore) { ASCIIToUTF16("A test"), AutocompleteMatch::ClassificationsFromString("0,0,2,2"), content::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, - string16()), + base::string16()), base::Time::Now(), 1); // Maximal score. @@ -601,7 +601,7 @@ TEST_F(ShortcutsProviderTest, DeleteMatch) { TEST_F(ShortcutsProviderTest, Extension) { // Try an input string that matches an extension URL. - string16 text(ASCIIToUTF16("echo")); + base::string16 text(ASCIIToUTF16("echo")); std::string expected_url( "chrome-extension://cedabbhfglmiikkmdgcpjdkocfcmbkee/?q=echo"); URLs expected_urls; diff --git a/chrome/browser/autocomplete/url_prefix.cc b/chrome/browser/autocomplete/url_prefix.cc index 9174bd56..d48ee35 100644 --- a/chrome/browser/autocomplete/url_prefix.cc +++ b/chrome/browser/autocomplete/url_prefix.cc @@ -8,7 +8,7 @@ #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" -URLPrefix::URLPrefix(const string16& prefix, size_t num_components) +URLPrefix::URLPrefix(const base::string16& prefix, size_t num_components) : prefix(prefix), num_components(num_components) { } @@ -30,7 +30,7 @@ const URLPrefixes& URLPrefix::GetURLPrefixes() { } // static -bool URLPrefix::IsURLPrefix(const string16& prefix) { +bool URLPrefix::IsURLPrefix(const base::string16& prefix) { const URLPrefixes& list = GetURLPrefixes(); for (URLPrefixes::const_iterator i = list.begin(); i != list.end(); ++i) if (i->prefix == prefix) @@ -39,8 +39,8 @@ bool URLPrefix::IsURLPrefix(const string16& prefix) { } // static -const URLPrefix* URLPrefix::BestURLPrefix(const string16& text, - const string16& prefix_suffix) { +const URLPrefix* URLPrefix::BestURLPrefix(const base::string16& text, + const base::string16& prefix_suffix) { const URLPrefixes& list = GetURLPrefixes(); for (URLPrefixes::const_iterator i = list.begin(); i != list.end(); ++i) if (StartsWith(text, i->prefix + prefix_suffix, false)) diff --git a/chrome/browser/autocomplete/url_prefix.h b/chrome/browser/autocomplete/url_prefix.h index a893f3a..962e73e 100644 --- a/chrome/browser/autocomplete/url_prefix.h +++ b/chrome/browser/autocomplete/url_prefix.h @@ -15,22 +15,22 @@ typedef std::vector<URLPrefix> URLPrefixes; // A URL prefix; combinations of schemes and (least significant) domain labels // that may be inferred from certain URL-like input strings. struct URLPrefix { - URLPrefix(const string16& prefix, size_t num_components); + URLPrefix(const base::string16& prefix, size_t num_components); // Returns a vector of URL prefixes sorted by descending number of components. static const URLPrefixes& GetURLPrefixes(); // Returns if the argument is a valid URL prefix. - static bool IsURLPrefix(const string16& prefix); + static bool IsURLPrefix(const base::string16& prefix); // Returns the URL prefix of |text| with the most components, or NULL. // |prefix_suffix| (which may be empty) is appended to every attempted prefix, // which is useful for finding the innermost match of user input in a URL. // Performs case insensitive string comparison. - static const URLPrefix* BestURLPrefix(const string16& text, - const string16& prefix_suffix); + static const URLPrefix* BestURLPrefix(const base::string16& text, + const base::string16& prefix_suffix); - string16 prefix; + base::string16 prefix; // The number of URL components (scheme, domain label, etc.) in the prefix. // For example, "http://foo.com" and "www.bar.com" each have one component, diff --git a/chrome/browser/autocomplete/zero_suggest_provider.cc b/chrome/browser/autocomplete/zero_suggest_provider.cc index 0d73acc..8366ab9 100644 --- a/chrome/browser/autocomplete/zero_suggest_provider.cc +++ b/chrome/browser/autocomplete/zero_suggest_provider.cc @@ -147,7 +147,7 @@ void ZeroSuggestProvider::OnURLFetchComplete(const net::URLFetcher* source) { void ZeroSuggestProvider::StartZeroSuggest( const GURL& current_page_url, AutocompleteInput::PageClassification page_classification, - const string16& permanent_text) { + const base::string16& permanent_text) { Stop(true); field_trial_triggered_ = false; field_trial_triggered_in_session_ = false; @@ -160,7 +160,7 @@ void ZeroSuggestProvider::StartZeroSuggest( template_url_service_->GetDefaultSearchProvider(); if (default_provider == NULL) return; - string16 prefix; + base::string16 prefix; TemplateURLRef::SearchTermsArgs search_term_args(prefix); search_term_args.current_page_url = current_query_; GURL suggest_url(default_provider->suggestions_url_ref(). @@ -200,7 +200,7 @@ void ZeroSuggestProvider::FillResults( int* verbatim_relevance, SearchProvider::SuggestResults* suggest_results, SearchProvider::NavigationResults* navigation_results) { - string16 query; + base::string16 query; const ListValue* root_list = NULL; const ListValue* results = NULL; const ListValue* relevances = NULL; @@ -242,7 +242,7 @@ void ZeroSuggestProvider::FillResults( suggest_results->clear(); navigation_results->clear(); - string16 result, title; + base::string16 result, title; std::string type; for (size_t index = 0; results->GetString(index, &result); ++index) { // Google search may return empty suggestions for weird input characters, @@ -266,7 +266,7 @@ void ZeroSuggestProvider::FillResults( } } else { suggest_results->push_back(SearchProvider::SuggestResult( - result, result, string16(), std::string(), std::string(), false, + result, result, base::string16(), std::string(), std::string(), false, relevance, relevances != NULL, false)); } } @@ -285,7 +285,7 @@ void ZeroSuggestProvider::AddSuggestResultsToMap( void ZeroSuggestProvider::AddMatchToMap(int relevance, AutocompleteMatch::Type type, const TemplateURL* template_url, - const string16& query_string, + const base::string16& query_string, int accepted_suggestion, SearchProvider::MatchMap* map) { // Pass in query_string as the input_text since we don't want any bolding. @@ -293,7 +293,7 @@ void ZeroSuggestProvider::AddMatchToMap(int relevance, // of passing in -1. AutocompleteMatch match = SearchProvider::CreateSearchSuggestion( this, AutocompleteInput(), query_string, relevance, type, false, - query_string, string16(), template_url, query_string, std::string(), + query_string, base::string16(), template_url, query_string, std::string(), accepted_suggestion, -1, true); if (!match.destination_url.is_valid()) return; @@ -443,7 +443,7 @@ void ZeroSuggestProvider::ConvertResultsToAutocompleteMatches() { } AutocompleteMatch ZeroSuggestProvider::MatchForCurrentURL() { - AutocompleteInput input(permanent_text_, string16::npos, string16(), + AutocompleteInput input(permanent_text_, base::string16::npos, base::string16(), GURL(current_query_), current_page_classification_, false, false, true, AutocompleteInput::ALL_MATCHES); diff --git a/chrome/browser/autocomplete/zero_suggest_provider.h b/chrome/browser/autocomplete/zero_suggest_provider.h index 5fb9bec..41d6b04 100644 --- a/chrome/browser/autocomplete/zero_suggest_provider.h +++ b/chrome/browser/autocomplete/zero_suggest_provider.h @@ -76,7 +76,7 @@ class ZeroSuggestProvider : public AutocompleteProvider, void StartZeroSuggest( const GURL& curent_page_url, AutocompleteInput::PageClassification page_classification, - const string16& permanent_text); + const base::string16& permanent_text); bool field_trial_triggered_in_session() const { return field_trial_triggered_in_session_; @@ -117,7 +117,7 @@ class ZeroSuggestProvider : public AutocompleteProvider, void AddMatchToMap(int relevance, AutocompleteMatch::Type type, const TemplateURL* template_url, - const string16& query_string, + const base::string16& query_string, int accepted_suggestion, SearchProvider::MatchMap* map); @@ -157,7 +157,7 @@ class ZeroSuggestProvider : public AutocompleteProvider, AutocompleteInput::PageClassification current_page_classification_; // Copy of OmniboxEditModel::permanent_text_. - string16 permanent_text_; + base::string16 permanent_text_; // Fetcher used to retrieve results. scoped_ptr<net::URLFetcher> fetcher_; |