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

Side by Side Diff: components/omnibox/browser/physical_web_provider.cc

Issue 2738003002: Add title to current page in zero suggest. (Closed)
Patch Set: Remove debugging info. Created 3 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 (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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/browser/physical_web_provider.h" 5 #include "components/omnibox/browser/physical_web_provider.h"
6 6
7 #include "base/feature_list.h"
7 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
8 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
9 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
11 #include "components/bookmarks/browser/titled_url_index.h" 12 #include "components/bookmarks/browser/titled_url_index.h"
12 #include "components/bookmarks/browser/titled_url_node_sorter.h" 13 #include "components/bookmarks/browser/titled_url_node_sorter.h"
13 #include "components/omnibox/browser/autocomplete_provider_client.h" 14 #include "components/omnibox/browser/autocomplete_provider_client.h"
14 #include "components/omnibox/browser/autocomplete_provider_listener.h" 15 #include "components/omnibox/browser/autocomplete_provider_listener.h"
15 #include "components/omnibox/browser/history_url_provider.h" 16 #include "components/omnibox/browser/history_url_provider.h"
16 #include "components/omnibox/browser/omnibox_field_trial.h" 17 #include "components/omnibox/browser/omnibox_field_trial.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 (empty_input_from_user && !after_typing_enabled_)) { 96 (empty_input_from_user && !after_typing_enabled_)) {
96 matches_.clear(); 97 matches_.clear();
97 } 98 }
98 99
99 // In zero-suggest, Physical Web matches should never be default. If the 100 // In zero-suggest, Physical Web matches should never be default. If the
100 // omnibox input is non-empty and we have at least one Physical Web match, 101 // omnibox input is non-empty and we have at least one Physical Web match,
101 // add the current URL as the default so that hitting enter after focusing 102 // add the current URL as the default so that hitting enter after focusing
102 // the omnibox causes the current page to reload. If the input field is 103 // the omnibox causes the current page to reload. If the input field is
103 // empty, no default match is required. 104 // empty, no default match is required.
104 if (!matches_.empty() && !input.text().empty()) { 105 if (!matches_.empty() && !input.text().empty()) {
105 matches_.push_back(VerbatimMatchForURL( 106 const base::string16 description =
106 client_, input, input.current_url(), history_url_provider_, -1)); 107 (base::FeatureList::IsEnabled(omnibox::kDisplayTitleForCurrentUrl))
108 ? input.current_title()
109 : base::string16();
110 matches_.push_back(VerbatimMatchForURL(client_, input,
111 input.current_url(), description,
112 history_url_provider_, -1));
107 } 113 }
108 } else { 114 } else {
109 ConstructQuerySuggestMatches(std::move(metadata_list), input); 115 ConstructQuerySuggestMatches(std::move(metadata_list), input);
110 116
111 if (!matches_.empty()) { 117 if (!matches_.empty()) {
112 had_physical_web_suggestions_ = true; 118 had_physical_web_suggestions_ = true;
113 had_physical_web_suggestions_at_focus_or_later_ = true; 119 had_physical_web_suggestions_at_focus_or_later_ = true;
114 } 120 }
115 121
116 // Don't show Physical Web suggestions after the user starts typing unless 122 // Don't show Physical Web suggestions after the user starts typing unless
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 AutocompleteInput::FormattedStringWithEquivalentMeaning( 315 AutocompleteInput::FormattedStringWithEquivalentMeaning(
310 url, match.contents, client_->GetSchemeClassifier()); 316 url, match.contents, client_->GetSchemeClassifier());
311 317
312 match.description = 318 match.description =
313 l10n_util::GetStringUTF16(IDS_PHYSICAL_WEB_OVERFLOW_DESCRIPTION); 319 l10n_util::GetStringUTF16(IDS_PHYSICAL_WEB_OVERFLOW_DESCRIPTION);
314 match.description_class.push_back( 320 match.description_class.push_back(
315 ACMatchClassification(0, ACMatchClassification::NONE)); 321 ACMatchClassification(0, ACMatchClassification::NONE));
316 322
317 matches_.push_back(match); 323 matches_.push_back(match);
318 } 324 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/omnibox_field_trial.cc ('k') | components/omnibox/browser/physical_web_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698