| 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/toolbar/toolbar_model_impl.h" | 5 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/autocomplete/autocomplete_input.h" | 8 #include "chrome/browser/autocomplete/autocomplete_input.h" |
| 9 #include "chrome/browser/google/google_util.h" | 9 #include "chrome/browser/google/google_util.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 // toolbar during window creation (i.e. before any tabs have been added | 208 // toolbar during window creation (i.e. before any tabs have been added |
| 209 // to the window). | 209 // to the window). |
| 210 WebContents* current_tab = delegate_->GetActiveWebContents(); | 210 WebContents* current_tab = delegate_->GetActiveWebContents(); |
| 211 return current_tab ? ¤t_tab->GetController() : NULL; | 211 return current_tab ? ¤t_tab->GetController() : NULL; |
| 212 } | 212 } |
| 213 | 213 |
| 214 string16 ToolbarModelImpl::TryToExtractSearchTermsFromURL() const { | 214 string16 ToolbarModelImpl::TryToExtractSearchTermsFromURL() const { |
| 215 const GURL& url = GetURL(); | 215 const GURL& url = GetURL(); |
| 216 Profile* profile = GetProfile(); | 216 Profile* profile = GetProfile(); |
| 217 | 217 |
| 218 // Ensure query extraction is enabled and query URL is HTTPS. | 218 // Ensure instant extended API is enabled and query URL is HTTPS. |
| 219 if (!profile || !chrome::search::IsQueryExtractionEnabled(profile) || | 219 if (!profile || !chrome::search::IsQueryExtractionEnabled(profile) || |
| 220 !url.SchemeIs(chrome::kHttpsScheme) || | 220 !url.SchemeIs(chrome::kHttpsScheme)) |
| 221 !google_util::IsInstantExtendedAPIGoogleSearchUrl(url.spec())) | |
| 222 return string16(); | 221 return string16(); |
| 223 | 222 |
| 224 TemplateURLService* template_url_service = | 223 TemplateURLService* template_url_service = |
| 225 TemplateURLServiceFactory::GetForProfile(profile); | 224 TemplateURLServiceFactory::GetForProfile(profile); |
| 226 | 225 |
| 227 TemplateURL *template_url = template_url_service->GetDefaultSearchProvider(); | 226 TemplateURL* template_url = template_url_service->GetDefaultSearchProvider(); |
| 228 if (!template_url) | 227 if (!template_url) |
| 229 return string16(); | 228 return string16(); |
| 230 | 229 |
| 231 string16 result; | 230 string16 result; |
| 232 template_url->ExtractSearchTermsFromURL(url, &result); | 231 template_url->ExtractSearchTermsFromURL(url, &result, true); |
| 233 return result; | 232 return result; |
| 234 } | 233 } |
| 235 | 234 |
| 236 Profile* ToolbarModelImpl::GetProfile() const { | 235 Profile* ToolbarModelImpl::GetProfile() const { |
| 237 NavigationController* navigation_controller = GetNavigationController(); | 236 NavigationController* navigation_controller = GetNavigationController(); |
| 238 return navigation_controller ? | 237 return navigation_controller ? |
| 239 Profile::FromBrowserContext(navigation_controller->GetBrowserContext()) : | 238 Profile::FromBrowserContext(navigation_controller->GetBrowserContext()) : |
| 240 NULL; | 239 NULL; |
| 241 } | 240 } |
| OLD | NEW |