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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 if (!match.destination_url.is_valid()) { | 252 if (!match.destination_url.is_valid()) { |
253 GetInfoForCurrentText(&match, alternate_nav_url); | 253 GetInfoForCurrentText(&match, alternate_nav_url); |
254 } else if (alternate_nav_url) { | 254 } else if (alternate_nav_url) { |
255 *alternate_nav_url = AutocompleteResult::ComputeAlternateNavUrl( | 255 *alternate_nav_url = AutocompleteResult::ComputeAlternateNavUrl( |
256 autocomplete_controller()->input(), match); | 256 autocomplete_controller()->input(), match); |
257 } | 257 } |
258 return match; | 258 return match; |
259 } | 259 } |
260 | 260 |
261 bool OmniboxEditModel::UpdatePermanentText() { | 261 bool OmniboxEditModel::UpdatePermanentText() { |
| 262 SearchProvider* search_provider = |
| 263 autocomplete_controller()->search_provider(); |
| 264 if (search_provider && delegate_->CurrentPageExists()) |
| 265 search_provider->set_current_page_url(delegate_->GetURL()); |
| 266 |
262 // When there's new permanent text, and the user isn't interacting with the | 267 // When there's new permanent text, and the user isn't interacting with the |
263 // omnibox, we want to revert the edit to show the new text. We could simply | 268 // omnibox, we want to revert the edit to show the new text. We could simply |
264 // define "interacting" as "the omnibox has focus", but we still allow updates | 269 // define "interacting" as "the omnibox has focus", but we still allow updates |
265 // when the omnibox has focus as long as the user hasn't begun editing, isn't | 270 // when the omnibox has focus as long as the user hasn't begun editing, isn't |
266 // seeing zerosuggestions (because changing this text would require changing | 271 // seeing zerosuggestions (because changing this text would require changing |
267 // or hiding those suggestions), and hasn't toggled on "Show URL" (because | 272 // or hiding those suggestions), and hasn't toggled on "Show URL" (because |
268 // this update will re-enable search term replacement, which will be annoying | 273 // this update will re-enable search term replacement, which will be annoying |
269 // if the user is trying to copy the URL). When the omnibox doesn't have | 274 // if the user is trying to copy the URL). When the omnibox doesn't have |
270 // focus, we assume the user may have abandoned their interaction and it's | 275 // focus, we assume the user may have abandoned their interaction and it's |
271 // always safe to change the text; this also prevents someone toggling "Show | 276 // always safe to change the text; this also prevents someone toggling "Show |
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 instant->OmniboxFocusChanged(state, reason, NULL); | 1390 instant->OmniboxFocusChanged(state, reason, NULL); |
1386 | 1391 |
1387 // Update state and notify view if the omnibox has focus and the caret | 1392 // Update state and notify view if the omnibox has focus and the caret |
1388 // visibility changed. | 1393 // visibility changed. |
1389 const bool was_caret_visible = is_caret_visible(); | 1394 const bool was_caret_visible = is_caret_visible(); |
1390 focus_state_ = state; | 1395 focus_state_ = state; |
1391 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1396 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1392 is_caret_visible() != was_caret_visible) | 1397 is_caret_visible() != was_caret_visible) |
1393 view_->ApplyCaretVisibility(); | 1398 view_->ApplyCaretVisibility(); |
1394 } | 1399 } |
OLD | NEW |