| 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/search/search.h" | 5 #include "chrome/browser/search/search.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 const char kPrerenderInstantUrlOnOmniboxFocus[] = | 54 const char kPrerenderInstantUrlOnOmniboxFocus[] = |
| 55 "prerender_instant_url_on_omnibox_focus"; | 55 "prerender_instant_url_on_omnibox_focus"; |
| 56 | 56 |
| 57 // Controls whether to use the alternate Instant search base URL. This allows | 57 // Controls whether to use the alternate Instant search base URL. This allows |
| 58 // experimentation of Instant search. | 58 // experimentation of Instant search. |
| 59 const char kUseAltInstantURL[] = "use_alternate_instant_url"; | 59 const char kUseAltInstantURL[] = "use_alternate_instant_url"; |
| 60 const char kUseSearchPathForInstant[] = "use_search_path_for_instant"; | 60 const char kUseSearchPathForInstant[] = "use_search_path_for_instant"; |
| 61 const char kAltInstantURLPath[] = "search"; | 61 const char kAltInstantURLPath[] = "search"; |
| 62 const char kAltInstantURLQueryParams[] = "&qbp=1"; | 62 const char kAltInstantURLQueryParams[] = "&qbp=1"; |
| 63 | 63 |
| 64 const char kShouldShowGoogleLocalNTPFlagName[] = "google_local_ntp"; | |
| 65 | |
| 66 // Status of the New Tab URL for the default Search provider. NOTE: Used in a | 64 // Status of the New Tab URL for the default Search provider. NOTE: Used in a |
| 67 // UMA histogram so values should only be added at the end and not reordered. | 65 // UMA histogram so values should only be added at the end and not reordered. |
| 68 enum NewTabURLState { | 66 enum NewTabURLState { |
| 69 // Valid URL that should be used. | 67 // Valid URL that should be used. |
| 70 NEW_TAB_URL_VALID = 0, | 68 NEW_TAB_URL_VALID = 0, |
| 71 | 69 |
| 72 // Corrupt state (e.g. no profile or template url). | 70 // Corrupt state (e.g. no profile or template url). |
| 73 NEW_TAB_URL_BAD = 1, | 71 NEW_TAB_URL_BAD = 1, |
| 74 | 72 |
| 75 // URL should not be used because in incognito window. | 73 // URL should not be used because in incognito window. |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 | 493 |
| 496 bool ShouldPrerenderInstantUrlOnOmniboxFocus() { | 494 bool ShouldPrerenderInstantUrlOnOmniboxFocus() { |
| 497 if (!ShouldPrefetchSearchResults()) | 495 if (!ShouldPrefetchSearchResults()) |
| 498 return false; | 496 return false; |
| 499 | 497 |
| 500 FieldTrialFlags flags; | 498 FieldTrialFlags flags; |
| 501 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | 499 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( |
| 502 kPrerenderInstantUrlOnOmniboxFocus, false, flags); | 500 kPrerenderInstantUrlOnOmniboxFocus, false, flags); |
| 503 } | 501 } |
| 504 | 502 |
| 505 bool ShouldShowGoogleLocalNTP() { | |
| 506 FieldTrialFlags flags; | |
| 507 return !GetFieldTrialInfo(&flags) || GetBoolValueForFlagWithDefault( | |
| 508 kShouldShowGoogleLocalNTPFlagName, true, flags); | |
| 509 } | |
| 510 | |
| 511 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) { | 503 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) { |
| 512 CHECK(ShouldAssignURLToInstantRenderer(url, profile)) | 504 CHECK(ShouldAssignURLToInstantRenderer(url, profile)) |
| 513 << "Error granting Instant access."; | 505 << "Error granting Instant access."; |
| 514 | 506 |
| 515 if (url.SchemeIs(chrome::kChromeSearchScheme)) | 507 if (url.SchemeIs(chrome::kChromeSearchScheme)) |
| 516 return url; | 508 return url; |
| 517 | 509 |
| 518 GURL effective_url(url); | 510 GURL effective_url(url); |
| 519 | 511 |
| 520 // Replace the scheme with "chrome-search:", and clear the port, since | 512 // Replace the scheme with "chrome-search:", and clear the port, since |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 kUseAltInstantURL, false, flags); | 599 kUseAltInstantURL, false, flags); |
| 608 } | 600 } |
| 609 | 601 |
| 610 bool ShouldUseSearchPathForInstant() { | 602 bool ShouldUseSearchPathForInstant() { |
| 611 FieldTrialFlags flags; | 603 FieldTrialFlags flags; |
| 612 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | 604 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( |
| 613 kUseSearchPathForInstant, false, flags); | 605 kUseSearchPathForInstant, false, flags); |
| 614 } | 606 } |
| 615 | 607 |
| 616 } // namespace search | 608 } // namespace search |
| OLD | NEW |