| 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" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "chrome/app/chrome_command_ids.h" | 17 #include "chrome/app/chrome_command_ids.h" |
| 18 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 18 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
| 19 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 19 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
| 20 #include "chrome/browser/autocomplete/autocomplete_input.h" | 20 #include "chrome/browser/autocomplete/autocomplete_input.h" |
| 21 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 21 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
| 22 #include "chrome/browser/autocomplete/extension_app_provider.h" | 22 #include "chrome/browser/autocomplete/extension_app_provider.h" |
| 23 #include "chrome/browser/autocomplete/history_url_provider.h" | 23 #include "chrome/browser/autocomplete/history_url_provider.h" |
| 24 #include "chrome/browser/autocomplete/keyword_provider.h" | 24 #include "chrome/browser/autocomplete/keyword_provider.h" |
| 25 #include "chrome/browser/autocomplete/search_provider.h" | 25 #include "chrome/browser/autocomplete/search_provider.h" |
| 26 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 27 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 26 #include "chrome/browser/bookmarks/bookmark_stats.h" | 28 #include "chrome/browser/bookmarks/bookmark_stats.h" |
| 27 #include "chrome/browser/chrome_notification_types.h" | 29 #include "chrome/browser/chrome_notification_types.h" |
| 28 #include "chrome/browser/command_updater.h" | 30 #include "chrome/browser/command_updater.h" |
| 29 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" | 31 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" |
| 30 #include "chrome/browser/favicon/favicon_tab_helper.h" | 32 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 31 #include "chrome/browser/google/google_url_tracker.h" | 33 #include "chrome/browser/google/google_url_tracker.h" |
| 32 #include "chrome/browser/net/predictor.h" | 34 #include "chrome/browser/net/predictor.h" |
| 33 #include "chrome/browser/omnibox/omnibox_log.h" | 35 #include "chrome/browser/omnibox/omnibox_log.h" |
| 34 #include "chrome/browser/predictors/autocomplete_action_predictor.h" | 36 #include "chrome/browser/predictors/autocomplete_action_predictor.h" |
| 35 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" | 37 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" |
| (...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 base::AutoReset<bool> tmp(&in_revert_, true); | 822 base::AutoReset<bool> tmp(&in_revert_, true); |
| 821 controller_->OnAutocompleteAccept( | 823 controller_->OnAutocompleteAccept( |
| 822 match.destination_url, disposition, | 824 match.destination_url, disposition, |
| 823 content::PageTransitionFromInt( | 825 content::PageTransitionFromInt( |
| 824 match.transition | content::PAGE_TRANSITION_FROM_ADDRESS_BAR)); | 826 match.transition | content::PAGE_TRANSITION_FROM_ADDRESS_BAR)); |
| 825 if (observer->load_state() != OmniboxNavigationObserver::LOAD_NOT_SEEN) | 827 if (observer->load_state() != OmniboxNavigationObserver::LOAD_NOT_SEEN) |
| 826 ignore_result(observer.release()); // The observer will delete itself. | 828 ignore_result(observer.release()); // The observer will delete itself. |
| 827 } | 829 } |
| 828 } | 830 } |
| 829 | 831 |
| 830 if (match.starred) | 832 if (match.starred) { |
| 831 RecordBookmarkLaunch(NULL, BOOKMARK_LAUNCH_LOCATION_OMNIBOX); | 833 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile_); |
| 834 RecordBookmarkLaunch(model, NULL, BOOKMARK_LAUNCH_LOCATION_OMNIBOX); |
| 835 } |
| 832 } | 836 } |
| 833 | 837 |
| 834 bool OmniboxEditModel::AcceptKeyword(EnteredKeywordModeMethod entered_method) { | 838 bool OmniboxEditModel::AcceptKeyword(EnteredKeywordModeMethod entered_method) { |
| 835 DCHECK(is_keyword_hint_ && !keyword_.empty()); | 839 DCHECK(is_keyword_hint_ && !keyword_.empty()); |
| 836 | 840 |
| 837 autocomplete_controller()->Stop(false); | 841 autocomplete_controller()->Stop(false); |
| 838 is_keyword_hint_ = false; | 842 is_keyword_hint_ = false; |
| 839 | 843 |
| 840 if (popup_model() && popup_model()->IsOpen()) | 844 if (popup_model() && popup_model()->IsOpen()) |
| 841 popup_model()->SetSelectedLineState(OmniboxPopupModel::KEYWORD); | 845 popup_model()->SetSelectedLineState(OmniboxPopupModel::KEYWORD); |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1443 // Update state and notify view if the omnibox has focus and the caret | 1447 // Update state and notify view if the omnibox has focus and the caret |
| 1444 // visibility changed. | 1448 // visibility changed. |
| 1445 const bool was_caret_visible = is_caret_visible(); | 1449 const bool was_caret_visible = is_caret_visible(); |
| 1446 focus_state_ = state; | 1450 focus_state_ = state; |
| 1447 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1451 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
| 1448 is_caret_visible() != was_caret_visible) | 1452 is_caret_visible() != was_caret_visible) |
| 1449 view_->ApplyCaretVisibility(); | 1453 view_->ApplyCaretVisibility(); |
| 1450 | 1454 |
| 1451 delegate_->OnFocusChanged(focus_state_, reason); | 1455 delegate_->OnFocusChanged(focus_state_, reason); |
| 1452 } | 1456 } |
| OLD | NEW |