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

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

Issue 2076303002: Delete query in omnibox code. R.I.P. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Delete query in the omnibox code from toolbar model. Created 4 years, 6 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_impl.h ('k') | no next file » | 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // Truncating the URL breaks editing and then pressing enter, but hopefully 59 // Truncating the URL breaks editing and then pressing enter, but hopefully
60 // 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
61 // 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
62 // visible URL" where editing affects and reloads the "real underlying URL", 62 // visible URL" where editing affects and reloads the "real underlying URL",
63 // but this seems very tricky for little gain. 63 // but this seems very tricky for little gain.
64 return gfx::TruncateString(formatted_text, max_url_display_chars_ - 1, 64 return gfx::TruncateString(formatted_text, max_url_display_chars_ - 1,
65 gfx::CHARACTER_BREAK) + 65 gfx::CHARACTER_BREAK) +
66 gfx::kEllipsisUTF16; 66 gfx::kEllipsisUTF16;
67 } 67 }
68 68
69 base::string16 ToolbarModelImpl::GetCorpusNameForMobile() const {
70 if (!WouldPerformSearchTermReplacement(false))
71 return base::string16();
72 GURL url(GetURL());
73 // If there is a query in the url fragment look for the corpus name there,
74 // otherwise look for the corpus name in the query parameters.
75 const std::string& query_str(google_util::HasGoogleSearchQueryParam(
Peter Kasting 2016/06/17 22:51:33 I think removing this means we can remove the goog
Maria 2016/06/17 23:08:46 Done.
76 url.ref_piece()) ? url.ref() : url.query());
77 url::Component query(0, static_cast<int>(query_str.length())), key, value;
78 const char kChipKey[] = "sboxchip";
79 while (url::ExtractQueryKeyValue(query_str.c_str(), &query, &key, &value)) {
80 if (key.is_nonempty() && query_str.substr(key.begin, key.len) == kChipKey) {
81 return net::UnescapeAndDecodeUTF8URLComponent(
82 query_str.substr(value.begin, value.len),
83 net::UnescapeRule::NORMAL);
84 }
85 }
86 return base::string16();
87 }
88
89 GURL ToolbarModelImpl::GetURL() const { 69 GURL ToolbarModelImpl::GetURL() const {
90 GURL url; 70 GURL url;
91 return delegate_->GetURL(&url) ? url : GURL(url::kAboutBlankURL); 71 return delegate_->GetURL(&url) ? url : GURL(url::kAboutBlankURL);
92 } 72 }
93 73
94 bool ToolbarModelImpl::WouldPerformSearchTermReplacement( 74 bool ToolbarModelImpl::WouldPerformSearchTermReplacement(
95 bool ignore_editing) const { 75 bool ignore_editing) const {
96 return !GetSearchTerms(ignore_editing).empty(); 76 return !GetSearchTerms(ignore_editing).empty();
97 } 77 }
98 78
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 bool ToolbarModelImpl::ShouldDisplayURL() const { 146 bool ToolbarModelImpl::ShouldDisplayURL() const {
167 return delegate_->ShouldDisplayURL(); 147 return delegate_->ShouldDisplayURL();
168 } 148 }
169 149
170 base::string16 ToolbarModelImpl::GetSearchTerms(bool ignore_editing) const { 150 base::string16 ToolbarModelImpl::GetSearchTerms(bool ignore_editing) const {
171 if (!url_replacement_enabled() || (input_in_progress() && !ignore_editing)) 151 if (!url_replacement_enabled() || (input_in_progress() && !ignore_editing))
172 return base::string16(); 152 return base::string16();
173 153
174 return delegate_->GetSearchTerms(GetSecurityLevel(ignore_editing)); 154 return delegate_->GetSearchTerms(GetSecurityLevel(ignore_editing));
175 } 155 }
OLDNEW
« no previous file with comments | « components/toolbar/toolbar_model_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698