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/chrome_autocomplete_scheme_classifier.h" | 21 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
22 #include "chrome/browser/autocomplete/history_url_provider.h" | 22 #include "chrome/browser/autocomplete/history_url_provider.h" |
23 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 23 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
24 #include "chrome/browser/bookmarks/bookmark_stats.h" | 24 #include "chrome/browser/bookmarks/bookmark_stats.h" |
25 #include "chrome/browser/chrome_notification_types.h" | 25 #include "chrome/browser/chrome_notification_types.h" |
26 #include "chrome/browser/command_updater.h" | 26 #include "chrome/browser/command_updater.h" |
27 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" | 27 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" |
28 #include "chrome/browser/favicon/favicon_tab_helper.h" | 28 #include "chrome/browser/favicon/favicon_tab_helper.h" |
29 #include "chrome/browser/google/google_url_tracker_factory.h" | |
30 #include "chrome/browser/net/predictor.h" | 29 #include "chrome/browser/net/predictor.h" |
31 #include "chrome/browser/omnibox/omnibox_log.h" | 30 #include "chrome/browser/omnibox/omnibox_log.h" |
32 #include "chrome/browser/predictors/autocomplete_action_predictor.h" | 31 #include "chrome/browser/predictors/autocomplete_action_predictor.h" |
33 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" | 32 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" |
34 #include "chrome/browser/prerender/prerender_field_trial.h" | 33 #include "chrome/browser/prerender/prerender_field_trial.h" |
35 #include "chrome/browser/prerender/prerender_manager.h" | 34 #include "chrome/browser/prerender/prerender_manager.h" |
36 #include "chrome/browser/prerender/prerender_manager_factory.h" | 35 #include "chrome/browser/prerender/prerender_manager_factory.h" |
37 #include "chrome/browser/profiles/profile.h" | 36 #include "chrome/browser/profiles/profile.h" |
38 #include "chrome/browser/search/search.h" | 37 #include "chrome/browser/search/search.h" |
39 #include "chrome/browser/search_engines/template_url_service_factory.h" | 38 #include "chrome/browser/search_engines/template_url_service_factory.h" |
40 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" | 39 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
41 #include "chrome/browser/sessions/session_tab_helper.h" | 40 #include "chrome/browser/sessions/session_tab_helper.h" |
42 #include "chrome/browser/ui/browser_list.h" | 41 #include "chrome/browser/ui/browser_list.h" |
43 #include "chrome/browser/ui/omnibox/omnibox_current_page_delegate_impl.h" | 42 #include "chrome/browser/ui/omnibox/omnibox_current_page_delegate_impl.h" |
44 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" | 43 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" |
45 #include "chrome/browser/ui/omnibox/omnibox_navigation_observer.h" | 44 #include "chrome/browser/ui/omnibox/omnibox_navigation_observer.h" |
46 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 45 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
47 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" | 46 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" |
48 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 47 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
49 #include "chrome/browser/ui/search/instant_search_prerenderer.h" | 48 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
50 #include "chrome/browser/ui/search/search_tab_helper.h" | 49 #include "chrome/browser/ui/search/search_tab_helper.h" |
51 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 50 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
52 #include "chrome/common/chrome_switches.h" | 51 #include "chrome/common/chrome_switches.h" |
53 #include "chrome/common/pref_names.h" | 52 #include "chrome/common/pref_names.h" |
54 #include "chrome/common/url_constants.h" | 53 #include "chrome/common/url_constants.h" |
55 #include "components/bookmarks/browser/bookmark_model.h" | 54 #include "components/bookmarks/browser/bookmark_model.h" |
56 #include "components/google/core/browser/google_url_tracker.h" | |
57 #include "components/metrics/proto/omnibox_event.pb.h" | 55 #include "components/metrics/proto/omnibox_event.pb.h" |
58 #include "components/omnibox/autocomplete_provider.h" | 56 #include "components/omnibox/autocomplete_provider.h" |
59 #include "components/omnibox/keyword_provider.h" | 57 #include "components/omnibox/keyword_provider.h" |
60 #include "components/omnibox/search_provider.h" | 58 #include "components/omnibox/search_provider.h" |
61 #include "components/search_engines/template_url.h" | 59 #include "components/search_engines/template_url.h" |
62 #include "components/search_engines/template_url_prepopulate_data.h" | 60 #include "components/search_engines/template_url_prepopulate_data.h" |
63 #include "components/search_engines/template_url_service.h" | 61 #include "components/search_engines/template_url_service.h" |
64 #include "components/url_fixer/url_fixer.h" | 62 #include "components/url_fixer/url_fixer.h" |
65 #include "content/public/browser/navigation_controller.h" | 63 #include "content/public/browser/navigation_controller.h" |
66 #include "content/public/browser/navigation_entry.h" | 64 #include "content/public/browser/navigation_entry.h" |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 // treat this as a reload. | 679 // treat this as a reload. |
682 match.transition = ui::PAGE_TRANSITION_RELOAD; | 680 match.transition = ui::PAGE_TRANSITION_RELOAD; |
683 } else if (for_drop || ((paste_state_ != NONE) && | 681 } else if (for_drop || ((paste_state_ != NONE) && |
684 match.is_history_what_you_typed_match)) { | 682 match.is_history_what_you_typed_match)) { |
685 // When the user pasted in a URL and hit enter, score it like a link click | 683 // When the user pasted in a URL and hit enter, score it like a link click |
686 // rather than a normal typed URL, so it doesn't get inline autocompleted | 684 // rather than a normal typed URL, so it doesn't get inline autocompleted |
687 // as aggressively later. | 685 // as aggressively later. |
688 match.transition = ui::PAGE_TRANSITION_LINK; | 686 match.transition = ui::PAGE_TRANSITION_LINK; |
689 } | 687 } |
690 | 688 |
691 TemplateURLService* service = | |
692 TemplateURLServiceFactory::GetForProfile(profile_); | |
693 const TemplateURL* template_url = match.GetTemplateURL(service, false); | |
694 if (template_url && template_url->url_ref().HasGoogleBaseURLs( | |
695 UIThreadSearchTermsData(profile_))) { | |
696 GoogleURLTracker* tracker = | |
697 GoogleURLTrackerFactory::GetForProfile(profile_); | |
698 if (tracker) | |
699 tracker->SearchCommitted(); | |
700 } | |
701 | |
702 DCHECK(popup_model()); | 689 DCHECK(popup_model()); |
703 view_->OpenMatch(match, disposition, alternate_nav_url, base::string16(), | 690 view_->OpenMatch(match, disposition, alternate_nav_url, base::string16(), |
704 popup_model()->selected_line()); | 691 popup_model()->selected_line()); |
705 } | 692 } |
706 | 693 |
707 void OmniboxEditModel::OpenMatch(AutocompleteMatch match, | 694 void OmniboxEditModel::OpenMatch(AutocompleteMatch match, |
708 WindowOpenDisposition disposition, | 695 WindowOpenDisposition disposition, |
709 const GURL& alternate_nav_url, | 696 const GURL& alternate_nav_url, |
710 const base::string16& pasted_text, | 697 const base::string16& pasted_text, |
711 size_t index) { | 698 size_t index) { |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1475 // Update state and notify view if the omnibox has focus and the caret | 1462 // Update state and notify view if the omnibox has focus and the caret |
1476 // visibility changed. | 1463 // visibility changed. |
1477 const bool was_caret_visible = is_caret_visible(); | 1464 const bool was_caret_visible = is_caret_visible(); |
1478 focus_state_ = state; | 1465 focus_state_ = state; |
1479 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1466 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1480 is_caret_visible() != was_caret_visible) | 1467 is_caret_visible() != was_caret_visible) |
1481 view_->ApplyCaretVisibility(); | 1468 view_->ApplyCaretVisibility(); |
1482 | 1469 |
1483 delegate_->OnFocusChanged(focus_state_, reason); | 1470 delegate_->OnFocusChanged(focus_state_, reason); |
1484 } | 1471 } |
OLD | NEW |