| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/autocomplete/autocomplete_edit.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "chrome/browser/prerender/prerender_manager.h" | 33 #include "chrome/browser/prerender/prerender_manager.h" |
| 34 #include "chrome/browser/prerender/prerender_manager_factory.h" | 34 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 35 #include "chrome/browser/profiles/profile.h" | 35 #include "chrome/browser/profiles/profile.h" |
| 36 #include "chrome/browser/search_engines/template_url.h" | 36 #include "chrome/browser/search_engines/template_url.h" |
| 37 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 37 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
| 38 #include "chrome/browser/search_engines/template_url_service.h" | 38 #include "chrome/browser/search_engines/template_url_service.h" |
| 39 #include "chrome/browser/search_engines/template_url_service_factory.h" | 39 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 40 #include "chrome/browser/sessions/restore_tab_helper.h" | 40 #include "chrome/browser/sessions/restore_tab_helper.h" |
| 41 #include "chrome/browser/ui/browser_list.h" | 41 #include "chrome/browser/ui/browser_list.h" |
| 42 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 42 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 43 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 43 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 44 #include "chrome/common/chrome_notification_types.h" | 44 #include "chrome/common/chrome_notification_types.h" |
| 45 #include "chrome/common/chrome_switches.h" | 45 #include "chrome/common/chrome_switches.h" |
| 46 #include "chrome/common/metrics/proto/omnibox_event.pb.h" | 46 #include "chrome/common/metrics/proto/omnibox_event.pb.h" |
| 47 #include "chrome/common/pref_names.h" | 47 #include "chrome/common/pref_names.h" |
| 48 #include "chrome/common/url_constants.h" | 48 #include "chrome/common/url_constants.h" |
| 49 #include "content/public/browser/notification_service.h" | 49 #include "content/public/browser/notification_service.h" |
| 50 #include "content/public/browser/render_view_host.h" | 50 #include "content/public/browser/render_view_host.h" |
| 51 #include "content/public/browser/user_metrics.h" | 51 #include "content/public/browser/user_metrics.h" |
| 52 #include "content/public/browser/web_contents.h" | 52 #include "content/public/browser/web_contents.h" |
| 53 #include "googleurl/src/gurl.h" | 53 #include "googleurl/src/gurl.h" |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 size_t index) { | 515 size_t index) { |
| 516 // We only care about cases where there is a selection (i.e. the popup is | 516 // We only care about cases where there is a selection (i.e. the popup is |
| 517 // open). | 517 // open). |
| 518 if (popup_->IsOpen()) { | 518 if (popup_->IsOpen()) { |
| 519 AutocompleteLog log( | 519 AutocompleteLog log( |
| 520 autocomplete_controller_->input().text(), | 520 autocomplete_controller_->input().text(), |
| 521 just_deleted_text_, | 521 just_deleted_text_, |
| 522 autocomplete_controller_->input().type(), | 522 autocomplete_controller_->input().type(), |
| 523 popup_->selected_line(), | 523 popup_->selected_line(), |
| 524 -1, // don't yet know tab ID; set later if appropriate | 524 -1, // don't yet know tab ID; set later if appropriate |
| 525 ClassifyPage(controller_->GetTabContentsWrapper()-> | 525 ClassifyPage(controller_->GetTabContents()-> |
| 526 web_contents()->GetURL()), | 526 web_contents()->GetURL()), |
| 527 base::TimeTicks::Now() - time_user_first_modified_omnibox_, | 527 base::TimeTicks::Now() - time_user_first_modified_omnibox_, |
| 528 0, // inline autocomplete length; possibly set later | 528 0, // inline autocomplete length; possibly set later |
| 529 result()); | 529 result()); |
| 530 DCHECK(user_input_in_progress_) << "We didn't get here through the " | 530 DCHECK(user_input_in_progress_) << "We didn't get here through the " |
| 531 "expected series of calls. time_user_first_modified_omnibox_ is " | 531 "expected series of calls. time_user_first_modified_omnibox_ is " |
| 532 "not set correctly and other things may be wrong."; | 532 "not set correctly and other things may be wrong."; |
| 533 if (index != AutocompletePopupModel::kNoMatch) | 533 if (index != AutocompletePopupModel::kNoMatch) |
| 534 log.selected_index = index; | 534 log.selected_index = index; |
| 535 else if (!has_temporary_text_) | 535 else if (!has_temporary_text_) |
| 536 log.inline_autocompleted_length = inline_autocomplete_text_.length(); | 536 log.inline_autocompleted_length = inline_autocomplete_text_.length(); |
| 537 if (disposition == CURRENT_TAB) { | 537 if (disposition == CURRENT_TAB) { |
| 538 // If we know the destination is being opened in the current tab, | 538 // If we know the destination is being opened in the current tab, |
| 539 // we can easily get the tab ID. (If it's being opened in a new | 539 // we can easily get the tab ID. (If it's being opened in a new |
| 540 // tab, we don't know the tab ID yet.) | 540 // tab, we don't know the tab ID yet.) |
| 541 log.tab_id = controller_->GetTabContentsWrapper()-> | 541 log.tab_id = controller_->GetTabContents()-> |
| 542 restore_tab_helper()->session_id().id(); | 542 restore_tab_helper()->session_id().id(); |
| 543 } | 543 } |
| 544 autocomplete_controller_->AddProvidersInfo(&log.providers_info); | 544 autocomplete_controller_->AddProvidersInfo(&log.providers_info); |
| 545 content::NotificationService::current()->Notify( | 545 content::NotificationService::current()->Notify( |
| 546 chrome::NOTIFICATION_OMNIBOX_OPENED_URL, | 546 chrome::NOTIFICATION_OMNIBOX_OPENED_URL, |
| 547 content::Source<Profile>(profile_), | 547 content::Source<Profile>(profile_), |
| 548 content::Details<AutocompleteLog>(&log)); | 548 content::Details<AutocompleteLog>(&log)); |
| 549 } | 549 } |
| 550 | 550 |
| 551 TemplateURL* template_url = match.GetTemplateURL(profile_); | 551 TemplateURL* template_url = match.GetTemplateURL(profile_); |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 return false; | 1091 return false; |
| 1092 } | 1092 } |
| 1093 | 1093 |
| 1094 void AutocompleteEditModel::DoPrerender(const AutocompleteMatch& match) { | 1094 void AutocompleteEditModel::DoPrerender(const AutocompleteMatch& match) { |
| 1095 // Do not prerender if the destination URL is the same as the current URL. | 1095 // Do not prerender if the destination URL is the same as the current URL. |
| 1096 if (match.destination_url == PermanentURL()) | 1096 if (match.destination_url == PermanentURL()) |
| 1097 return; | 1097 return; |
| 1098 // It's possible the tab strip does not have an active tab contents, for | 1098 // It's possible the tab strip does not have an active tab contents, for |
| 1099 // instance if the tab has been closed or on return from a sleep state | 1099 // instance if the tab has been closed or on return from a sleep state |
| 1100 // (http://crbug.com/105689) | 1100 // (http://crbug.com/105689) |
| 1101 TabContentsWrapper* tab = controller_->GetTabContentsWrapper(); | 1101 TabContents* tab = controller_->GetTabContents(); |
| 1102 if (!tab) | 1102 if (!tab) |
| 1103 return; | 1103 return; |
| 1104 prerender::PrerenderManager* prerender_manager = | 1104 prerender::PrerenderManager* prerender_manager = |
| 1105 prerender::PrerenderManagerFactory::GetForProfile(tab->profile()); | 1105 prerender::PrerenderManagerFactory::GetForProfile(tab->profile()); |
| 1106 if (prerender_manager) { | 1106 if (prerender_manager) { |
| 1107 content::RenderViewHost* current_host = | 1107 content::RenderViewHost* current_host = |
| 1108 tab->web_contents()->GetRenderViewHost(); | 1108 tab->web_contents()->GetRenderViewHost(); |
| 1109 prerender_manager->AddPrerenderFromOmnibox( | 1109 prerender_manager->AddPrerenderFromOmnibox( |
| 1110 match.destination_url, current_host->GetSessionStorageNamespace()); | 1110 match.destination_url, current_host->GetSessionStorageNamespace()); |
| 1111 } | 1111 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 return metrics::OmniboxEventProto_PageClassification_INVALID_SPEC; | 1144 return metrics::OmniboxEventProto_PageClassification_INVALID_SPEC; |
| 1145 const std::string& url = gurl.spec(); | 1145 const std::string& url = gurl.spec(); |
| 1146 if (url == chrome::kChromeUINewTabURL) | 1146 if (url == chrome::kChromeUINewTabURL) |
| 1147 return metrics::OmniboxEventProto_PageClassification_NEW_TAB_PAGE; | 1147 return metrics::OmniboxEventProto_PageClassification_NEW_TAB_PAGE; |
| 1148 if (url == chrome::kAboutBlankURL) | 1148 if (url == chrome::kAboutBlankURL) |
| 1149 return metrics::OmniboxEventProto_PageClassification_BLANK; | 1149 return metrics::OmniboxEventProto_PageClassification_BLANK; |
| 1150 if (url == profile()->GetPrefs()->GetString(prefs::kHomePage)) | 1150 if (url == profile()->GetPrefs()->GetString(prefs::kHomePage)) |
| 1151 return metrics::OmniboxEventProto_PageClassification_HOMEPAGE; | 1151 return metrics::OmniboxEventProto_PageClassification_HOMEPAGE; |
| 1152 return metrics::OmniboxEventProto_PageClassification_OTHER; | 1152 return metrics::OmniboxEventProto_PageClassification_OTHER; |
| 1153 } | 1153 } |
| OLD | NEW |