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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 } | 295 } |
296 | 296 |
297 bool NavEntryIsInstantNTP(const content::WebContents* contents, | 297 bool NavEntryIsInstantNTP(const content::WebContents* contents, |
298 const content::NavigationEntry* entry) { | 298 const content::NavigationEntry* entry) { |
299 if (!contents || !entry) | 299 if (!contents || !entry) |
300 return false; | 300 return false; |
301 | 301 |
302 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); | 302 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); |
303 return IsInstantExtendedAPIEnabled() && | 303 return IsInstantExtendedAPIEnabled() && |
304 IsRenderedInInstantProcess(contents, profile) && | 304 IsRenderedInInstantProcess(contents, profile) && |
305 IsInstantURL(entry->GetVirtualURL(), profile) && | 305 (IsInstantURL(entry->GetVirtualURL(), profile) || |
306 entry->GetVirtualURL() == GURL(chrome::kChromeSearchLocalNTPURL)) && | |
samarth
2013/03/15 22:14:29
Please add a unit test for the changes in this fil
jeremycho
2013/03/16 00:09:56
Done.
| |
306 GetSearchTermsImpl(contents, entry).empty(); | 307 GetSearchTermsImpl(contents, entry).empty(); |
307 } | 308 } |
308 | 309 |
309 bool ShouldAssignURLToInstantRenderer(const GURL& url, Profile* profile) { | 310 bool ShouldAssignURLToInstantRenderer(const GURL& url, Profile* profile) { |
310 return url.is_valid() && | 311 return url.is_valid() && |
311 profile && | 312 profile && |
312 (url.SchemeIs(chrome::kChromeSearchScheme) || | 313 (url.SchemeIs(chrome::kChromeSearchScheme) || |
313 IsInstantURL(url, profile) || | 314 IsInstantURL(url, profile) || |
314 (IsInstantExtendedAPIEnabled() && | 315 (IsInstantExtendedAPIEnabled() && |
315 url == GURL(kLocalOmniboxPopupURL))); | 316 (url == GURL(kLocalOmniboxPopupURL) || |
317 url == GURL(chrome::kChromeSearchLocalNTPURL)))); | |
316 } | 318 } |
317 | 319 |
318 void RegisterUserPrefs(PrefRegistrySyncable* registry) { | 320 void RegisterUserPrefs(PrefRegistrySyncable* registry) { |
319 registry->RegisterBooleanPref(prefs::kInstantConfirmDialogShown, false, | 321 registry->RegisterBooleanPref(prefs::kInstantConfirmDialogShown, false, |
320 PrefRegistrySyncable::SYNCABLE_PREF); | 322 PrefRegistrySyncable::SYNCABLE_PREF); |
321 registry->RegisterBooleanPref(prefs::kInstantEnabled, false, | 323 registry->RegisterBooleanPref(prefs::kInstantEnabled, false, |
322 PrefRegistrySyncable::SYNCABLE_PREF); | 324 PrefRegistrySyncable::SYNCABLE_PREF); |
323 // This default is overridden by SetInstantExtendedPrefDefault(). | 325 // This default is overridden by SetInstantExtendedPrefDefault(). |
324 registry->RegisterBooleanPref(prefs::kInstantExtendedEnabled, false, | 326 registry->RegisterBooleanPref(prefs::kInstantExtendedEnabled, false, |
325 PrefRegistrySyncable::SYNCABLE_PREF); | 327 PrefRegistrySyncable::SYNCABLE_PREF); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
517 GURL::Replacements replacements; | 519 GURL::Replacements replacements; |
518 replacements.SetSchemeStr(search_scheme); | 520 replacements.SetSchemeStr(search_scheme); |
519 replacements.SetHostStr(search_host); | 521 replacements.SetHostStr(search_host); |
520 replacements.SetPortStr(search_port); | 522 replacements.SetPortStr(search_port); |
521 replacements.SetPathStr(search_path); | 523 replacements.SetPathStr(search_path); |
522 return instant_url.ReplaceComponents(replacements); | 524 return instant_url.ReplaceComponents(replacements); |
523 } | 525 } |
524 | 526 |
525 } // namespace search | 527 } // namespace search |
526 } // namespace chrome | 528 } // namespace chrome |
OLD | NEW |