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 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 // NOTE: Non-prepopulated engines will all have ID 0, which is fine as | 756 // NOTE: Non-prepopulated engines will all have ID 0, which is fine as |
757 // the prepopulate IDs start at 1. Distribution-specific engines will | 757 // the prepopulate IDs start at 1. Distribution-specific engines will |
758 // all have IDs above the maximum, and will be automatically lumped | 758 // all have IDs above the maximum, and will be automatically lumped |
759 // together in an "overflow" bucket in the histogram. | 759 // together in an "overflow" bucket in the histogram. |
760 UMA_HISTOGRAM_ENUMERATION("Omnibox.SearchEngine", | 760 UMA_HISTOGRAM_ENUMERATION("Omnibox.SearchEngine", |
761 template_url->prepopulate_id(), | 761 template_url->prepopulate_id(), |
762 TemplateURLPrepopulateData::kMaxPrepopulatedEngineID); | 762 TemplateURLPrepopulateData::kMaxPrepopulatedEngineID); |
763 } | 763 } |
764 | 764 |
765 // Get the current text before we call RevertAll() which will clear it. | 765 // Get the current text before we call RevertAll() which will clear it. |
766 string16 current_text = GetViewText(); | 766 string16 current_text = view_->GetText(); |
767 | 767 |
768 if (disposition != NEW_BACKGROUND_TAB) { | 768 if (disposition != NEW_BACKGROUND_TAB) { |
769 base::AutoReset<bool> tmp(&in_revert_, true); | 769 base::AutoReset<bool> tmp(&in_revert_, true); |
770 view_->RevertAll(); // Revert the box to its unedited state. | 770 view_->RevertAll(); // Revert the box to its unedited state. |
771 } | 771 } |
772 | 772 |
773 if (match.type == AutocompleteMatchType::EXTENSION_APP) { | 773 if (match.type == AutocompleteMatchType::EXTENSION_APP) { |
774 ExtensionAppProvider::LaunchAppFromOmnibox(match, profile_, disposition); | 774 ExtensionAppProvider::LaunchAppFromOmnibox(match, profile_, disposition); |
775 observer->OnSuccessfulNavigation(); | 775 observer->OnSuccessfulNavigation(); |
776 } else { | 776 } else { |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1205 bool is_keyword_hint; | 1205 bool is_keyword_hint; |
1206 match.GetKeywordUIState(profile_, &keyword, &is_keyword_hint); | 1206 match.GetKeywordUIState(profile_, &keyword, &is_keyword_hint); |
1207 popup_model()->OnResultChanged(); | 1207 popup_model()->OnResultChanged(); |
1208 // OnPopupDataChanged() resets OmniboxController's |current_match_| early | 1208 // OnPopupDataChanged() resets OmniboxController's |current_match_| early |
1209 // on. Therefore, copy match.inline_autocompletion to a temp to preserve | 1209 // on. Therefore, copy match.inline_autocompletion to a temp to preserve |
1210 // its value across the entire call. | 1210 // its value across the entire call. |
1211 const string16 inline_autocompletion(match.inline_autocompletion); | 1211 const string16 inline_autocompletion(match.inline_autocompletion); |
1212 OnPopupDataChanged(inline_autocompletion, NULL, keyword, is_keyword_hint); | 1212 OnPopupDataChanged(inline_autocompletion, NULL, keyword, is_keyword_hint); |
1213 } | 1213 } |
1214 | 1214 |
1215 string16 OmniboxEditModel::GetViewText() const { | |
1216 return view_->GetText(); | |
1217 } | |
1218 | |
1219 InstantController* OmniboxEditModel::GetInstantController() const { | 1215 InstantController* OmniboxEditModel::GetInstantController() const { |
1220 return controller_->GetInstant(); | 1216 return controller_->GetInstant(); |
1221 } | 1217 } |
1222 | 1218 |
1223 // static | 1219 // static |
1224 const char OmniboxEditModel::kCutOrCopyAllTextHistogram[] = | 1220 const char OmniboxEditModel::kCutOrCopyAllTextHistogram[] = |
1225 "Omnibox.CutOrCopyAllText"; | 1221 "Omnibox.CutOrCopyAllText"; |
1226 | 1222 |
1227 bool OmniboxEditModel::query_in_progress() const { | 1223 bool OmniboxEditModel::query_in_progress() const { |
1228 return !autocomplete_controller()->done(); | 1224 return !autocomplete_controller()->done(); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1405 instant->OmniboxFocusChanged(state, reason, NULL); | 1401 instant->OmniboxFocusChanged(state, reason, NULL); |
1406 | 1402 |
1407 // Update state and notify view if the omnibox has focus and the caret | 1403 // Update state and notify view if the omnibox has focus and the caret |
1408 // visibility changed. | 1404 // visibility changed. |
1409 const bool was_caret_visible = is_caret_visible(); | 1405 const bool was_caret_visible = is_caret_visible(); |
1410 focus_state_ = state; | 1406 focus_state_ = state; |
1411 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1407 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1412 is_caret_visible() != was_caret_visible) | 1408 is_caret_visible() != was_caret_visible) |
1413 view_->ApplyCaretVisibility(); | 1409 view_->ApplyCaretVisibility(); |
1414 } | 1410 } |
OLD | NEW |