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

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

Issue 2891653003: [omnibox] Break out SetCaretPos() method and enhance browser test (Closed)
Patch Set: Better Mac call Created 3 years, 7 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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 const gfx::Range range(caret_pos, caret_pos); 422 const gfx::Range range(caret_pos, caret_pos);
423 SetTextAndSelectedRange(text, range); 423 SetTextAndSelectedRange(text, range);
424 424
425 if (update_popup) 425 if (update_popup)
426 UpdatePopup(); 426 UpdatePopup();
427 427
428 if (notify_text_changed) 428 if (notify_text_changed)
429 TextChanged(); 429 TextChanged();
430 } 430 }
431 431
432 void OmniboxViewViews::SetCaretPos(size_t caret_pos) {
433 size_t pos = std::min(caret_pos, text().length());
Peter Kasting 2017/05/18 18:38:34 Nit: Is this actually necessary, or will SelectRan
Kevin Bailey 2017/05/18 19:48:17 It's not necessary. It's corrected way down in Ren
434 const gfx::Range range(pos, pos);
435 SelectRange(range);
Peter Kasting 2017/05/18 18:38:34 Nit: Or just SelectRange(gfx::Range(pos, pos));
Kevin Bailey 2017/05/18 19:48:17 Done.
436 }
437
432 bool OmniboxViewViews::IsSelectAll() const { 438 bool OmniboxViewViews::IsSelectAll() const {
433 // TODO(oshima): IME support. 439 // TODO(oshima): IME support.
434 return text() == GetSelectedText(); 440 return text() == GetSelectedText();
435 } 441 }
436 442
437 bool OmniboxViewViews::DeleteAtEndPressed() { 443 bool OmniboxViewViews::DeleteAtEndPressed() {
438 return delete_at_end_pressed_; 444 return delete_at_end_pressed_;
439 } 445 }
440 446
441 void OmniboxViewViews::UpdatePopup() { 447 void OmniboxViewViews::UpdatePopup() {
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); 1073 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO);
1068 1074
1069 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); 1075 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR);
1070 1076
1071 // Minor note: We use IDC_ for command id here while the underlying textfield 1077 // Minor note: We use IDC_ for command id here while the underlying textfield
1072 // is using IDS_ for all its command ids. This is because views cannot depend 1078 // is using IDS_ for all its command ids. This is because views cannot depend
1073 // on IDC_ for now. 1079 // on IDC_ for now.
1074 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, 1080 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES,
1075 IDS_EDIT_SEARCH_ENGINES); 1081 IDS_EDIT_SEARCH_ENGINES);
1076 } 1082 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698