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/search/search.h" | 5 #include "chrome/browser/search/search.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 const TemplateURLRef& instant_url_ref = template_url->instant_url_ref(); | 176 const TemplateURLRef& instant_url_ref = template_url->instant_url_ref(); |
177 UIThreadSearchTermsData search_terms_data(profile); | 177 UIThreadSearchTermsData search_terms_data(profile); |
178 const GURL instant_url = TemplateURLRefToGURL( | 178 const GURL instant_url = TemplateURLRefToGURL( |
179 instant_url_ref, search_terms_data, false, false); | 179 instant_url_ref, search_terms_data, false, false); |
180 if (!instant_url.is_valid()) | 180 if (!instant_url.is_valid()) |
181 return false; | 181 return false; |
182 | 182 |
183 return MatchesOriginAndPath(url, instant_url); | 183 return MatchesOriginAndPath(url, instant_url); |
184 } | 184 } |
185 | 185 |
186 base::string16 GetSearchTermsImpl(const content::WebContents* contents, | |
187 const content::NavigationEntry* entry) { | |
188 // TODO(treib): Remove this and update callers accordingly. crbug.com/627747 | |
189 return base::string16(); | |
190 } | |
191 | |
192 bool IsURLAllowedForSupervisedUser(const GURL& url, Profile* profile) { | 186 bool IsURLAllowedForSupervisedUser(const GURL& url, Profile* profile) { |
193 #if defined(ENABLE_SUPERVISED_USERS) | 187 #if defined(ENABLE_SUPERVISED_USERS) |
194 SupervisedUserService* supervised_user_service = | 188 SupervisedUserService* supervised_user_service = |
195 SupervisedUserServiceFactory::GetForProfile(profile); | 189 SupervisedUserServiceFactory::GetForProfile(profile); |
196 SupervisedUserURLFilter* url_filter = | 190 SupervisedUserURLFilter* url_filter = |
197 supervised_user_service->GetURLFilterForUIThread(); | 191 supervised_user_service->GetURLFilterForUIThread(); |
198 if (url_filter->GetFilteringBehaviorForURL(url) == | 192 if (url_filter->GetFilteringBehaviorForURL(url) == |
199 SupervisedUserURLFilter::BLOCK) { | 193 SupervisedUserURLFilter::BLOCK) { |
200 return false; | 194 return false; |
201 } | 195 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 } | 288 } |
295 | 289 |
296 TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile); | 290 TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile); |
297 base::string16 search_terms; | 291 base::string16 search_terms; |
298 if (template_url) | 292 if (template_url) |
299 template_url->ExtractSearchTermsFromURL( | 293 template_url->ExtractSearchTermsFromURL( |
300 url, UIThreadSearchTermsData(profile), &search_terms); | 294 url, UIThreadSearchTermsData(profile), &search_terms); |
301 return search_terms; | 295 return search_terms; |
302 } | 296 } |
303 | 297 |
304 bool IsQueryExtractionAllowedForURL(Profile* profile, const GURL& url) { | 298 bool IsQueryExtractionAllowedForURL(Profile* profile, const GURL& url) { |
Peter Kasting
2016/08/13 05:03:44
Eventually you'll want to rip out this, IsSuitable
Marc Treib
2016/08/16 12:00:17
Yup, probably. But as of now, it's still used in a
| |
305 TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile); | 299 TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile); |
306 return template_url && IsSuitableURLForInstant(url, template_url); | 300 return template_url && IsSuitableURLForInstant(url, template_url); |
307 } | 301 } |
308 | 302 |
309 base::string16 GetSearchTermsFromNavigationEntry( | |
310 const content::NavigationEntry* entry) { | |
311 base::string16 search_terms; | |
312 if (entry) | |
313 entry->GetExtraData(sessions::kSearchTermsKey, &search_terms); | |
314 return search_terms; | |
315 } | |
316 | |
317 base::string16 GetSearchTerms(const content::WebContents* contents) { | |
318 if (!contents) | |
319 return base::string16(); | |
320 | |
321 const content::NavigationEntry* entry = | |
322 contents->GetController().GetVisibleEntry(); | |
323 if (!entry) | |
324 return base::string16(); | |
325 | |
326 if (IsInstantExtendedAPIEnabled()) { | |
327 InstantSupportState state = | |
328 GetInstantSupportStateFromNavigationEntry(*entry); | |
Peter Kasting
2016/08/13 05:03:44
This was the only caller of this function, so it s
Marc Treib
2016/08/16 12:00:17
Thanks! Done.
| |
329 if (state == INSTANT_SUPPORT_NO) | |
330 return base::string16(); | |
331 } | |
332 | |
333 return GetSearchTermsImpl(contents, entry); | |
334 } | |
335 | |
336 bool ShouldAssignURLToInstantRenderer(const GURL& url, Profile* profile) { | 303 bool ShouldAssignURLToInstantRenderer(const GURL& url, Profile* profile) { |
337 return url.is_valid() && | 304 return url.is_valid() && |
338 profile && | 305 profile && |
339 IsInstantExtendedAPIEnabled() && | 306 IsInstantExtendedAPIEnabled() && |
340 (url.SchemeIs(chrome::kChromeSearchScheme) || | 307 (url.SchemeIs(chrome::kChromeSearchScheme) || |
341 IsInstantURL(url, profile)); | 308 IsInstantURL(url, profile)); |
342 } | 309 } |
343 | 310 |
344 bool IsRenderedInInstantProcess(const content::WebContents* contents, | 311 bool IsRenderedInInstantProcess(const content::WebContents* contents, |
345 Profile* profile) { | 312 Profile* profile) { |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
564 kUseAltInstantURL, false, flags); | 531 kUseAltInstantURL, false, flags); |
565 } | 532 } |
566 | 533 |
567 bool ShouldUseSearchPathForInstant() { | 534 bool ShouldUseSearchPathForInstant() { |
568 FieldTrialFlags flags; | 535 FieldTrialFlags flags; |
569 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | 536 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( |
570 kUseSearchPathForInstant, false, flags); | 537 kUseSearchPathForInstant, false, flags); |
571 } | 538 } |
572 | 539 |
573 } // namespace search | 540 } // namespace search |
OLD | NEW |