| 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/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "components/offline_pages/offline_page_switches.h" | 13 #include "components/offline_pages/offline_page_switches.h" |
| 14 #include "components/version_info/version_info.h" |
| 14 | 15 |
| 15 #if defined(OS_ANDROID) | 16 #if defined(OS_ANDROID) |
| 16 | 17 |
| 17 namespace offline_pages { | 18 namespace offline_pages { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 const char kOfflinePagesFieldTrialName[] = "OfflinePages"; | 21 const char kOfflinePagesFieldTrialName[] = "OfflinePages"; |
| 21 // The old experiment has only one mode to enable offline pages. | 22 // The old experiment has only one mode to enable offline pages. |
| 22 const char kEnabledGroupName[] = "Enabled"; | 23 const char kEnabledGroupName[] = "Enabled"; |
| 23 // The new experiment supports two modes for offline pages. | 24 // The new experiment supports two modes for offline pages. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 return FeatureMode::ENABLED_AS_SAVED_PAGES; | 56 return FeatureMode::ENABLED_AS_SAVED_PAGES; |
| 56 // The new experiment can control showing either bookmark or saved page. | 57 // The new experiment can control showing either bookmark or saved page. |
| 57 if (base::StartsWith(group_name, kEnabledAsBookmarksGroupName, | 58 if (base::StartsWith(group_name, kEnabledAsBookmarksGroupName, |
| 58 base::CompareCase::SENSITIVE)) { | 59 base::CompareCase::SENSITIVE)) { |
| 59 return FeatureMode::ENABLED_AS_BOOKMARKS; | 60 return FeatureMode::ENABLED_AS_BOOKMARKS; |
| 60 } | 61 } |
| 61 if (base::StartsWith(group_name, kEnabledAsSavedPagesGroupName, | 62 if (base::StartsWith(group_name, kEnabledAsSavedPagesGroupName, |
| 62 base::CompareCase::SENSITIVE)) { | 63 base::CompareCase::SENSITIVE)) { |
| 63 return FeatureMode::ENABLED_AS_SAVED_PAGES; | 64 return FeatureMode::ENABLED_AS_SAVED_PAGES; |
| 64 } | 65 } |
| 65 return FeatureMode::DISABLED; | 66 |
| 67 // Enabled by default on trunk. |
| 68 return version_info::IsOfficialBuild() ? FeatureMode::DISABLED |
| 69 : FeatureMode::ENABLED_AS_BOOKMARKS; |
| 66 } | 70 } |
| 67 | 71 |
| 68 bool IsOfflinePagesEnabled() { | 72 bool IsOfflinePagesEnabled() { |
| 69 FeatureMode mode = GetOfflinePageFeatureMode(); | 73 FeatureMode mode = GetOfflinePageFeatureMode(); |
| 70 return mode == FeatureMode::ENABLED_AS_BOOKMARKS || | 74 return mode == FeatureMode::ENABLED_AS_BOOKMARKS || |
| 71 mode == FeatureMode::ENABLED_AS_SAVED_PAGES; | 75 mode == FeatureMode::ENABLED_AS_SAVED_PAGES; |
| 72 } | 76 } |
| 73 | 77 |
| 74 } // namespace offline_pages | 78 } // namespace offline_pages |
| 75 | 79 |
| 76 #endif | 80 #endif |
| OLD | NEW |