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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 return; | 135 return; |
136 | 136 |
137 base::TimeDelta duration = | 137 base::TimeDelta duration = |
138 base::TimeTicks::Now() - core_tab_helper->new_tab_start_time(); | 138 base::TimeTicks::Now() - core_tab_helper->new_tab_start_time(); |
139 UMA_HISTOGRAM_TIMES("Tab.NewTabOnload", duration); | 139 UMA_HISTOGRAM_TIMES("Tab.NewTabOnload", duration); |
140 core_tab_helper->set_new_tab_start_time(base::TimeTicks()); | 140 core_tab_helper->set_new_tab_start_time(base::TimeTicks()); |
141 } | 141 } |
142 | 142 |
143 // Returns the OmniboxView for |contents| or NULL if not available. | 143 // Returns the OmniboxView for |contents| or NULL if not available. |
144 OmniboxView* GetOmniboxView(content::WebContents* contents) { | 144 OmniboxView* GetOmniboxView(content::WebContents* contents) { |
145 if (!contents) | 145 // iOS and Android don't use the Instant framework. |
| 146 #if defined(OS_IOS) || defined(OS_ANDROID) |
| 147 return NULL; |
| 148 #else |
| 149 if (contents) |
146 return NULL; | 150 return NULL; |
147 | |
148 // iOS and Android don't use the Instant framework. | |
149 #if !defined(OS_IOS) && !defined(OS_ANDROID) | |
150 Browser* browser = chrome::FindBrowserWithWebContents(contents); | 151 Browser* browser = chrome::FindBrowserWithWebContents(contents); |
151 return browser ? browser->window()->GetLocationBar()->GetOmniboxView() : NULL; | 152 return browser ? browser->window()->GetLocationBar()->GetOmniboxView() : NULL; |
152 #endif | 153 #endif |
153 return NULL; | |
154 } | 154 } |
155 | 155 |
156 } // namespace | 156 } // namespace |
157 | 157 |
158 SearchTabHelper::SearchTabHelper(content::WebContents* web_contents) | 158 SearchTabHelper::SearchTabHelper(content::WebContents* web_contents) |
159 : WebContentsObserver(web_contents), | 159 : WebContentsObserver(web_contents), |
160 is_search_enabled_(chrome::IsInstantExtendedAPIEnabled()), | 160 is_search_enabled_(chrome::IsInstantExtendedAPIEnabled()), |
161 web_contents_(web_contents), | 161 web_contents_(web_contents), |
162 ipc_router_(web_contents, this, | 162 ipc_router_(web_contents, this, |
163 make_scoped_ptr(new SearchIPCRouterPolicyImpl(web_contents)) | 163 make_scoped_ptr(new SearchIPCRouterPolicyImpl(web_contents)) |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 // Don't push a history entry. | 630 // Don't push a history entry. |
631 load_params.should_replace_current_entry = true; | 631 load_params.should_replace_current_entry = true; |
632 web_contents_->GetController().LoadURLWithParams(load_params); | 632 web_contents_->GetController().LoadURLWithParams(load_params); |
633 } | 633 } |
634 | 634 |
635 bool SearchTabHelper::IsInputInProgress() const { | 635 bool SearchTabHelper::IsInputInProgress() const { |
636 OmniboxView* omnibox = GetOmniboxView(web_contents()); | 636 OmniboxView* omnibox = GetOmniboxView(web_contents()); |
637 return !model_.mode().is_ntp() && omnibox && | 637 return !model_.mode().is_ntp() && omnibox && |
638 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; | 638 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; |
639 } | 639 } |
OLD | NEW |