| 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/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 | 620 |
| 621 // NOTE: Non-prepopulated engines will all have ID 0, which is fine as | 621 // NOTE: Non-prepopulated engines will all have ID 0, which is fine as |
| 622 // the prepopulate IDs start at 1. Distribution-specific engines will | 622 // the prepopulate IDs start at 1. Distribution-specific engines will |
| 623 // all have IDs above the maximum, and will be automatically lumped | 623 // all have IDs above the maximum, and will be automatically lumped |
| 624 // together in an "overflow" bucket in the histogram. | 624 // together in an "overflow" bucket in the histogram. |
| 625 UMA_HISTOGRAM_ENUMERATION("Omnibox.SearchEngine", | 625 UMA_HISTOGRAM_ENUMERATION("Omnibox.SearchEngine", |
| 626 template_url->prepopulate_id(), | 626 template_url->prepopulate_id(), |
| 627 TemplateURLPrepopulateData::kMaxPrepopulatedEngineID); | 627 TemplateURLPrepopulateData::kMaxPrepopulatedEngineID); |
| 628 } | 628 } |
| 629 | 629 |
| 630 if (disposition != NEW_BACKGROUND_TAB) { | 630 // Text in the omnibox needs to be reverted in the following cases: |
| 631 // (1) Non-instant-extended query is committed (except to a background tab, |
| 632 // where the query stays in the omnibox e.g. middle-click). |
| 633 // (2) Instant-extended query is committed on a new tab (foreground or |
| 634 // background). Current tab should show previous, reverted query. |
| 635 bool is_instant_extended_search = controller()->GetInstant() && |
| 636 controller()->GetInstant()->IsInstantExtendedSearch(); |
| 637 if ((disposition != NEW_BACKGROUND_TAB && !is_instant_extended_search) || |
| 638 (is_instant_extended_search && |
| 639 (disposition == NEW_BACKGROUND_TAB || |
| 640 disposition == NEW_FOREGROUND_TAB))) { |
| 631 in_revert_ = true; | 641 in_revert_ = true; |
| 632 view_->RevertAll(); // Revert the box to its unedited state | 642 view_->RevertAll(); // Revert the box to its unedited state |
| 633 in_revert_ = false; | 643 in_revert_ = false; |
| 634 } | 644 } |
| 635 | 645 |
| 636 if (match.type == AutocompleteMatch::EXTENSION_APP) { | 646 if (match.type == AutocompleteMatch::EXTENSION_APP) { |
| 637 ExtensionAppProvider::LaunchAppFromOmnibox(match, profile_, disposition); | 647 ExtensionAppProvider::LaunchAppFromOmnibox(match, profile_, disposition); |
| 638 } else { | 648 } else { |
| 639 GURL destination_url(match.destination_url); | 649 GURL destination_url(match.destination_url); |
| 640 // Append the query formulation time (time from when the user first typed a | 650 // Append the query formulation time (time from when the user first typed a |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1310 instant->OmniboxFocusChanged(state, reason, NULL); | 1320 instant->OmniboxFocusChanged(state, reason, NULL); |
| 1311 | 1321 |
| 1312 // Update state and notify view if the omnibox has focus and the caret | 1322 // Update state and notify view if the omnibox has focus and the caret |
| 1313 // visibility changed. | 1323 // visibility changed. |
| 1314 const bool was_caret_visible = is_caret_visible(); | 1324 const bool was_caret_visible = is_caret_visible(); |
| 1315 focus_state_ = state; | 1325 focus_state_ = state; |
| 1316 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1326 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
| 1317 is_caret_visible() != was_caret_visible) | 1327 is_caret_visible() != was_caret_visible) |
| 1318 view_->ApplyCaretVisibility(); | 1328 view_->ApplyCaretVisibility(); |
| 1319 } | 1329 } |
| OLD | NEW |