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 <memory> | 7 #include <memory> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 // Called when an NTP finishes loading. If the load start time was noted, | 87 // Called when an NTP finishes loading. If the load start time was noted, |
88 // calculates and logs the total load time. | 88 // calculates and logs the total load time. |
89 void RecordNewTabLoadTime(content::WebContents* contents) { | 89 void RecordNewTabLoadTime(content::WebContents* contents) { |
90 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(contents); | 90 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(contents); |
91 if (core_tab_helper->new_tab_start_time().is_null()) | 91 if (core_tab_helper->new_tab_start_time().is_null()) |
92 return; | 92 return; |
93 | 93 |
94 base::TimeDelta duration = | 94 base::TimeDelta duration = |
95 base::TimeTicks::Now() - core_tab_helper->new_tab_start_time(); | 95 base::TimeTicks::Now() - core_tab_helper->new_tab_start_time(); |
| 96 bool is_google = google_util::IsGoogleDomainUrl( |
| 97 contents->GetController().GetLastCommittedEntry()->GetURL(), |
| 98 google_util::ALLOW_SUBDOMAIN, google_util::DISALLOW_NON_STANDARD_PORTS); |
96 if (IsCacheableNTP(contents)) { | 99 if (IsCacheableNTP(contents)) { |
97 if (google_util::IsGoogleDomainUrl( | 100 if (is_google) { |
98 contents->GetController().GetLastCommittedEntry()->GetURL(), | |
99 google_util::ALLOW_SUBDOMAIN, | |
100 google_util::DISALLOW_NON_STANDARD_PORTS)) { | |
101 UMA_HISTOGRAM_TIMES("Tab.NewTabOnload.Google", duration); | 101 UMA_HISTOGRAM_TIMES("Tab.NewTabOnload.Google", duration); |
102 } else { | 102 } else { |
103 UMA_HISTOGRAM_TIMES("Tab.NewTabOnload.Other", duration); | 103 UMA_HISTOGRAM_TIMES("Tab.NewTabOnload.Other", duration); |
104 } | 104 } |
105 } else { | 105 } else { |
106 UMA_HISTOGRAM_TIMES("Tab.NewTabOnload.Local", duration); | 106 UMA_HISTOGRAM_TIMES("Tab.NewTabOnload.Local", duration); |
| 107 if (is_google) { |
| 108 UMA_HISTOGRAM_TIMES("Tab.NewTabOnload.LocalGoogle", duration); |
| 109 } else { |
| 110 UMA_HISTOGRAM_TIMES("Tab.NewTabOnload.LocalOther", duration); |
| 111 } |
107 } | 112 } |
108 core_tab_helper->set_new_tab_start_time(base::TimeTicks()); | 113 core_tab_helper->set_new_tab_start_time(base::TimeTicks()); |
109 } | 114 } |
110 | 115 |
111 // Returns true if the user wants to sync history. This function returning true | 116 // Returns true if the user wants to sync history. This function returning true |
112 // is not a guarantee that history is being synced, but it can be used to | 117 // is not a guarantee that history is being synced, but it can be used to |
113 // disable a feature that should not be shown to users who prefer not to sync | 118 // disable a feature that should not be shown to users who prefer not to sync |
114 // their history. | 119 // their history. |
115 bool IsHistorySyncEnabled(Profile* profile) { | 120 bool IsHistorySyncEnabled(Profile* profile) { |
116 browser_sync::ProfileSyncService* sync = | 121 browser_sync::ProfileSyncService* sync = |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 return Profile::FromBrowserContext(web_contents_->GetBrowserContext()); | 491 return Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
487 } | 492 } |
488 | 493 |
489 bool SearchTabHelper::IsInputInProgress() const { | 494 bool SearchTabHelper::IsInputInProgress() const { |
490 if (model_.mode().is_ntp()) | 495 if (model_.mode().is_ntp()) |
491 return false; | 496 return false; |
492 const OmniboxView* omnibox_view = GetOmniboxView(); | 497 const OmniboxView* omnibox_view = GetOmniboxView(); |
493 return omnibox_view && | 498 return omnibox_view && |
494 omnibox_view->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; | 499 omnibox_view->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; |
495 } | 500 } |
OLD | NEW |