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

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

Issue 1841653003: Drop |languages| from {Format,Elide}Url* and IDNToUnicode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo in elide_url.cc Created 4 years, 8 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
« no previous file with comments | « components/toolbar/toolbar_model_delegate.h ('k') | components/url_formatter/elide_url.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 26 matching lines...) Expand all
37 // ToolbarModelImpl Implementation. 37 // ToolbarModelImpl Implementation.
38 base::string16 ToolbarModelImpl::GetText() const { 38 base::string16 ToolbarModelImpl::GetText() const {
39 base::string16 search_terms(GetSearchTerms(false)); 39 base::string16 search_terms(GetSearchTerms(false));
40 if (!search_terms.empty()) 40 if (!search_terms.empty())
41 return search_terms; 41 return search_terms;
42 42
43 return GetFormattedURL(NULL); 43 return GetFormattedURL(NULL);
44 } 44 }
45 45
46 base::string16 ToolbarModelImpl::GetFormattedURL(size_t* prefix_end) const { 46 base::string16 ToolbarModelImpl::GetFormattedURL(size_t* prefix_end) const {
47 // May be empty during initialization.
48 std::string languages = delegate_->GetAcceptLanguages();
49
50 GURL url(GetURL()); 47 GURL url(GetURL());
51 // Note that we can't unescape spaces here, because if the user copies this 48 // Note that we can't unescape spaces here, because if the user copies this
52 // and pastes it into another program, that program may think the URL ends at 49 // and pastes it into another program, that program may think the URL ends at
53 // the space. 50 // the space.
54 const base::string16 formatted_text = 51 const base::string16 formatted_text =
55 delegate_->FormattedStringWithEquivalentMeaning( 52 delegate_->FormattedStringWithEquivalentMeaning(
56 url, url_formatter::FormatUrl( 53 url, url_formatter::FormatUrl(
57 url, languages, url_formatter::kFormatUrlOmitAll, 54 url, url_formatter::kFormatUrlOmitAll,
58 net::UnescapeRule::NORMAL, nullptr, prefix_end, nullptr)); 55 net::UnescapeRule::NORMAL, nullptr, prefix_end, nullptr));
59 if (formatted_text.length() <= max_url_display_chars_) 56 if (formatted_text.length() <= max_url_display_chars_)
60 return formatted_text; 57 return formatted_text;
61 58
62 // Truncating the URL breaks editing and then pressing enter, but hopefully 59 // Truncating the URL breaks editing and then pressing enter, but hopefully
63 // people won't try to do much with such enormous URLs anyway. If this becomes 60 // people won't try to do much with such enormous URLs anyway. If this becomes
64 // a real problem, we could perhaps try to keep some sort of different "elided 61 // a real problem, we could perhaps try to keep some sort of different "elided
65 // visible URL" where editing affects and reloads the "real underlying URL", 62 // visible URL" where editing affects and reloads the "real underlying URL",
66 // but this seems very tricky for little gain. 63 // but this seems very tricky for little gain.
67 return gfx::TruncateString(formatted_text, max_url_display_chars_ - 1, 64 return gfx::TruncateString(formatted_text, max_url_display_chars_ - 1,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 bool ToolbarModelImpl::ShouldDisplayURL() const { 166 bool ToolbarModelImpl::ShouldDisplayURL() const {
170 return delegate_->ShouldDisplayURL(); 167 return delegate_->ShouldDisplayURL();
171 } 168 }
172 169
173 base::string16 ToolbarModelImpl::GetSearchTerms(bool ignore_editing) const { 170 base::string16 ToolbarModelImpl::GetSearchTerms(bool ignore_editing) const {
174 if (!url_replacement_enabled() || (input_in_progress() && !ignore_editing)) 171 if (!url_replacement_enabled() || (input_in_progress() && !ignore_editing))
175 return base::string16(); 172 return base::string16();
176 173
177 return delegate_->GetSearchTerms(GetSecurityLevel(ignore_editing)); 174 return delegate_->GetSearchTerms(GetSecurityLevel(ignore_editing));
178 } 175 }
OLDNEW
« no previous file with comments | « components/toolbar/toolbar_model_delegate.h ('k') | components/url_formatter/elide_url.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698