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