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

Side by Side Diff: components/toolbar/toolbar_model_impl.cc

Issue 2232863002: Remove search::GetSearchTerms since it always returns empty string (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_query_extract
Patch Set: Mac Created 4 years, 4 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/toolbar/toolbar_model_impl.h" 5 #include "components/toolbar/toolbar_model_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 17 matching lines...) Expand all
28 size_t max_url_display_chars) 28 size_t max_url_display_chars)
29 : delegate_(delegate), max_url_display_chars_(max_url_display_chars) { 29 : delegate_(delegate), max_url_display_chars_(max_url_display_chars) {
30 DCHECK(delegate_); 30 DCHECK(delegate_);
31 } 31 }
32 32
33 ToolbarModelImpl::~ToolbarModelImpl() { 33 ToolbarModelImpl::~ToolbarModelImpl() {
34 } 34 }
35 35
36 // ToolbarModelImpl Implementation. 36 // ToolbarModelImpl Implementation.
37 base::string16 ToolbarModelImpl::GetText() const { 37 base::string16 ToolbarModelImpl::GetText() const {
38 base::string16 search_terms(GetSearchTerms(false));
39 if (!search_terms.empty())
40 return search_terms;
Peter Kasting 2016/08/13 05:03:45 This removal probably means we should rip out GetT
Marc Treib 2016/08/16 12:00:18 Done.
41
42 return GetFormattedURL(NULL); 38 return GetFormattedURL(NULL);
43 } 39 }
44 40
45 base::string16 ToolbarModelImpl::GetFormattedURL(size_t* prefix_end) const { 41 base::string16 ToolbarModelImpl::GetFormattedURL(size_t* prefix_end) const {
46 GURL url(GetURL()); 42 GURL url(GetURL());
47 // Note that we can't unescape spaces here, because if the user copies this 43 // Note that we can't unescape spaces here, because if the user copies this
48 // and pastes it into another program, that program may think the URL ends at 44 // and pastes it into another program, that program may think the URL ends at
49 // the space. 45 // the space.
50 const base::string16 formatted_text = 46 const base::string16 formatted_text =
51 delegate_->FormattedStringWithEquivalentMeaning( 47 delegate_->FormattedStringWithEquivalentMeaning(
(...skipping 11 matching lines...) Expand all
63 return gfx::TruncateString(formatted_text, max_url_display_chars_ - 1, 59 return gfx::TruncateString(formatted_text, max_url_display_chars_ - 1,
64 gfx::CHARACTER_BREAK) + 60 gfx::CHARACTER_BREAK) +
65 gfx::kEllipsisUTF16; 61 gfx::kEllipsisUTF16;
66 } 62 }
67 63
68 GURL ToolbarModelImpl::GetURL() const { 64 GURL ToolbarModelImpl::GetURL() const {
69 GURL url; 65 GURL url;
70 return delegate_->GetURL(&url) ? url : GURL(url::kAboutBlankURL); 66 return delegate_->GetURL(&url) ? url : GURL(url::kAboutBlankURL);
71 } 67 }
72 68
73 bool ToolbarModelImpl::WouldPerformSearchTermReplacement(
74 bool ignore_editing) const {
75 return !GetSearchTerms(ignore_editing).empty();
76 }
77
78 SecurityStateModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel( 69 SecurityStateModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel(
79 bool ignore_editing) const { 70 bool ignore_editing) const {
80 // When editing or empty, assume no security style. 71 // When editing or empty, assume no security style.
81 return ((input_in_progress() && !ignore_editing) || !ShouldDisplayURL()) 72 return ((input_in_progress() && !ignore_editing) || !ShouldDisplayURL())
82 ? SecurityStateModel::NONE 73 ? SecurityStateModel::NONE
83 : delegate_->GetSecurityLevel(); 74 : delegate_->GetSecurityLevel();
84 } 75 }
85 76
86 int ToolbarModelImpl::GetIcon() const { 77 int ToolbarModelImpl::GetIcon() const {
87 switch (GetSecurityLevel(false)) { 78 switch (GetSecurityLevel(false)) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 DCHECK(!cert->subject().country_name.empty()); 129 DCHECK(!cert->subject().country_name.empty());
139 return l10n_util::GetStringFUTF16( 130 return l10n_util::GetStringFUTF16(
140 IDS_SECURE_CONNECTION_EV, 131 IDS_SECURE_CONNECTION_EV,
141 base::UTF8ToUTF16(cert->subject().organization_names[0]), 132 base::UTF8ToUTF16(cert->subject().organization_names[0]),
142 base::UTF8ToUTF16(cert->subject().country_name)); 133 base::UTF8ToUTF16(cert->subject().country_name));
143 } 134 }
144 135
145 bool ToolbarModelImpl::ShouldDisplayURL() const { 136 bool ToolbarModelImpl::ShouldDisplayURL() const {
146 return delegate_->ShouldDisplayURL(); 137 return delegate_->ShouldDisplayURL();
147 } 138 }
148
149 base::string16 ToolbarModelImpl::GetSearchTerms(bool ignore_editing) const {
150 if (!url_replacement_enabled() || (input_in_progress() && !ignore_editing))
151 return base::string16();
152
153 return delegate_->GetSearchTerms(GetSecurityLevel(ignore_editing));
154 }
OLDNEW
« components/toolbar/toolbar_model.h ('K') | « components/toolbar/toolbar_model_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698