| 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 "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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // the "instant" flag below have any effect. | 59 // the "instant" flag below have any effect. |
| 60 const char kAllowInstantSearchResultsFlagName[] = "allow_instant"; | 60 const char kAllowInstantSearchResultsFlagName[] = "allow_instant"; |
| 61 | 61 |
| 62 // Sets the default state for the Instant checkbox. | 62 // Sets the default state for the Instant checkbox. |
| 63 const char kInstantSearchResultsFlagName[] = "instant"; | 63 const char kInstantSearchResultsFlagName[] = "instant"; |
| 64 | 64 |
| 65 const char kLocalOnlyFlagName[] = "local_only"; | 65 const char kLocalOnlyFlagName[] = "local_only"; |
| 66 const char kPreloadLocalOnlyNTPFlagName[] = "preload_local_only_ntp"; | 66 const char kPreloadLocalOnlyNTPFlagName[] = "preload_local_only_ntp"; |
| 67 const char kUseRemoteNTPOnStartupFlagName[] = "use_remote_ntp_on_startup"; | 67 const char kUseRemoteNTPOnStartupFlagName[] = "use_remote_ntp_on_startup"; |
| 68 const char kShowNtpFlagName[] = "show_ntp"; | 68 const char kShowNtpFlagName[] = "show_ntp"; |
| 69 const char kRecentTabsOnNTPFlagName[] = "show_recent_tabs"; |
| 69 | 70 |
| 70 // Constants for the field trial name and group prefix. | 71 // Constants for the field trial name and group prefix. |
| 71 const char kInstantExtendedFieldTrialName[] = "InstantExtended"; | 72 const char kInstantExtendedFieldTrialName[] = "InstantExtended"; |
| 72 const char kGroupNumberPrefix[] = "Group"; | 73 const char kGroupNumberPrefix[] = "Group"; |
| 73 | 74 |
| 74 // If the field trial's group name ends with this string its configuration will | 75 // If the field trial's group name ends with this string its configuration will |
| 75 // be ignored and Instant Extended will not be enabled by default. | 76 // be ignored and Instant Extended will not be enabled by default. |
| 76 const char kDisablingSuffix[] = "DISABLED"; | 77 const char kDisablingSuffix[] = "DISABLED"; |
| 77 | 78 |
| 78 // Remember if we reported metrics about opt-in/out state. | 79 // Remember if we reported metrics about opt-in/out state. |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 bool ShouldShowInstantNTP() { | 559 bool ShouldShowInstantNTP() { |
| 559 FieldTrialFlags flags; | 560 FieldTrialFlags flags; |
| 560 if (GetFieldTrialInfo( | 561 if (GetFieldTrialInfo( |
| 561 base::FieldTrialList::FindFullName(kInstantExtendedFieldTrialName), | 562 base::FieldTrialList::FindFullName(kInstantExtendedFieldTrialName), |
| 562 &flags, NULL)) { | 563 &flags, NULL)) { |
| 563 return GetBoolValueForFlagWithDefault(kShowNtpFlagName, true, flags); | 564 return GetBoolValueForFlagWithDefault(kShowNtpFlagName, true, flags); |
| 564 } | 565 } |
| 565 return true; | 566 return true; |
| 566 } | 567 } |
| 567 | 568 |
| 569 bool ShouldShowRecentTabsOnNTP() { |
| 570 FieldTrialFlags flags; |
| 571 if (GetFieldTrialInfo( |
| 572 base::FieldTrialList::FindFullName(kInstantExtendedFieldTrialName), |
| 573 &flags, NULL)) { |
| 574 return GetBoolValueForFlagWithDefault( |
| 575 kRecentTabsOnNTPFlagName, false, flags); |
| 576 } |
| 577 |
| 578 return false; |
| 579 } |
| 580 |
| 568 bool MatchesOriginAndPath(const GURL& my_url, const GURL& other_url) { | 581 bool MatchesOriginAndPath(const GURL& my_url, const GURL& other_url) { |
| 569 return MatchesOrigin(my_url, other_url) && my_url.path() == other_url.path(); | 582 return MatchesOrigin(my_url, other_url) && my_url.path() == other_url.path(); |
| 570 } | 583 } |
| 571 | 584 |
| 572 GURL GetPrivilegedURLForInstant(const GURL& url, Profile* profile) { | 585 GURL GetPrivilegedURLForInstant(const GURL& url, Profile* profile) { |
| 573 CHECK(ShouldAssignURLToInstantRenderer(url, profile)) | 586 CHECK(ShouldAssignURLToInstantRenderer(url, profile)) |
| 574 << "Error granting Instant access."; | 587 << "Error granting Instant access."; |
| 575 | 588 |
| 576 if (IsPrivilegedURLForInstant(url)) | 589 if (IsPrivilegedURLForInstant(url)) |
| 577 return url; | 590 return url; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 return instant_url.is_valid() && | 758 return instant_url.is_valid() && |
| 746 (!IsInstantExtendedAPIEnabled() || | 759 (!IsInstantExtendedAPIEnabled() || |
| 747 template_url->HasSearchTermsReplacementKey(instant_url)); | 760 template_url->HasSearchTermsReplacementKey(instant_url)); |
| 748 } | 761 } |
| 749 | 762 |
| 750 void ResetInstantExtendedOptInStateGateForTest() { | 763 void ResetInstantExtendedOptInStateGateForTest() { |
| 751 instant_extended_opt_in_state_gate = false; | 764 instant_extended_opt_in_state_gate = false; |
| 752 } | 765 } |
| 753 | 766 |
| 754 } // namespace chrome | 767 } // namespace chrome |
| OLD | NEW |