| OLD | NEW |
| 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 "base/property_bag.h" | 7 #include "base/property_bag.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 } | 500 } |
| 501 | 501 |
| 502 bool OmniboxViewViews::DeleteAtEndPressed() { | 502 bool OmniboxViewViews::DeleteAtEndPressed() { |
| 503 return delete_at_end_pressed_; | 503 return delete_at_end_pressed_; |
| 504 } | 504 } |
| 505 | 505 |
| 506 void OmniboxViewViews::GetSelectionBounds(string16::size_type* start, | 506 void OmniboxViewViews::GetSelectionBounds(string16::size_type* start, |
| 507 string16::size_type* end) const { | 507 string16::size_type* end) const { |
| 508 ui::Range range; | 508 ui::Range range; |
| 509 textfield_->GetSelectedRange(&range); | 509 textfield_->GetSelectedRange(&range); |
| 510 *start = static_cast<size_t>(range.end()); | 510 if (range.is_empty()) { |
| 511 *end = static_cast<size_t>(range.start()); | 511 // Omnibox API expects that selection bounds is at cursor position |
| 512 // if there is no selection. |
| 513 *start = textfield_->GetCursorPosition(); |
| 514 *end = textfield_->GetCursorPosition(); |
| 515 } else { |
| 516 *start = static_cast<size_t>(range.end()); |
| 517 *end = static_cast<size_t>(range.start()); |
| 518 } |
| 512 } | 519 } |
| 513 | 520 |
| 514 void OmniboxViewViews::SelectAll(bool reversed) { | 521 void OmniboxViewViews::SelectAll(bool reversed) { |
| 515 if (reversed) | 522 if (reversed) |
| 516 textfield_->SelectRange(ui::Range(GetTextLength(), 0)); | 523 textfield_->SelectRange(ui::Range(GetTextLength(), 0)); |
| 517 else | 524 else |
| 518 textfield_->SelectRange(ui::Range(0, GetTextLength())); | 525 textfield_->SelectRange(ui::Range(0, GetTextLength())); |
| 519 } | 526 } |
| 520 | 527 |
| 521 void OmniboxViewViews::RevertAll() { | 528 void OmniboxViewViews::RevertAll() { |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 OmniboxViewViews* omnibox_view = new OmniboxViewViews(controller, | 875 OmniboxViewViews* omnibox_view = new OmniboxViewViews(controller, |
| 869 toolbar_model, | 876 toolbar_model, |
| 870 profile, | 877 profile, |
| 871 command_updater, | 878 command_updater, |
| 872 popup_window_mode, | 879 popup_window_mode, |
| 873 location_bar); | 880 location_bar); |
| 874 omnibox_view->Init(); | 881 omnibox_view->Init(); |
| 875 return omnibox_view; | 882 return omnibox_view; |
| 876 } | 883 } |
| 877 #endif | 884 #endif |
| OLD | NEW |