| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 UMA_HISTOGRAM_TIMES("Tab.NewTabOnload.Google", duration); | 116 UMA_HISTOGRAM_TIMES("Tab.NewTabOnload.Google", duration); |
| 117 } else { | 117 } else { |
| 118 UMA_HISTOGRAM_TIMES("Tab.NewTabOnload.Other", duration); | 118 UMA_HISTOGRAM_TIMES("Tab.NewTabOnload.Other", duration); |
| 119 } | 119 } |
| 120 } else { | 120 } else { |
| 121 UMA_HISTOGRAM_TIMES("Tab.NewTabOnload.Local", duration); | 121 UMA_HISTOGRAM_TIMES("Tab.NewTabOnload.Local", duration); |
| 122 } | 122 } |
| 123 core_tab_helper->set_new_tab_start_time(base::TimeTicks()); | 123 core_tab_helper->set_new_tab_start_time(base::TimeTicks()); |
| 124 } | 124 } |
| 125 | 125 |
| 126 // Returns true if the user is signed in and full history sync is enabled, | 126 // Returns true if the user wants to sync history. This function returning true |
| 127 // and false otherwise. | 127 // is not a guarantee that history is being synced, but it can be used to |
| 128 // disable a feature that should not be shown to users who prefer not to sync |
| 129 // their history. |
| 128 bool IsHistorySyncEnabled(Profile* profile) { | 130 bool IsHistorySyncEnabled(Profile* profile) { |
| 129 ProfileSyncService* sync = | 131 ProfileSyncService* sync = |
| 130 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); | 132 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); |
| 131 return sync && | 133 return sync && |
| 132 sync->SyncActive() && | 134 sync->GetPreferredDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES); |
| 133 sync->GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES); | |
| 134 } | 135 } |
| 135 | 136 |
| 136 bool OmniboxHasFocus(OmniboxView* omnibox) { | 137 bool OmniboxHasFocus(OmniboxView* omnibox) { |
| 137 return omnibox && omnibox->model()->has_focus(); | 138 return omnibox && omnibox->model()->has_focus(); |
| 138 } | 139 } |
| 139 | 140 |
| 140 } // namespace | 141 } // namespace |
| 141 | 142 |
| 142 SearchTabHelper::SearchTabHelper(content::WebContents* web_contents) | 143 SearchTabHelper::SearchTabHelper(content::WebContents* web_contents) |
| 143 : WebContentsObserver(web_contents), | 144 : WebContentsObserver(web_contents), |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 | 590 |
| 590 bool SearchTabHelper::IsInputInProgress() const { | 591 bool SearchTabHelper::IsInputInProgress() const { |
| 591 OmniboxView* omnibox = GetOmniboxView(); | 592 OmniboxView* omnibox = GetOmniboxView(); |
| 592 return !model_.mode().is_ntp() && omnibox && | 593 return !model_.mode().is_ntp() && omnibox && |
| 593 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; | 594 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; |
| 594 } | 595 } |
| 595 | 596 |
| 596 OmniboxView* SearchTabHelper::GetOmniboxView() const { | 597 OmniboxView* SearchTabHelper::GetOmniboxView() const { |
| 597 return delegate_ ? delegate_->GetOmniboxView() : NULL; | 598 return delegate_ ? delegate_->GetOmniboxView() : NULL; |
| 598 } | 599 } |
| OLD | NEW |