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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_view_views.cc

Issue 1104513003: Omnibox: Remove Hint Text Code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed WITH_DEFAULT_SEARCH_PROVIDER part of string Created 5 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
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 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 216
217 // TODO(msw|oshima): Consider saving/restoring edit history. 217 // TODO(msw|oshima): Consider saving/restoring edit history.
218 ClearEditHistory(); 218 ClearEditHistory();
219 } 219 }
220 220
221 void OmniboxViewViews::ResetTabState(content::WebContents* web_contents) { 221 void OmniboxViewViews::ResetTabState(content::WebContents* web_contents) {
222 web_contents->SetUserData(OmniboxState::kKey, nullptr); 222 web_contents->SetUserData(OmniboxState::kKey, nullptr);
223 } 223 }
224 224
225 void OmniboxViewViews::Update() { 225 void OmniboxViewViews::Update() {
226 UpdatePlaceholderText();
227
228 const ToolbarModel::SecurityLevel old_security_level = security_level_; 226 const ToolbarModel::SecurityLevel old_security_level = security_level_;
229 security_level_ = controller()->GetToolbarModel()->GetSecurityLevel(false); 227 security_level_ = controller()->GetToolbarModel()->GetSecurityLevel(false);
230 if (model()->UpdatePermanentText()) { 228 if (model()->UpdatePermanentText()) {
231 // Something visibly changed. Re-enable URL replacement. 229 // Something visibly changed. Re-enable URL replacement.
232 controller()->GetToolbarModel()->set_url_replacement_enabled(true); 230 controller()->GetToolbarModel()->set_url_replacement_enabled(true);
233 model()->UpdatePermanentText(); 231 model()->UpdatePermanentText();
234 232
235 // Select all the new text if the user had all the old text selected, or if 233 // Select all the new text if the user had all the old text selected, or if
236 // there was no previous text (for new tab page URL replacement extensions). 234 // there was no previous text (for new tab page URL replacement extensions).
237 // This makes one particular case better: the user clicks in the box to 235 // This makes one particular case better: the user clicks in the box to
(...skipping 13 matching lines...) Expand all
251 // trailing portion of a long URL being scrolled into view. We could try 249 // trailing portion of a long URL being scrolled into view. We could try
252 // and address cases like this, but it seems better to just not muck with 250 // and address cases like this, but it seems better to just not muck with
253 // things when the omnibox isn't focused to begin with. 251 // things when the omnibox isn't focused to begin with.
254 if (was_select_all && model()->has_focus()) 252 if (was_select_all && model()->has_focus())
255 SelectAll(was_reversed); 253 SelectAll(was_reversed);
256 } else if (old_security_level != security_level_) { 254 } else if (old_security_level != security_level_) {
257 EmphasizeURLComponents(); 255 EmphasizeURLComponents();
258 } 256 }
259 } 257 }
260 258
261 void OmniboxViewViews::UpdatePlaceholderText() {
262 if (OmniboxFieldTrial::DisplayHintTextWhenPossible())
263 set_placeholder_text(GetHintText());
264 }
265
266 base::string16 OmniboxViewViews::GetText() const { 259 base::string16 OmniboxViewViews::GetText() const {
267 // TODO(oshima): IME support 260 // TODO(oshima): IME support
268 return text(); 261 return text();
269 } 262 }
270 263
271 void OmniboxViewViews::SetUserText(const base::string16& text, 264 void OmniboxViewViews::SetUserText(const base::string16& text,
272 const base::string16& display_text, 265 const base::string16& display_text,
273 bool update_popup) { 266 bool update_popup) {
274 saved_selection_for_focus_change_ = gfx::Range::InvalidRange(); 267 saved_selection_for_focus_change_ = gfx::Range::InvalidRange();
275 OmniboxView::SetUserText(text, display_text, update_popup); 268 OmniboxView::SetUserText(text, display_text, update_popup);
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 menu_contents->InsertItemWithStringIdAt( 1055 menu_contents->InsertItemWithStringIdAt(
1063 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); 1056 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL);
1064 } 1057 }
1065 1058
1066 // Minor note: We use IDC_ for command id here while the underlying textfield 1059 // Minor note: We use IDC_ for command id here while the underlying textfield
1067 // is using IDS_ for all its command ids. This is because views cannot depend 1060 // is using IDS_ for all its command ids. This is because views cannot depend
1068 // on IDC_ for now. 1061 // on IDC_ for now.
1069 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, 1062 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES,
1070 IDS_EDIT_SEARCH_ENGINES); 1063 IDS_EDIT_SEARCH_ENGINES);
1071 } 1064 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.h ('k') | components/omnibox/omnibox_field_trial.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698