Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: chrome/browser/instant/search.cc

Issue 12386019: Instant: Use only one hidden WebContents per profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 191 // Since iOS and Android don't use the Instant framework, these checks are
192 // disabled for the two platforms. 192 // disabled for the two platforms.
193 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); 193 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
194 #if !defined(OS_IOS) && !defined(OS_ANDROID) 194 #if !defined(OS_IOS) && !defined(OS_ANDROID)
195 if (!IsRenderedInInstantProcess(contents, profile)) 195 if (!IsRenderedInInstantProcess(contents, profile))
196 return string16(); 196 return string16();
197 #endif // !defined(OS_IOS) && !defined(OS_ANDROID) 197 #endif // !defined(OS_IOS) && !defined(OS_ANDROID)
198 // Check to see if search terms have already been extracted. 198 // Check to see if search terms have already been extracted.
199 string16 search_terms = GetSearchTermsFromNavigationEntry(entry); 199 string16 search_terms = GetSearchTermsFromNavigationEntry(entry);
200 if (!search_terms.empty()) 200 if (!search_terms.empty())
201 return search_terms; 201 return search_terms;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 } 316 }
317 317
318 void RegisterUserPrefs(PrefRegistrySyncable* registry) { 318 void RegisterUserPrefs(PrefRegistrySyncable* registry) {
319 registry->RegisterBooleanPref(prefs::kInstantConfirmDialogShown, false, 319 registry->RegisterBooleanPref(prefs::kInstantConfirmDialogShown, false,
320 PrefRegistrySyncable::SYNCABLE_PREF); 320 PrefRegistrySyncable::SYNCABLE_PREF);
321 registry->RegisterBooleanPref(prefs::kInstantEnabled, false, 321 registry->RegisterBooleanPref(prefs::kInstantEnabled, false,
322 PrefRegistrySyncable::SYNCABLE_PREF); 322 PrefRegistrySyncable::SYNCABLE_PREF);
323 // This default is overridden by SetInstantExtendedPrefDefault(). 323 // This default is overridden by SetInstantExtendedPrefDefault().
324 registry->RegisterBooleanPref(prefs::kInstantExtendedEnabled, false, 324 registry->RegisterBooleanPref(prefs::kInstantExtendedEnabled, false,
325 PrefRegistrySyncable::SYNCABLE_PREF); 325 PrefRegistrySyncable::SYNCABLE_PREF);
326
327 // TODO(jered): Remove this.
328 registry->RegisterStringPref(prefs::kInstantUIZeroSuggestUrlPrefix, "",
329 PrefRegistrySyncable::UNSYNCABLE_PREF);
326 } 330 }
327 331
328 const char* GetInstantPrefName() { 332 const char* GetInstantPrefName() {
329 return IsInstantExtendedAPIEnabled() ? prefs::kInstantExtendedEnabled : 333 return IsInstantExtendedAPIEnabled() ? prefs::kInstantExtendedEnabled :
330 prefs::kInstantEnabled; 334 prefs::kInstantEnabled;
331 } 335 }
332 336
333 bool IsInstantPrefEnabled(Profile* profile) { 337 bool IsInstantPrefEnabled(Profile* profile) {
334 if (!profile || profile->IsOffTheRecord()) 338 if (!profile || profile->IsOffTheRecord())
335 return false; 339 return false;
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 GURL::Replacements replacements; 521 GURL::Replacements replacements;
518 replacements.SetSchemeStr(search_scheme); 522 replacements.SetSchemeStr(search_scheme);
519 replacements.SetHostStr(search_host); 523 replacements.SetHostStr(search_host);
520 replacements.SetPortStr(search_port); 524 replacements.SetPortStr(search_port);
521 replacements.SetPathStr(search_path); 525 replacements.SetPathStr(search_path);
522 return instant_url.ReplaceComponents(replacements); 526 return instant_url.ReplaceComponents(replacements);
523 } 527 }
524 528
525 } // namespace search 529 } // namespace search
526 } // namespace chrome 530 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698