| OLD | NEW |
| 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 "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 5 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 if (!match.destination_url.is_valid()) { | 290 if (!match.destination_url.is_valid()) { |
| 291 GetInfoForCurrentText(&match, alternate_nav_url); | 291 GetInfoForCurrentText(&match, alternate_nav_url); |
| 292 } else if (alternate_nav_url) { | 292 } else if (alternate_nav_url) { |
| 293 *alternate_nav_url = AutocompleteResult::ComputeAlternateNavUrl( | 293 *alternate_nav_url = AutocompleteResult::ComputeAlternateNavUrl( |
| 294 input_, match); | 294 input_, match); |
| 295 } | 295 } |
| 296 return match; | 296 return match; |
| 297 } | 297 } |
| 298 | 298 |
| 299 bool OmniboxEditModel::UpdatePermanentText() { | 299 bool OmniboxEditModel::UpdatePermanentText() { |
| 300 SearchProvider* search_provider = | |
| 301 autocomplete_controller()->search_provider(); | |
| 302 if (search_provider && delegate_->CurrentPageExists()) | |
| 303 search_provider->set_current_page_url(delegate_->GetURL()); | |
| 304 | |
| 305 // When there's new permanent text, and the user isn't interacting with the | 300 // When there's new permanent text, and the user isn't interacting with the |
| 306 // omnibox, we want to revert the edit to show the new text. We could simply | 301 // omnibox, we want to revert the edit to show the new text. We could simply |
| 307 // define "interacting" as "the omnibox has focus", but we still allow updates | 302 // define "interacting" as "the omnibox has focus", but we still allow updates |
| 308 // when the omnibox has focus as long as the user hasn't begun editing, isn't | 303 // when the omnibox has focus as long as the user hasn't begun editing, isn't |
| 309 // seeing zerosuggestions (because changing this text would require changing | 304 // seeing zerosuggestions (because changing this text would require changing |
| 310 // or hiding those suggestions), and hasn't toggled on "Show URL" (because | 305 // or hiding those suggestions), and hasn't toggled on "Show URL" (because |
| 311 // this update will re-enable search term replacement, which will be annoying | 306 // this update will re-enable search term replacement, which will be annoying |
| 312 // if the user is trying to copy the URL). When the omnibox doesn't have | 307 // if the user is trying to copy the URL). When the omnibox doesn't have |
| 313 // focus, we assume the user may have abandoned their interaction and it's | 308 // focus, we assume the user may have abandoned their interaction and it's |
| 314 // always safe to change the text; this also prevents someone toggling "Show | 309 // always safe to change the text; this also prevents someone toggling "Show |
| (...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1536 // Update state and notify view if the omnibox has focus and the caret | 1531 // Update state and notify view if the omnibox has focus and the caret |
| 1537 // visibility changed. | 1532 // visibility changed. |
| 1538 const bool was_caret_visible = is_caret_visible(); | 1533 const bool was_caret_visible = is_caret_visible(); |
| 1539 focus_state_ = state; | 1534 focus_state_ = state; |
| 1540 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1535 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
| 1541 is_caret_visible() != was_caret_visible) | 1536 is_caret_visible() != was_caret_visible) |
| 1542 view_->ApplyCaretVisibility(); | 1537 view_->ApplyCaretVisibility(); |
| 1543 | 1538 |
| 1544 delegate_->OnFocusChanged(focus_state_, reason); | 1539 delegate_->OnFocusChanged(focus_state_, reason); |
| 1545 } | 1540 } |
| OLD | NEW |