OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/offline_pages/offline_page_feature.h" | 5 #include "components/offline_pages/offline_page_feature.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/feature_list.h" |
10 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
11 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
13 #include "components/offline_pages/offline_page_switches.h" | 14 #include "components/offline_pages/offline_page_switches.h" |
14 #include "components/version_info/version_info.h" | 15 #include "components/version_info/version_info.h" |
15 | 16 |
16 #if defined(OS_ANDROID) | |
17 | |
18 namespace offline_pages { | 17 namespace offline_pages { |
19 | 18 |
20 namespace { | 19 namespace { |
21 const char kOfflinePagesFieldTrialName[] = "OfflinePages"; | 20 const char kOfflinePagesFieldTrialName[] = "OfflinePages"; |
22 // The old experiment has only one mode to enable offline pages. | 21 // The old experiment has only one mode to enable offline pages. |
23 const char kEnabledGroupName[] = "Enabled"; | 22 const char kEnabledGroupName[] = "Enabled"; |
24 // The new experiment supports two modes for offline pages. | 23 // The new experiment supports two modes for offline pages. |
25 const char kEnabledAsBookmarksGroupName[] = "EnabledAsBookmarks"; | 24 const char kEnabledAsBookmarksGroupName[] = "EnabledAsBookmarks"; |
26 const char kEnabledAsSavedPagesGroupName[] = "EnabledAsSavedPages"; | 25 const char kEnabledAsSavedPagesGroupName[] = "EnabledAsSavedPages"; |
27 } // namespace | 26 } // namespace |
28 | 27 |
| 28 const base::Feature kOffliningRecentPagesFeature { |
| 29 "offline-recent-pages", base::FEATURE_DISABLED_BY_DEFAULT |
| 30 }; |
| 31 |
29 FeatureMode GetOfflinePageFeatureMode() { | 32 FeatureMode GetOfflinePageFeatureMode() { |
30 // Note: It's important to query the field trial state first, to ensure that | 33 // Note: It's important to query the field trial state first, to ensure that |
31 // UMA reports the correct group. | 34 // UMA reports the correct group. |
32 std::string group_name = | 35 std::string group_name = |
33 base::FieldTrialList::FindFullName(kOfflinePagesFieldTrialName); | 36 base::FieldTrialList::FindFullName(kOfflinePagesFieldTrialName); |
34 | 37 |
35 // The old experiment 'Enabled' defaults to showing saved page. | 38 // The old experiment 'Enabled' defaults to showing saved page. |
36 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 39 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
37 switches::kEnableOfflinePages)) { | 40 switches::kEnableOfflinePages)) { |
38 return FeatureMode::ENABLED_AS_SAVED_PAGES; | 41 return FeatureMode::ENABLED_AS_SAVED_PAGES; |
(...skipping 29 matching lines...) Expand all Loading... |
68 return version_info::IsOfficialBuild() ? FeatureMode::DISABLED | 71 return version_info::IsOfficialBuild() ? FeatureMode::DISABLED |
69 : FeatureMode::ENABLED_AS_BOOKMARKS; | 72 : FeatureMode::ENABLED_AS_BOOKMARKS; |
70 } | 73 } |
71 | 74 |
72 bool IsOfflinePagesEnabled() { | 75 bool IsOfflinePagesEnabled() { |
73 FeatureMode mode = GetOfflinePageFeatureMode(); | 76 FeatureMode mode = GetOfflinePageFeatureMode(); |
74 return mode == FeatureMode::ENABLED_AS_BOOKMARKS || | 77 return mode == FeatureMode::ENABLED_AS_BOOKMARKS || |
75 mode == FeatureMode::ENABLED_AS_SAVED_PAGES; | 78 mode == FeatureMode::ENABLED_AS_SAVED_PAGES; |
76 } | 79 } |
77 | 80 |
| 81 bool IsOffliningRecentPagesEnabled() { |
| 82 return base::FeatureList::IsEnabled(kOffliningRecentPagesFeature) && |
| 83 IsOfflinePagesEnabled(); |
| 84 } |
| 85 |
78 } // namespace offline_pages | 86 } // namespace offline_pages |
79 | |
80 #endif | |
OLD | NEW |