OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/instant/instant_loader.h" | 5 #include "chrome/browser/instant/instant_loader.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 user_text.substr(1) : user_text; | 473 user_text.substr(1) : user_text; |
474 | 474 |
475 // We should preserve the transition type regardless of whether we're already | 475 // We should preserve the transition type regardless of whether we're already |
476 // showing the url. | 476 // showing the url. |
477 last_transition_type_ = transition_type; | 477 last_transition_type_ = transition_type; |
478 | 478 |
479 // If state hasn't changed, just reuse the last suggestion. If the user | 479 // If state hasn't changed, just reuse the last suggestion. If the user |
480 // modifies the text of the omnibox in anyway the URL changes. We also need to | 480 // modifies the text of the omnibox in anyway the URL changes. We also need to |
481 // update if verbatim changes and we're showing instant results. We have to be | 481 // update if verbatim changes and we're showing instant results. We have to be |
482 // careful in checking user_text as in some situations InstantController | 482 // careful in checking user_text as in some situations InstantController |
483 // passes in an empty string (when it knows the user_text won't matter). | 483 // passes in an empty string (when it knows the user_text won't matter). In |
484 if (url_ == url && (!template_url || verbatim == verbatim_)) { | 484 // these cases, we don't worry about whether the new user text matches the old |
| 485 // user text. |
| 486 if ((url_ == url) && |
| 487 (new_user_text.empty() || user_text_ == new_user_text) && |
| 488 (!template_url || verbatim == verbatim_)) { |
485 suggested_text->assign(last_suggestion_); | 489 suggested_text->assign(last_suggestion_); |
486 return; | 490 return; |
487 } | 491 } |
488 | 492 |
489 DCHECK(!url.is_empty() && url.is_valid()); | 493 DCHECK(!url.is_empty() && url.is_valid()); |
490 | 494 |
491 url_ = url; | 495 url_ = url; |
492 user_text_ = new_user_text; | 496 user_text_ = new_user_text; |
493 verbatim_ = verbatim; | 497 verbatim_ = verbatim; |
494 last_suggestion_.clear(); | 498 last_suggestion_.clear(); |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 SetTakesFocusOnlyOnMouseDown(true); | 786 SetTakesFocusOnlyOnMouseDown(true); |
783 } | 787 } |
784 registrar_.Add( | 788 registrar_.Add( |
785 this, | 789 this, |
786 NotificationType::RENDER_VIEW_HOST_CHANGED, | 790 NotificationType::RENDER_VIEW_HOST_CHANGED, |
787 Source<NavigationController>(&preview_contents_->controller())); | 791 Source<NavigationController>(&preview_contents_->controller())); |
788 #endif | 792 #endif |
789 | 793 |
790 preview_contents_->tab_contents()->ShowContents(); | 794 preview_contents_->tab_contents()->ShowContents(); |
791 } | 795 } |
OLD | NEW |