Chromium Code Reviews| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 | 55 |
| 56 const char kInstantExtendedActivationName[] = "instant"; | 56 const char kInstantExtendedActivationName[] = "instant"; |
| 57 const InstantExtendedDefault kInstantExtendedActivationDefault = | 57 const InstantExtendedDefault kInstantExtendedActivationDefault = |
| 58 INSTANT_DEFAULT_ON; | 58 INSTANT_DEFAULT_ON; |
| 59 | 59 |
| 60 const char kLocalOnlyFlagName[] = "local_only"; | 60 const char kLocalOnlyFlagName[] = "local_only"; |
| 61 | 61 |
| 62 // Key for specifying local NTP behavior trials. | 62 // Key for specifying local NTP behavior trials. |
| 63 const char kLocalNTPFlagName[] = "local_ntp"; | 63 const char kLocalNTPFlagName[] = "local_ntp"; |
| 64 | 64 |
| 65 // Key for enabling the recently closed link on the local NTP. | |
| 66 const char kRecentlyClosedNTPLinkFlagName[] = "recently_closed_ntp_link"; | |
|
samarth
2013/05/03 04:52:45
show_recently_closed_ntp_link or just show_recentl
jeremycho
2013/05/03 06:30:29
Done.
| |
| 67 | |
| 65 // Constants for the field trial name and group prefix. | 68 // Constants for the field trial name and group prefix. |
| 66 const char kInstantExtendedFieldTrialName[] = "InstantExtended"; | 69 const char kInstantExtendedFieldTrialName[] = "InstantExtended"; |
| 67 const char kGroupNumberPrefix[] = "Group"; | 70 const char kGroupNumberPrefix[] = "Group"; |
| 68 | 71 |
| 69 // If the field trial's group name ends with this string its configuration will | 72 // If the field trial's group name ends with this string its configuration will |
| 70 // be ignored and Instant Extended will not be enabled by default. | 73 // be ignored and Instant Extended will not be enabled by default. |
| 71 const char kDisablingSuffix[] = "DISABLED"; | 74 const char kDisablingSuffix[] = "DISABLED"; |
| 72 | 75 |
| 73 TemplateURL* GetDefaultSearchProviderTemplateURL(Profile* profile) { | 76 TemplateURL* GetDefaultSearchProviderTemplateURL(Profile* profile) { |
| 74 TemplateURLService* template_url_service = | 77 TemplateURLService* template_url_service = |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 486 FieldTrialFlags flags; | 489 FieldTrialFlags flags; |
| 487 if (GetFieldTrialInfo( | 490 if (GetFieldTrialInfo( |
| 488 base::FieldTrialList::FindFullName(kInstantExtendedFieldTrialName), | 491 base::FieldTrialList::FindFullName(kInstantExtendedFieldTrialName), |
| 489 &flags, NULL)) { | 492 &flags, NULL)) { |
| 490 return GetBoolValueForFlagWithDefault(kLocalNTPFlagName, false, flags); | 493 return GetBoolValueForFlagWithDefault(kLocalNTPFlagName, false, flags); |
| 491 } | 494 } |
| 492 | 495 |
| 493 return false; | 496 return false; |
| 494 } | 497 } |
| 495 | 498 |
| 499 bool IsRecentlyClosedNTPLinkEnabled() { | |
| 500 FieldTrialFlags flags; | |
| 501 if (GetFieldTrialInfo( | |
| 502 base::FieldTrialList::FindFullName(kInstantExtendedFieldTrialName), | |
| 503 &flags, NULL)) { | |
| 504 return GetBoolValueForFlagWithDefault( | |
| 505 kRecentlyClosedNTPLinkFlagName, false, flags); | |
| 506 } | |
| 507 | |
| 508 return false; | |
| 509 } | |
| 510 | |
| 496 bool MatchesOriginAndPath(const GURL& my_url, const GURL& other_url) { | 511 bool MatchesOriginAndPath(const GURL& my_url, const GURL& other_url) { |
| 497 return MatchesOrigin(my_url, other_url) && my_url.path() == other_url.path(); | 512 return MatchesOrigin(my_url, other_url) && my_url.path() == other_url.path(); |
| 498 } | 513 } |
| 499 | 514 |
| 500 void EnableInstantExtendedAPIForTesting() { | 515 void EnableInstantExtendedAPIForTesting() { |
| 501 CommandLine* cl = CommandLine::ForCurrentProcess(); | 516 CommandLine* cl = CommandLine::ForCurrentProcess(); |
| 502 cl->AppendSwitch(switches::kEnableInstantExtendedAPI); | 517 cl->AppendSwitch(switches::kEnableInstantExtendedAPI); |
| 503 } | 518 } |
| 504 | 519 |
| 505 bool GetFieldTrialInfo(const std::string& group_name, | 520 bool GetFieldTrialInfo(const std::string& group_name, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 600 | 615 |
| 601 GURL instant_url = TemplateURLRefToGURL(template_url->instant_url_ref(), | 616 GURL instant_url = TemplateURLRefToGURL(template_url->instant_url_ref(), |
| 602 kDisableStartMargin); | 617 kDisableStartMargin); |
| 603 // Extended mode instant requires a search terms replacement key. | 618 // Extended mode instant requires a search terms replacement key. |
| 604 return instant_url.is_valid() && | 619 return instant_url.is_valid() && |
| 605 (!IsInstantExtendedAPIEnabled() || | 620 (!IsInstantExtendedAPIEnabled() || |
| 606 template_url->HasSearchTermsReplacementKey(instant_url)); | 621 template_url->HasSearchTermsReplacementKey(instant_url)); |
| 607 } | 622 } |
| 608 | 623 |
| 609 } // namespace chrome | 624 } // namespace chrome |
| OLD | NEW |