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 <set> | 8 #include <set> |
8 | 9 |
9 #include "base/macros.h" | 10 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/ptr_util.h" |
11 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
12 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
13 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
15 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/search/instant_service.h" | 18 #include "chrome/browser/search/instant_service.h" |
18 #include "chrome/browser/search/instant_service_factory.h" | 19 #include "chrome/browser/search/instant_service_factory.h" |
19 #include "chrome/browser/search/search.h" | 20 #include "chrome/browser/search/search.h" |
20 #include "chrome/browser/signin/signin_manager_factory.h" | 21 #include "chrome/browser/signin/signin_manager_factory.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 bool OmniboxHasFocus(OmniboxView* omnibox) { | 142 bool OmniboxHasFocus(OmniboxView* omnibox) { |
142 return omnibox && omnibox->model()->has_focus(); | 143 return omnibox && omnibox->model()->has_focus(); |
143 } | 144 } |
144 | 145 |
145 } // namespace | 146 } // namespace |
146 | 147 |
147 SearchTabHelper::SearchTabHelper(content::WebContents* web_contents) | 148 SearchTabHelper::SearchTabHelper(content::WebContents* web_contents) |
148 : WebContentsObserver(web_contents), | 149 : WebContentsObserver(web_contents), |
149 is_search_enabled_(search::IsInstantExtendedAPIEnabled()), | 150 is_search_enabled_(search::IsInstantExtendedAPIEnabled()), |
150 web_contents_(web_contents), | 151 web_contents_(web_contents), |
151 ipc_router_(web_contents, | 152 ipc_router_( |
152 this, | 153 web_contents, |
153 make_scoped_ptr(new SearchIPCRouterPolicyImpl(web_contents))), | 154 this, |
| 155 base::WrapUnique(new SearchIPCRouterPolicyImpl(web_contents))), |
154 instant_service_(NULL), | 156 instant_service_(NULL), |
155 delegate_(NULL), | 157 delegate_(NULL), |
156 omnibox_has_focus_fn_(&OmniboxHasFocus) { | 158 omnibox_has_focus_fn_(&OmniboxHasFocus) { |
157 if (!is_search_enabled_) | 159 if (!is_search_enabled_) |
158 return; | 160 return; |
159 | 161 |
160 instant_service_ = | 162 instant_service_ = |
161 InstantServiceFactory::GetForProfile( | 163 InstantServiceFactory::GetForProfile( |
162 Profile::FromBrowserContext(web_contents_->GetBrowserContext())); | 164 Profile::FromBrowserContext(web_contents_->GetBrowserContext())); |
163 if (instant_service_) | 165 if (instant_service_) |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 | 592 |
591 bool SearchTabHelper::IsInputInProgress() const { | 593 bool SearchTabHelper::IsInputInProgress() const { |
592 OmniboxView* omnibox = GetOmniboxView(); | 594 OmniboxView* omnibox = GetOmniboxView(); |
593 return !model_.mode().is_ntp() && omnibox && | 595 return !model_.mode().is_ntp() && omnibox && |
594 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; | 596 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; |
595 } | 597 } |
596 | 598 |
597 OmniboxView* SearchTabHelper::GetOmniboxView() const { | 599 OmniboxView* SearchTabHelper::GetOmniboxView() const { |
598 return delegate_ ? delegate_->GetOmniboxView() : NULL; | 600 return delegate_ ? delegate_->GetOmniboxView() : NULL; |
599 } | 601 } |
OLD | NEW |