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 "components/omnibox/browser/omnibox_edit_model.h" | 5 #include "components/omnibox/browser/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/metrics/user_metrics.h" | 13 #include "base/metrics/user_metrics.h" |
14 #include "base/profiler/scoped_tracker.h" | 14 #include "base/profiler/scoped_tracker.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
19 #include "components/bookmarks/browser/bookmark_model.h" | 19 #include "components/bookmarks/browser/bookmark_model.h" |
20 #include "components/metrics/proto/omnibox_event.pb.h" | 20 #include "components/metrics/proto/omnibox_event.pb.h" |
21 #include "components/omnibox/browser/autocomplete_classifier.h" | 21 #include "components/omnibox/browser/autocomplete_classifier.h" |
22 #include "components/omnibox/browser/autocomplete_match_type.h" | 22 #include "components/omnibox/browser/autocomplete_match_type.h" |
23 #include "components/omnibox/browser/autocomplete_provider.h" | 23 #include "components/omnibox/browser/autocomplete_provider.h" |
24 #include "components/omnibox/browser/history_url_provider.h" | 24 #include "components/omnibox/browser/history_url_provider.h" |
25 #include "components/omnibox/browser/keyword_provider.h" | 25 #include "components/omnibox/browser/keyword_provider.h" |
26 #include "components/omnibox/browser/omnibox_client.h" | 26 #include "components/omnibox/browser/omnibox_client.h" |
27 #include "components/omnibox/browser/omnibox_edit_controller.h" | 27 #include "components/omnibox/browser/omnibox_edit_controller.h" |
28 #include "components/omnibox/browser/omnibox_event_global_tracker.h" | |
28 #include "components/omnibox/browser/omnibox_log.h" | 29 #include "components/omnibox/browser/omnibox_log.h" |
29 #include "components/omnibox/browser/omnibox_navigation_observer.h" | 30 #include "components/omnibox/browser/omnibox_navigation_observer.h" |
30 #include "components/omnibox/browser/omnibox_popup_model.h" | 31 #include "components/omnibox/browser/omnibox_popup_model.h" |
31 #include "components/omnibox/browser/omnibox_popup_view.h" | 32 #include "components/omnibox/browser/omnibox_popup_view.h" |
32 #include "components/omnibox/browser/omnibox_view.h" | 33 #include "components/omnibox/browser/omnibox_view.h" |
33 #include "components/omnibox/browser/search_provider.h" | 34 #include "components/omnibox/browser/search_provider.h" |
34 #include "components/search_engines/template_url.h" | 35 #include "components/search_engines/template_url.h" |
35 #include "components/search_engines/template_url_prepopulate_data.h" | 36 #include "components/search_engines/template_url_prepopulate_data.h" |
36 #include "components/search_engines/template_url_service.h" | 37 #include "components/search_engines/template_url_service.h" |
37 #include "components/toolbar/toolbar_model.h" | 38 #include "components/toolbar/toolbar_model.h" |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
701 << "default match changed."; | 702 << "default match changed."; |
702 | 703 |
703 if ((disposition == CURRENT_TAB) && client_->CurrentPageExists()) { | 704 if ((disposition == CURRENT_TAB) && client_->CurrentPageExists()) { |
704 // If we know the destination is being opened in the current tab, | 705 // If we know the destination is being opened in the current tab, |
705 // we can easily get the tab ID. (If it's being opened in a new | 706 // we can easily get the tab ID. (If it's being opened in a new |
706 // tab, we don't know the tab ID yet.) | 707 // tab, we don't know the tab ID yet.) |
707 log.tab_id = client_->GetSessionID().id(); | 708 log.tab_id = client_->GetSessionID().id(); |
708 } | 709 } |
709 autocomplete_controller()->AddProvidersInfo(&log.providers_info); | 710 autocomplete_controller()->AddProvidersInfo(&log.providers_info); |
710 client_->OnURLOpenedFromOmnibox(&log); | 711 client_->OnURLOpenedFromOmnibox(&log); |
712 OmniboxEventGlobalTracker::GetInstance()->OnURLOpened(&log); | |
Alexei Svitkine (slow)
2015/08/06 19:29:03
Seems like you can also eliminate the client_->OnU
Peter Kasting
2015/08/06 19:58:22
I think that would mean that all clients automatic
blundell
2015/08/06 20:22:21
Peter's correct.
Alexei Svitkine (slow)
2015/08/06 20:27:28
Fair enough. I thought there was just a single cli
| |
711 LOCAL_HISTOGRAM_BOOLEAN("Omnibox.EventCount", true); | 713 LOCAL_HISTOGRAM_BOOLEAN("Omnibox.EventCount", true); |
712 DCHECK(!last_omnibox_focus_.is_null()) | 714 DCHECK(!last_omnibox_focus_.is_null()) |
713 << "An omnibox focus should have occurred before opening a match."; | 715 << "An omnibox focus should have occurred before opening a match."; |
714 UMA_HISTOGRAM_TIMES(kFocusToOpenTimeHistogram, now - last_omnibox_focus_); | 716 UMA_HISTOGRAM_TIMES(kFocusToOpenTimeHistogram, now - last_omnibox_focus_); |
715 | 717 |
716 TemplateURLService* service = client_->GetTemplateURLService(); | 718 TemplateURLService* service = client_->GetTemplateURLService(); |
717 TemplateURL* template_url = match.GetTemplateURL(service, false); | 719 TemplateURL* template_url = match.GetTemplateURL(service, false); |
718 if (template_url) { | 720 if (template_url) { |
719 if (match.transition == ui::PAGE_TRANSITION_KEYWORD) { | 721 if (match.transition == ui::PAGE_TRANSITION_KEYWORD) { |
720 // The user is using a non-substituting keyword or is explicitly in | 722 // The user is using a non-substituting keyword or is explicitly in |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1449 // Update state and notify view if the omnibox has focus and the caret | 1451 // Update state and notify view if the omnibox has focus and the caret |
1450 // visibility changed. | 1452 // visibility changed. |
1451 const bool was_caret_visible = is_caret_visible(); | 1453 const bool was_caret_visible = is_caret_visible(); |
1452 focus_state_ = state; | 1454 focus_state_ = state; |
1453 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1455 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1454 is_caret_visible() != was_caret_visible) | 1456 is_caret_visible() != was_caret_visible) |
1455 view_->ApplyCaretVisibility(); | 1457 view_->ApplyCaretVisibility(); |
1456 | 1458 |
1457 client_->OnFocusChanged(focus_state_, reason); | 1459 client_->OnFocusChanged(focus_state_, reason); |
1458 } | 1460 } |
OLD | NEW |