Chromium Code Reviews| Index: components/offline_pages/offline_page_feature.cc |
| diff --git a/components/offline_pages/offline_page_feature.cc b/components/offline_pages/offline_page_feature.cc |
| index 114c0dbe9156120c27f55bed06371210918a345f..bb58d9b2caa0edfe8d48d4caac5431d5593118cb 100644 |
| --- a/components/offline_pages/offline_page_feature.cc |
| +++ b/components/offline_pages/offline_page_feature.cc |
| @@ -6,90 +6,39 @@ |
| #include <string> |
| -#include "base/command_line.h" |
| #include "base/feature_list.h" |
| -#include "base/metrics/field_trial.h" |
| -#include "base/strings/string_util.h" |
| -#include "build/build_config.h" |
| -#include "components/offline_pages/offline_page_switches.h" |
| -#include "components/version_info/version_info.h" |
| namespace offline_pages { |
| -namespace { |
| -const char kOfflinePagesFieldTrialName[] = "OfflinePages"; |
| -// The old experiment has only one mode to enable offline pages. |
| -const char kEnabledGroupName[] = "Enabled"; |
| -// The new experiment supports two modes for offline pages. |
| -const char kEnabledAsBookmarksGroupName[] = "EnabledAsBookmarks"; |
| -const char kEnabledAsSavedPagesGroupName[] = "EnabledAsSavedPages"; |
| -} // namespace |
| +const base::Feature kOfflineBookmarksFeature { |
| + "OfflineBookmarks", base::FEATURE_DISABLED_BY_DEFAULT |
| +}; |
| const base::Feature kOffliningRecentPagesFeature { |
| - "offline-recent-pages", base::FEATURE_DISABLED_BY_DEFAULT |
| + "OfflineRecentPages", base::FEATURE_DISABLED_BY_DEFAULT |
| }; |
| const base::Feature kOfflinePagesBackgroundLoadingFeature { |
| - "offline-pages-background-loading", base::FEATURE_DISABLED_BY_DEFAULT |
| + "OfflinePagesBackgroundLoading", base::FEATURE_DISABLED_BY_DEFAULT |
| }; |
| -FeatureMode GetOfflinePageFeatureMode() { |
| - // Note: It's important to query the field trial state first, to ensure that |
| - // UMA reports the correct group. |
| - std::string group_name = |
| - base::FieldTrialList::FindFullName(kOfflinePagesFieldTrialName); |
| - |
| - // The old experiment 'Enabled' defaults to showing saved page. |
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kEnableOfflinePages)) { |
| - return FeatureMode::ENABLED_AS_SAVED_PAGES; |
| - } |
| - // The new experiment can control showing either bookmark or saved page. |
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kEnableOfflinePagesAsBookmarks)) { |
| - return FeatureMode::ENABLED_AS_BOOKMARKS; |
| - } |
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kEnableOfflinePagesAsSavedPages)) { |
| - return FeatureMode::ENABLED_AS_SAVED_PAGES; |
| - } |
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kDisableOfflinePages)) { |
| - return FeatureMode::DISABLED; |
| - } |
| - |
| - // The old experiment 'Enabled' defaults to showing saved page. |
| - if (group_name == kEnabledGroupName) |
| - return FeatureMode::ENABLED_AS_SAVED_PAGES; |
| - // The new experiment can control showing either bookmark or saved page. |
| - if (base::StartsWith(group_name, kEnabledAsBookmarksGroupName, |
| - base::CompareCase::SENSITIVE)) { |
| - return FeatureMode::ENABLED_AS_BOOKMARKS; |
| - } |
| - if (base::StartsWith(group_name, kEnabledAsSavedPagesGroupName, |
| - base::CompareCase::SENSITIVE)) { |
| - return FeatureMode::ENABLED_AS_SAVED_PAGES; |
| - } |
| - |
| - // Enabled by default on trunk. |
| - return version_info::IsOfficialBuild() ? FeatureMode::DISABLED |
| - : FeatureMode::ENABLED_AS_BOOKMARKS; |
| +bool IsOfflinePagesEnabled() { |
| + return IsOfflineBookmarksEnabled() || IsOffliningRecentPagesEnabled() || |
| + IsOfflinePagesBackgroundLoadingEnabled(); |
| } |
| -bool IsOfflinePagesEnabled() { |
| - FeatureMode mode = GetOfflinePageFeatureMode(); |
| - return mode == FeatureMode::ENABLED_AS_BOOKMARKS || |
| - mode == FeatureMode::ENABLED_AS_SAVED_PAGES; |
| +bool IsOfflineBookmarksEnabled() { |
| + return base::FeatureList::IsEnabled(kOfflineBookmarksFeature); |
| } |
| bool IsOffliningRecentPagesEnabled() { |
| return base::FeatureList::IsEnabled(kOffliningRecentPagesFeature) && |
| - IsOfflinePagesEnabled(); |
| + IsOfflineBookmarksEnabled(); |
|
fgorski
2016/04/18 22:40:02
remove. the features should be independent.
jianli
2016/04/18 23:09:05
Done.
|
| } |
| bool IsOfflinePagesBackgroundLoadingEnabled() { |
| return base::FeatureList::IsEnabled(kOfflinePagesBackgroundLoadingFeature) |
| - && IsOfflinePagesEnabled(); |
| + && IsOfflineBookmarksEnabled(); |
|
fgorski
2016/04/18 22:40:02
ditto.
jianli
2016/04/18 23:09:05
Done.
|
| } |
| } // namespace offline_pages |