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

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_edit_model.cc

Issue 11415292: [Search] No longer reverting omnibox text on instant search (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Gutted Created 8 years 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
« no previous file with comments | « chrome/browser/instant/instant_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 622
623 // NOTE: Non-prepopulated engines will all have ID 0, which is fine as 623 // NOTE: Non-prepopulated engines will all have ID 0, which is fine as
624 // the prepopulate IDs start at 1. Distribution-specific engines will 624 // the prepopulate IDs start at 1. Distribution-specific engines will
625 // all have IDs above the maximum, and will be automatically lumped 625 // all have IDs above the maximum, and will be automatically lumped
626 // together in an "overflow" bucket in the histogram. 626 // together in an "overflow" bucket in the histogram.
627 UMA_HISTOGRAM_ENUMERATION("Omnibox.SearchEngine", 627 UMA_HISTOGRAM_ENUMERATION("Omnibox.SearchEngine",
628 template_url->prepopulate_id(), 628 template_url->prepopulate_id(),
629 TemplateURLPrepopulateData::kMaxPrepopulatedEngineID); 629 TemplateURLPrepopulateData::kMaxPrepopulatedEngineID);
630 } 630 }
631 631
632 if (disposition != NEW_BACKGROUND_TAB) { 632 // Text in the omnibox needs to be reverted in the following cases:
633 // (1) Non-instant-extended query is committed (except to a background tab,
634 // where the query stays in the omnibox e.g. middle-click).
635 // (2) Instant-extended query is committed on a new tab (foreground or
636 // background). Current tab should show previous, reverted query.
637 bool is_instant_extended_search = controller()->GetInstant() &&
638 controller()->GetInstant()->IsInstantExtendedSearch();
639 if ((disposition != NEW_BACKGROUND_TAB && !is_instant_extended_search) ||
640 (is_instant_extended_search &&
641 (disposition == NEW_BACKGROUND_TAB ||
642 disposition == NEW_FOREGROUND_TAB))) {
633 base::AutoReset<bool> tmp(&in_revert_, true); 643 base::AutoReset<bool> tmp(&in_revert_, true);
634 view_->RevertAll(); // Revert the box to its unedited state 644 view_->RevertAll(); // Revert the box to its unedited state
635 } 645 }
636 646
637 if (match.type == AutocompleteMatch::EXTENSION_APP) { 647 if (match.type == AutocompleteMatch::EXTENSION_APP) {
638 ExtensionAppProvider::LaunchAppFromOmnibox(match, profile_, disposition); 648 ExtensionAppProvider::LaunchAppFromOmnibox(match, profile_, disposition);
639 } else { 649 } else {
640 GURL destination_url(match.destination_url); 650 GURL destination_url(match.destination_url);
641 // Append the query formulation time (time from when the user first typed a 651 // Append the query formulation time (time from when the user first typed a
642 // character into the omnibox to when the user selected a query) to the AQS 652 // character into the omnibox to when the user selected a query) to the AQS
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 instant->OmniboxFocusChanged(state, reason, NULL); 1326 instant->OmniboxFocusChanged(state, reason, NULL);
1317 1327
1318 // Update state and notify view if the omnibox has focus and the caret 1328 // Update state and notify view if the omnibox has focus and the caret
1319 // visibility changed. 1329 // visibility changed.
1320 const bool was_caret_visible = is_caret_visible(); 1330 const bool was_caret_visible = is_caret_visible();
1321 focus_state_ = state; 1331 focus_state_ = state;
1322 if (focus_state_ != OMNIBOX_FOCUS_NONE && 1332 if (focus_state_ != OMNIBOX_FOCUS_NONE &&
1323 is_caret_visible() != was_caret_visible) 1333 is_caret_visible() != was_caret_visible)
1324 view_->ApplyCaretVisibility(); 1334 view_->ApplyCaretVisibility();
1325 } 1335 }
OLDNEW
« no previous file with comments | « chrome/browser/instant/instant_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698