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/search/search_tab_helper.h" | 5 #include "chrome/browser/ui/search/search_tab_helper.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/ui/location_bar/location_bar.h" | 24 #include "chrome/browser/ui/location_bar/location_bar.h" |
25 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 25 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
26 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 26 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
27 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 27 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
28 #include "chrome/browser/ui/search/instant_search_prerenderer.h" | 28 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
29 #include "chrome/browser/ui/search/search_ipc_router_policy_impl.h" | 29 #include "chrome/browser/ui/search/search_ipc_router_policy_impl.h" |
30 #include "chrome/browser/ui/search/search_tab_helper_delegate.h" | 30 #include "chrome/browser/ui/search/search_tab_helper_delegate.h" |
31 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 31 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
32 #include "chrome/browser/ui/webui/ntp/ntp_user_data_logger.h" | 32 #include "chrome/browser/ui/webui/ntp/ntp_user_data_logger.h" |
33 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
| 34 #include "components/google/core/browser/google_util.h" |
34 #include "components/search/search.h" | 35 #include "components/search/search.h" |
35 #include "components/signin/core/browser/signin_manager.h" | 36 #include "components/signin/core/browser/signin_manager.h" |
36 #include "content/public/browser/navigation_controller.h" | 37 #include "content/public/browser/navigation_controller.h" |
37 #include "content/public/browser/navigation_details.h" | 38 #include "content/public/browser/navigation_details.h" |
38 #include "content/public/browser/navigation_entry.h" | 39 #include "content/public/browser/navigation_entry.h" |
39 #include "content/public/browser/navigation_type.h" | 40 #include "content/public/browser/navigation_type.h" |
40 #include "content/public/browser/notification_service.h" | 41 #include "content/public/browser/notification_service.h" |
41 #include "content/public/browser/notification_source.h" | 42 #include "content/public/browser/notification_source.h" |
42 #include "content/public/browser/render_frame_host.h" | 43 #include "content/public/browser/render_frame_host.h" |
43 #include "content/public/browser/render_process_host.h" | 44 #include "content/public/browser/render_process_host.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 114 |
114 // Called when an NTP finishes loading. If the load start time was noted, | 115 // Called when an NTP finishes loading. If the load start time was noted, |
115 // calculates and logs the total load time. | 116 // calculates and logs the total load time. |
116 void RecordNewTabLoadTime(content::WebContents* contents) { | 117 void RecordNewTabLoadTime(content::WebContents* contents) { |
117 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(contents); | 118 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(contents); |
118 if (core_tab_helper->new_tab_start_time().is_null()) | 119 if (core_tab_helper->new_tab_start_time().is_null()) |
119 return; | 120 return; |
120 | 121 |
121 base::TimeDelta duration = | 122 base::TimeDelta duration = |
122 base::TimeTicks::Now() - core_tab_helper->new_tab_start_time(); | 123 base::TimeTicks::Now() - core_tab_helper->new_tab_start_time(); |
123 UMA_HISTOGRAM_TIMES("Tab.NewTabOnload", duration); | 124 if (IsCacheableNTP(contents)) { |
| 125 if (google_util::IsGoogleDomainUrl( |
| 126 contents->GetController().GetLastCommittedEntry()->GetURL(), |
| 127 google_util::ALLOW_SUBDOMAIN, |
| 128 google_util::DISALLOW_NON_STANDARD_PORTS)) { |
| 129 UMA_HISTOGRAM_TIMES("Tab.NewTabOnload.Google", duration); |
| 130 } else { |
| 131 UMA_HISTOGRAM_TIMES("Tab.NewTabOnload.Other", duration); |
| 132 } |
| 133 } else { |
| 134 UMA_HISTOGRAM_TIMES("Tab.NewTabOnload.Local", duration); |
| 135 } |
124 core_tab_helper->set_new_tab_start_time(base::TimeTicks()); | 136 core_tab_helper->set_new_tab_start_time(base::TimeTicks()); |
125 } | 137 } |
126 | 138 |
127 // Returns true if the user is signed in and full history sync is enabled, | 139 // Returns true if the user is signed in and full history sync is enabled, |
128 // and false otherwise. | 140 // and false otherwise. |
129 bool IsHistorySyncEnabled(Profile* profile) { | 141 bool IsHistorySyncEnabled(Profile* profile) { |
130 ProfileSyncService* sync = | 142 ProfileSyncService* sync = |
131 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); | 143 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); |
132 return sync && | 144 return sync && |
133 sync->sync_initialized() && | 145 sync->sync_initialized() && |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 | 628 |
617 bool SearchTabHelper::IsInputInProgress() const { | 629 bool SearchTabHelper::IsInputInProgress() const { |
618 OmniboxView* omnibox = GetOmniboxView(); | 630 OmniboxView* omnibox = GetOmniboxView(); |
619 return !model_.mode().is_ntp() && omnibox && | 631 return !model_.mode().is_ntp() && omnibox && |
620 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; | 632 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; |
621 } | 633 } |
622 | 634 |
623 OmniboxView* SearchTabHelper::GetOmniboxView() const { | 635 OmniboxView* SearchTabHelper::GetOmniboxView() const { |
624 return delegate_ ? delegate_->GetOmniboxView() : NULL; | 636 return delegate_ ? delegate_->GetOmniboxView() : NULL; |
625 } | 637 } |
OLD | NEW |