| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| 11 #include "base/format_macros.h" | 11 #include "base/format_macros.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "chrome/app/chrome_command_ids.h" | 18 #include "chrome/app/chrome_command_ids.h" |
| 19 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 19 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
| 20 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 20 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
| 21 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 21 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
| 22 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 22 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.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_factory.h" |
| 26 #include "chrome/browser/bookmarks/bookmark_stats.h" | 27 #include "chrome/browser/bookmarks/bookmark_stats.h" |
| 27 #include "chrome/browser/chrome_notification_types.h" | 28 #include "chrome/browser/chrome_notification_types.h" |
| 28 #include "chrome/browser/command_updater.h" | 29 #include "chrome/browser/command_updater.h" |
| 29 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" | 30 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" |
| 30 #include "chrome/browser/favicon/favicon_tab_helper.h" | 31 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 31 #include "chrome/browser/google/google_url_tracker_factory.h" | 32 #include "chrome/browser/google/google_url_tracker_factory.h" |
| 32 #include "chrome/browser/net/predictor.h" | 33 #include "chrome/browser/net/predictor.h" |
| 33 #include "chrome/browser/omnibox/omnibox_log.h" | 34 #include "chrome/browser/omnibox/omnibox_log.h" |
| 34 #include "chrome/browser/predictors/autocomplete_action_predictor.h" | 35 #include "chrome/browser/predictors/autocomplete_action_predictor.h" |
| 35 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" | 36 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 47 #include "chrome/browser/ui/omnibox/omnibox_navigation_observer.h" | 48 #include "chrome/browser/ui/omnibox/omnibox_navigation_observer.h" |
| 48 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 49 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
| 49 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" | 50 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" |
| 50 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 51 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 51 #include "chrome/browser/ui/search/instant_search_prerenderer.h" | 52 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
| 52 #include "chrome/browser/ui/search/search_tab_helper.h" | 53 #include "chrome/browser/ui/search/search_tab_helper.h" |
| 53 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 54 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
| 54 #include "chrome/common/chrome_switches.h" | 55 #include "chrome/common/chrome_switches.h" |
| 55 #include "chrome/common/pref_names.h" | 56 #include "chrome/common/pref_names.h" |
| 56 #include "chrome/common/url_constants.h" | 57 #include "chrome/common/url_constants.h" |
| 58 #include "components/bookmarks/browser/bookmark_model.h" |
| 57 #include "components/google/core/browser/google_url_tracker.h" | 59 #include "components/google/core/browser/google_url_tracker.h" |
| 58 #include "components/metrics/proto/omnibox_event.pb.h" | 60 #include "components/metrics/proto/omnibox_event.pb.h" |
| 59 #include "components/search_engines/template_url.h" | 61 #include "components/search_engines/template_url.h" |
| 60 #include "components/search_engines/template_url_prepopulate_data.h" | 62 #include "components/search_engines/template_url_prepopulate_data.h" |
| 61 #include "components/search_engines/template_url_service.h" | 63 #include "components/search_engines/template_url_service.h" |
| 62 #include "components/url_fixer/url_fixer.h" | 64 #include "components/url_fixer/url_fixer.h" |
| 63 #include "content/public/browser/navigation_controller.h" | 65 #include "content/public/browser/navigation_controller.h" |
| 64 #include "content/public/browser/navigation_entry.h" | 66 #include "content/public/browser/navigation_entry.h" |
| 65 #include "content/public/browser/notification_service.h" | 67 #include "content/public/browser/notification_service.h" |
| 66 #include "content/public/browser/render_view_host.h" | 68 #include "content/public/browser/render_view_host.h" |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 // This calls RevertAll again. | 847 // This calls RevertAll again. |
| 846 base::AutoReset<bool> tmp(&in_revert_, true); | 848 base::AutoReset<bool> tmp(&in_revert_, true); |
| 847 controller_->OnAutocompleteAccept( | 849 controller_->OnAutocompleteAccept( |
| 848 match.destination_url, disposition, | 850 match.destination_url, disposition, |
| 849 content::PageTransitionFromInt( | 851 content::PageTransitionFromInt( |
| 850 match.transition | content::PAGE_TRANSITION_FROM_ADDRESS_BAR)); | 852 match.transition | content::PAGE_TRANSITION_FROM_ADDRESS_BAR)); |
| 851 if (observer->load_state() != OmniboxNavigationObserver::LOAD_NOT_SEEN) | 853 if (observer->load_state() != OmniboxNavigationObserver::LOAD_NOT_SEEN) |
| 852 ignore_result(observer.release()); // The observer will delete itself. | 854 ignore_result(observer.release()); // The observer will delete itself. |
| 853 } | 855 } |
| 854 | 856 |
| 855 if (match.starred) | 857 BookmarkModel* bookmark_model = BookmarkModelFactory::GetForProfile(profile_); |
| 858 if (bookmark_model && bookmark_model->IsBookmarked(match.destination_url)) |
| 856 RecordBookmarkLaunch(NULL, BOOKMARK_LAUNCH_LOCATION_OMNIBOX); | 859 RecordBookmarkLaunch(NULL, BOOKMARK_LAUNCH_LOCATION_OMNIBOX); |
| 857 } | 860 } |
| 858 | 861 |
| 859 bool OmniboxEditModel::AcceptKeyword(EnteredKeywordModeMethod entered_method) { | 862 bool OmniboxEditModel::AcceptKeyword(EnteredKeywordModeMethod entered_method) { |
| 860 DCHECK(is_keyword_hint_ && !keyword_.empty()); | 863 DCHECK(is_keyword_hint_ && !keyword_.empty()); |
| 861 | 864 |
| 862 autocomplete_controller()->Stop(false); | 865 autocomplete_controller()->Stop(false); |
| 863 is_keyword_hint_ = false; | 866 is_keyword_hint_ = false; |
| 864 | 867 |
| 865 if (popup_model() && popup_model()->IsOpen()) | 868 if (popup_model() && popup_model()->IsOpen()) |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1472 // Update state and notify view if the omnibox has focus and the caret | 1475 // Update state and notify view if the omnibox has focus and the caret |
| 1473 // visibility changed. | 1476 // visibility changed. |
| 1474 const bool was_caret_visible = is_caret_visible(); | 1477 const bool was_caret_visible = is_caret_visible(); |
| 1475 focus_state_ = state; | 1478 focus_state_ = state; |
| 1476 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1479 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
| 1477 is_caret_visible() != was_caret_visible) | 1480 is_caret_visible() != was_caret_visible) |
| 1478 view_->ApplyCaretVisibility(); | 1481 view_->ApplyCaretVisibility(); |
| 1479 | 1482 |
| 1480 delegate_->OnFocusChanged(focus_state_, reason); | 1483 delegate_->OnFocusChanged(focus_state_, reason); |
| 1481 } | 1484 } |
| OLD | NEW |