Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: components/omnibox/autocomplete_match.cc

Issue 1155673002: Omnibox - Add About Flag to Reverse Title and URLs in the Dropdown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove extra blank line Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/omnibox/autocomplete_match.h" 5 #include "components/omnibox/autocomplete_match.h"
6 6
7 #include "base/command_line.h"
7 #include "base/i18n/time_formatting.h" 8 #include "base/i18n/time_formatting.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
9 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
10 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_piece.h" 12 #include "base/strings/string_piece.h"
12 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "components/omnibox/autocomplete_provider.h" 16 #include "components/omnibox/autocomplete_provider.h"
17 #include "components/omnibox/omnibox_switches.h"
16 #include "components/omnibox/suggestion_answer.h" 18 #include "components/omnibox/suggestion_answer.h"
17 #include "components/search_engines/template_url.h" 19 #include "components/search_engines/template_url.h"
18 #include "components/search_engines/template_url_service.h" 20 #include "components/search_engines/template_url_service.h"
19 #include "grit/components_scaled_resources.h" 21 #include "grit/components_scaled_resources.h"
20 22
21 namespace { 23 namespace {
22 24
23 bool IsTrivialClassification(const ACMatchClassifications& classifications) { 25 bool IsTrivialClassification(const ACMatchClassifications& classifications) {
24 return classifications.empty() || 26 return classifications.empty() ||
25 ((classifications.size() == 1) && 27 ((classifications.size() == 1) &&
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 return true; 521 return true;
520 522
521 for (ACMatches::const_iterator it(duplicate_matches.begin()); 523 for (ACMatches::const_iterator it(duplicate_matches.begin());
522 it != duplicate_matches.end(); ++it) { 524 it != duplicate_matches.end(); ++it) {
523 if (it->deletable) 525 if (it->deletable)
524 return true; 526 return true;
525 } 527 }
526 return false; 528 return false;
527 } 529 }
528 530
531 void AutocompleteMatch::PossiblySwapContentsAndDescriptionForURLSuggestion(
532 const AutocompleteInput& input) {
533 // For URL suggestions, swap contents and description on query-type inputs
534 // if legal (under the constraint that contents must be non-empty) and
535 // we're supposed to (due to about:flags).
Peter Kasting 2015/05/21 21:55:33 Nit: I think this comment just restates the (fairl
Mark P 2015/05/22 22:51:29 Okay, removed. I only added the comment because I
536 if (!IsSearchType(type) && !description.empty() &&
537 base::CommandLine::ForCurrentProcess()->
538 HasSwitch(switches::kEmphasizeTitlesInOmniboxDropdown) &&
539 ((input.type() == metrics::OmniboxInputType::QUERY) ||
540 (input.type() == metrics::OmniboxInputType::FORCED_QUERY))) {
541 std::swap(contents, description);
542 std::swap(contents_class, description_class);
543 }
544 }
545
529 #ifndef NDEBUG 546 #ifndef NDEBUG
530 void AutocompleteMatch::Validate() const { 547 void AutocompleteMatch::Validate() const {
531 ValidateClassifications(contents, contents_class); 548 ValidateClassifications(contents, contents_class);
532 ValidateClassifications(description, description_class); 549 ValidateClassifications(description, description_class);
533 } 550 }
534 551
535 void AutocompleteMatch::ValidateClassifications( 552 void AutocompleteMatch::ValidateClassifications(
536 const base::string16& text, 553 const base::string16& text,
537 const ACMatchClassifications& classifications) const { 554 const ACMatchClassifications& classifications) const {
538 if (text.empty()) { 555 if (text.empty()) {
(...skipping 18 matching lines...) Expand all
557 << " is unsorted in relation to last offset of " << last_offset 574 << " is unsorted in relation to last offset of " << last_offset
558 << ". Provider: " << provider_name << "."; 575 << ". Provider: " << provider_name << ".";
559 DCHECK_LT(i->offset, text.length()) 576 DCHECK_LT(i->offset, text.length())
560 << " Classification of [" << i->offset << "," << text.length() 577 << " Classification of [" << i->offset << "," << text.length()
561 << "] is out of bounds for \"" << text << "\". Provider: " 578 << "] is out of bounds for \"" << text << "\". Provider: "
562 << provider_name << "."; 579 << provider_name << ".";
563 last_offset = i->offset; 580 last_offset = i->offset;
564 } 581 }
565 } 582 }
566 #endif 583 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698