| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 const char kInstantExtendedActivationName[] = "instant"; | 62 const char kInstantExtendedActivationName[] = "instant"; |
| 63 const InstantExtendedDefault kInstantExtendedActivationDefault = | 63 const InstantExtendedDefault kInstantExtendedActivationDefault = |
| 64 INSTANT_DEFAULT_ON; | 64 INSTANT_DEFAULT_ON; |
| 65 | 65 |
| 66 const char kLocalOnlyFlagName[] = "local_only"; | 66 const char kLocalOnlyFlagName[] = "local_only"; |
| 67 | 67 |
| 68 // Key for specifying remote NTP behavior trials. | 68 // Key for specifying remote NTP behavior trials. |
| 69 const char kUseRemoteNTPOnStartupFlagName[] = "use_remote_ntp_on_startup"; | 69 const char kUseRemoteNTPOnStartupFlagName[] = "use_remote_ntp_on_startup"; |
| 70 | 70 |
| 71 // Key for showing the recent tabs link on the local NTP. |
| 72 const char kRecentTabsOnNTPFlagName[] = "show_recent_tabs"; |
| 73 |
| 71 // Constants for the field trial name and group prefix. | 74 // Constants for the field trial name and group prefix. |
| 72 const char kInstantExtendedFieldTrialName[] = "InstantExtended"; | 75 const char kInstantExtendedFieldTrialName[] = "InstantExtended"; |
| 73 const char kGroupNumberPrefix[] = "Group"; | 76 const char kGroupNumberPrefix[] = "Group"; |
| 74 | 77 |
| 75 // If the field trial's group name ends with this string its configuration will | 78 // If the field trial's group name ends with this string its configuration will |
| 76 // be ignored and Instant Extended will not be enabled by default. | 79 // be ignored and Instant Extended will not be enabled by default. |
| 77 const char kDisablingSuffix[] = "DISABLED"; | 80 const char kDisablingSuffix[] = "DISABLED"; |
| 78 | 81 |
| 79 // Remember if we reported metrics about opt-in/out state. | 82 // Remember if we reported metrics about opt-in/out state. |
| 80 bool instant_extended_opt_in_state_gate = false; | 83 bool instant_extended_opt_in_state_gate = false; |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 FieldTrialFlags flags; | 512 FieldTrialFlags flags; |
| 510 if (GetFieldTrialInfo( | 513 if (GetFieldTrialInfo( |
| 511 base::FieldTrialList::FindFullName(kInstantExtendedFieldTrialName), | 514 base::FieldTrialList::FindFullName(kInstantExtendedFieldTrialName), |
| 512 &flags, NULL)) { | 515 &flags, NULL)) { |
| 513 return GetBoolValueForFlagWithDefault(kUseRemoteNTPOnStartupFlagName, false, | 516 return GetBoolValueForFlagWithDefault(kUseRemoteNTPOnStartupFlagName, false, |
| 514 flags); | 517 flags); |
| 515 } | 518 } |
| 516 return false; | 519 return false; |
| 517 } | 520 } |
| 518 | 521 |
| 522 bool ShouldShowRecentTabsOnNTP() { |
| 523 FieldTrialFlags flags; |
| 524 if (GetFieldTrialInfo( |
| 525 base::FieldTrialList::FindFullName(kInstantExtendedFieldTrialName), |
| 526 &flags, NULL)) { |
| 527 return GetBoolValueForFlagWithDefault( |
| 528 kRecentTabsOnNTPFlagName, false, flags); |
| 529 } |
| 530 |
| 531 return false; |
| 532 } |
| 533 |
| 519 bool MatchesOriginAndPath(const GURL& my_url, const GURL& other_url) { | 534 bool MatchesOriginAndPath(const GURL& my_url, const GURL& other_url) { |
| 520 return MatchesOrigin(my_url, other_url) && my_url.path() == other_url.path(); | 535 return MatchesOrigin(my_url, other_url) && my_url.path() == other_url.path(); |
| 521 } | 536 } |
| 522 | 537 |
| 523 GURL GetPrivilegedURLForInstant(const GURL& url, Profile* profile) { | 538 GURL GetPrivilegedURLForInstant(const GURL& url, Profile* profile) { |
| 524 CHECK(ShouldAssignURLToInstantRenderer(url, profile)) | 539 CHECK(ShouldAssignURLToInstantRenderer(url, profile)) |
| 525 << "Error granting Instant access."; | 540 << "Error granting Instant access."; |
| 526 | 541 |
| 527 if (IsPrivilegedURLForInstant(url)) | 542 if (IsPrivilegedURLForInstant(url)) |
| 528 return url; | 543 return url; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 return instant_url.is_valid() && | 685 return instant_url.is_valid() && |
| 671 (!IsInstantExtendedAPIEnabled() || | 686 (!IsInstantExtendedAPIEnabled() || |
| 672 template_url->HasSearchTermsReplacementKey(instant_url)); | 687 template_url->HasSearchTermsReplacementKey(instant_url)); |
| 673 } | 688 } |
| 674 | 689 |
| 675 void ResetInstantExtendedOptInStateGateForTest() { | 690 void ResetInstantExtendedOptInStateGateForTest() { |
| 676 instant_extended_opt_in_state_gate = false; | 691 instant_extended_opt_in_state_gate = false; |
| 677 } | 692 } |
| 678 | 693 |
| 679 } // namespace chrome | 694 } // namespace chrome |
| OLD | NEW |