Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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.h" | 5 #include "chrome/browser/ui/search/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/string_split.h" | 9 #include "base/string_split.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 return search_terms; | 185 return search_terms; |
| 186 } | 186 } |
| 187 | 187 |
| 188 string16 GetSearchTerms(const content::WebContents* contents) { | 188 string16 GetSearchTerms(const content::WebContents* contents) { |
| 189 if (!contents) | 189 if (!contents) |
| 190 return string16(); | 190 return string16(); |
| 191 | 191 |
| 192 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); | 192 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); |
| 193 if (!IsQueryExtractionEnabled(profile)) | 193 if (!IsQueryExtractionEnabled(profile)) |
| 194 return string16(); | 194 return string16(); |
| 195 | 195 #if !defined(OS_IOS) && !defined(OS_ANDROID) |
|
Ted C
2013/03/01 02:50:21
Should we add a comment that IOS and Android do no
Yusuf
2013/03/01 18:58:20
Added comment.
On 2013/03/01 02:50:21, Ted C wrot
| |
| 196 // For security reasons, don't extract search terms if the page is not being | 196 // For security reasons, don't extract search terms if the page is not being |
| 197 // rendered in the privileged Instant renderer process. This is to protect | 197 // rendered in the privileged Instant renderer process. This is to protect |
| 198 // against a malicious page somehow scripting the search results page and | 198 // against a malicious page somehow scripting the search results page and |
| 199 // faking search terms in the URL. Random pages can't get into the Instant | 199 // faking search terms in the URL. Random pages can't get into the Instant |
| 200 // renderer and scripting doesn't work cross-process, so if the page is in | 200 // renderer and scripting doesn't work cross-process, so if the page is in |
| 201 // the Instant process, we know it isn't being exploited. | 201 // the Instant process, we know it isn't being exploited. |
| 202 const content::RenderProcessHost* process_host = | 202 const content::RenderProcessHost* process_host = |
| 203 contents->GetRenderProcessHost(); | 203 contents->GetRenderProcessHost(); |
| 204 if (!process_host) | 204 if (!process_host) |
| 205 return string16(); | 205 return string16(); |
| 206 | 206 |
| 207 const InstantService* instant_service = | 207 const InstantService* instant_service = |
| 208 InstantServiceFactory::GetForProfile(profile); | 208 InstantServiceFactory::GetForProfile(profile); |
| 209 if (!instant_service) | 209 if (!instant_service) |
| 210 return string16(); | 210 return string16(); |
| 211 | 211 |
| 212 if (!instant_service->IsInstantProcess(process_host->GetID())) | 212 if (!instant_service->IsInstantProcess(process_host->GetID())) |
| 213 return string16(); | 213 return string16(); |
| 214 | 214 #endif |
|
dhollowa
2013/03/01 00:35:51
nit: // !defined(OS_IOS) && !defined(OS_ANDROID)
Yusuf
2013/03/01 18:58:20
Done.
| |
| 215 // Check to see if search terms have already been extracted. | 215 // Check to see if search terms have already been extracted. |
| 216 const content::NavigationEntry* entry = | 216 const content::NavigationEntry* entry = |
| 217 contents->GetController().GetVisibleEntry(); | 217 contents->GetController().GetVisibleEntry(); |
| 218 if (!entry) | 218 if (!entry) |
| 219 return string16(); | 219 return string16(); |
| 220 | 220 |
| 221 string16 search_terms = GetSearchTermsFromNavigationEntry(entry); | 221 string16 search_terms = GetSearchTermsFromNavigationEntry(entry); |
| 222 if (!search_terms.empty()) | 222 if (!search_terms.empty()) |
| 223 return search_terms; | 223 return search_terms; |
| 224 | 224 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 // Given a FieldTrialFlags object, returns the boolean value of the provided | 365 // Given a FieldTrialFlags object, returns the boolean value of the provided |
| 366 // flag. | 366 // flag. |
| 367 bool GetBoolValueForFlagWithDefault(const std::string& flag, | 367 bool GetBoolValueForFlagWithDefault(const std::string& flag, |
| 368 bool default_value, | 368 bool default_value, |
| 369 const FieldTrialFlags& flags) { | 369 const FieldTrialFlags& flags) { |
| 370 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); | 370 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); |
| 371 } | 371 } |
| 372 | 372 |
| 373 } // namespace search | 373 } // namespace search |
| 374 } // namespace chrome | 374 } // namespace chrome |
| OLD | NEW |