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/instant/search.h" | 5 #include "chrome/browser/instant/search.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 const content::NavigationEntry* entry) { | 181 const content::NavigationEntry* entry) { |
182 if (!IsQueryExtractionEnabled()) | 182 if (!IsQueryExtractionEnabled()) |
183 return string16(); | 183 return string16(); |
184 | 184 |
185 // For security reasons, don't extract search terms if the page is not being | 185 // For security reasons, don't extract search terms if the page is not being |
186 // rendered in the privileged Instant renderer process. This is to protect | 186 // rendered in the privileged Instant renderer process. This is to protect |
187 // against a malicious page somehow scripting the search results page and | 187 // against a malicious page somehow scripting the search results page and |
188 // faking search terms in the URL. Random pages can't get into the Instant | 188 // faking search terms in the URL. Random pages can't get into the Instant |
189 // renderer and scripting doesn't work cross-process, so if the page is in | 189 // renderer and scripting doesn't work cross-process, so if the page is in |
190 // the Instant process, we know it isn't being exploited. | 190 // the Instant process, we know it isn't being exploited. |
| 191 // Since iOS and Android doesn't use the instant framework, these checks are |
| 192 // disabled for the two platforms. |
191 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); | 193 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); |
| 194 #if !defined(OS_IOS) && !defined(OS_ANDROID) |
192 if (!IsRenderedInInstantProcess(contents, profile)) | 195 if (!IsRenderedInInstantProcess(contents, profile)) |
193 return string16(); | 196 return string16(); |
194 | 197 #endif // !defined(OS_IOS) && !defined(OS_ANDROID) |
195 // Check to see if search terms have already been extracted. | 198 // Check to see if search terms have already been extracted. |
196 string16 search_terms = GetSearchTermsFromNavigationEntry(entry); | 199 string16 search_terms = GetSearchTermsFromNavigationEntry(entry); |
197 if (!search_terms.empty()) | 200 if (!search_terms.empty()) |
198 return search_terms; | 201 return search_terms; |
199 | 202 |
200 // Otherwise, extract from the URL. | 203 // Otherwise, extract from the URL. |
201 TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile); | 204 TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile); |
202 if (!template_url) | 205 if (!template_url) |
203 return string16(); | 206 return string16(); |
204 | 207 |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 GURL::Replacements replacements; | 517 GURL::Replacements replacements; |
515 replacements.SetSchemeStr(search_scheme); | 518 replacements.SetSchemeStr(search_scheme); |
516 replacements.SetHostStr(search_host); | 519 replacements.SetHostStr(search_host); |
517 replacements.SetPortStr(search_port); | 520 replacements.SetPortStr(search_port); |
518 replacements.SetPathStr(search_path); | 521 replacements.SetPathStr(search_path); |
519 return instant_url.ReplaceComponents(replacements); | 522 return instant_url.ReplaceComponents(replacements); |
520 } | 523 } |
521 | 524 |
522 } // namespace search | 525 } // namespace search |
523 } // namespace chrome | 526 } // namespace chrome |
OLD | NEW |