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/omnibox/browser/omnibox_view.cc

Issue 2735533002: Use SetUserText() in OmniboxViewViews emphasis tests to ensure system coherence. (Closed)
Patch Set: Hopefully compiles deux Created 3 years, 9 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/omnibox/browser/omnibox_view.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 // This file defines helper functions shared by the various implementations 5 // This file defines helper functions shared by the various implementations
6 // of OmniboxView. 6 // of OmniboxView.
7 7
8 #include "components/omnibox/browser/omnibox_view.h" 8 #include "components/omnibox/browser/omnibox_view.h"
9 9
10 #include <utility> 10 #include <utility>
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 model_.reset(new OmniboxEditModel(this, controller, std::move(client))); 180 model_.reset(new OmniboxEditModel(this, controller, std::move(client)));
181 } 181 }
182 } 182 }
183 183
184 void OmniboxView::TextChanged() { 184 void OmniboxView::TextChanged() {
185 EmphasizeURLComponents(); 185 EmphasizeURLComponents();
186 if (model_.get()) 186 if (model_.get())
187 model_->OnChanged(); 187 model_->OnChanged();
188 } 188 }
189 189
190 bool OmniboxView::CurrentTextIsURL() {
191 return model_->CurrentTextIsURL();
192 }
193
194 void OmniboxView::UpdateTextStyle( 190 void OmniboxView::UpdateTextStyle(
195 const base::string16& display_text, 191 const base::string16& display_text,
196 const AutocompleteSchemeClassifier& classifier) { 192 const AutocompleteSchemeClassifier& classifier) {
197 enum DemphasizeComponents { 193 enum DemphasizeComponents {
198 EVERYTHING, 194 EVERYTHING,
199 ALL_BUT_SCHEME, 195 ALL_BUT_SCHEME,
200 ALL_BUT_HOST, 196 ALL_BUT_HOST,
201 NOTHING, 197 NOTHING,
202 } deemphasize = NOTHING; 198 } deemphasize = NOTHING;
203 199
204 url::Component scheme, host; 200 url::Component scheme, host;
205 AutocompleteInput::ParseForEmphasizeComponents(display_text, classifier, 201 AutocompleteInput::ParseForEmphasizeComponents(display_text, classifier,
206 &scheme, &host); 202 &scheme, &host);
207 203
208 if (CurrentTextIsURL()) { 204 if (model_->CurrentTextIsURL()) {
209 const base::string16 url_scheme = 205 const base::string16 url_scheme =
210 display_text.substr(scheme.begin, scheme.len); 206 display_text.substr(scheme.begin, scheme.len);
211 // Extension IDs are not human-readable, so deemphasize everything to draw 207 // Extension IDs are not human-readable, so deemphasize everything to draw
212 // attention to the human-readable name in the location icon text. 208 // attention to the human-readable name in the location icon text.
213 // Data URLs are rarely human-readable and can be used for spoofing, so draw 209 // Data URLs are rarely human-readable and can be used for spoofing, so draw
214 // attention to the scheme to emphasize "this is just a bunch of data". 210 // attention to the scheme to emphasize "this is just a bunch of data".
215 // For normal URLs, the host is the best proxy for "identity". 211 // For normal URLs, the host is the best proxy for "identity".
216 if (url_scheme == base::UTF8ToUTF16(extensions::kExtensionScheme)) 212 if (url_scheme == base::UTF8ToUTF16(extensions::kExtensionScheme))
217 deemphasize = EVERYTHING; 213 deemphasize = EVERYTHING;
218 else if (url_scheme == base::UTF8ToUTF16(url::kDataScheme)) 214 else if (url_scheme == base::UTF8ToUTF16(url::kDataScheme))
(...skipping 19 matching lines...) Expand all
238 break; 234 break;
239 case ALL_BUT_HOST: 235 case ALL_BUT_HOST:
240 SetEmphasis(false, gfx::Range::InvalidRange()); 236 SetEmphasis(false, gfx::Range::InvalidRange());
241 SetEmphasis(true, gfx::Range(host.begin, host.end())); 237 SetEmphasis(true, gfx::Range(host.begin, host.end()));
242 break; 238 break;
243 } 239 }
244 240
245 // Emphasize the scheme for security UI display purposes (if necessary). 241 // Emphasize the scheme for security UI display purposes (if necessary).
246 if (!model()->user_input_in_progress() && scheme_range.IsValid()) 242 if (!model()->user_input_in_progress() && scheme_range.IsValid())
247 UpdateSchemeStyle(scheme_range); 243 UpdateSchemeStyle(scheme_range);
248 } 244 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/omnibox_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698