summaryrefslogtreecommitdiffstats
path: root/components/offline_pages
diff options
context:
space:
mode:
authordimich <dimich@chromium.org>2016-03-08 16:34:12 -0800
committerCommit bot <commit-bot@chromium.org>2016-03-09 00:35:35 +0000
commit1b3ad9bddb26f0dedbc7463397867d0a9981f85b (patch)
tree3eaf2c358e59e8fe97a1d54aba60725a3608b77f /components/offline_pages
parent1f9673dbd1b71cfa5a0dc5ab06509368153bcb20 (diff)
downloadchromium_src-1b3ad9bddb26f0dedbc7463397867d0a9981f85b.zip
chromium_src-1b3ad9bddb26f0dedbc7463397867d0a9981f85b.tar.gz
chromium_src-1b3ad9bddb26f0dedbc7463397867d0a9981f85b.tar.bz2
Add enable-offlining-recent-pages feature switch. The feature is not yet implemented. See launch bug below for description.
BUG=587599 Review URL: https://codereview.chromium.org/1750883002 Cr-Commit-Position: refs/heads/master@{#379997}
Diffstat (limited to 'components/offline_pages')
-rw-r--r--components/offline_pages/BUILD.gn1
-rw-r--r--components/offline_pages/offline_page_feature.cc14
-rw-r--r--components/offline_pages/offline_page_feature.h10
-rw-r--r--components/offline_pages/offline_page_model_unittest.cc20
4 files changed, 37 insertions, 8 deletions
diff --git a/components/offline_pages/BUILD.gn b/components/offline_pages/BUILD.gn
index cdbdb7b..1c2efd1 100644
--- a/components/offline_pages/BUILD.gn
+++ b/components/offline_pages/BUILD.gn
@@ -74,6 +74,7 @@ source_set("unit_tests") {
deps = [
":offline_pages",
+ ":switches",
":test_support",
"//base",
"//base/test:test_support",
diff --git a/components/offline_pages/offline_page_feature.cc b/components/offline_pages/offline_page_feature.cc
index ed390b8..ab00925 100644
--- a/components/offline_pages/offline_page_feature.cc
+++ b/components/offline_pages/offline_page_feature.cc
@@ -7,14 +7,13 @@
#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"
-#if defined(OS_ANDROID)
-
namespace offline_pages {
namespace {
@@ -26,6 +25,10 @@ const char kEnabledAsBookmarksGroupName[] = "EnabledAsBookmarks";
const char kEnabledAsSavedPagesGroupName[] = "EnabledAsSavedPages";
} // namespace
+const base::Feature kOffliningRecentPagesFeature {
+ "offline-recent-pages", 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.
@@ -75,6 +78,9 @@ bool IsOfflinePagesEnabled() {
mode == FeatureMode::ENABLED_AS_SAVED_PAGES;
}
-} // namespace offline_pages
+bool IsOffliningRecentPagesEnabled() {
+ return base::FeatureList::IsEnabled(kOffliningRecentPagesFeature) &&
+ IsOfflinePagesEnabled();
+}
-#endif
+} // namespace offline_pages
diff --git a/components/offline_pages/offline_page_feature.h b/components/offline_pages/offline_page_feature.h
index 600140f..1d01a2d 100644
--- a/components/offline_pages/offline_page_feature.h
+++ b/components/offline_pages/offline_page_feature.h
@@ -5,12 +5,13 @@
#ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_FEATURE_H_
#define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_FEATURE_H_
+#include "base/feature_list.h"
#include "build/build_config.h"
-#if defined(OS_ANDROID)
-
namespace offline_pages {
+extern const base::Feature kOffliningRecentPagesFeature;
+
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.components.offlinepages
enum class FeatureMode {
// Offline pages feature is disabled.
@@ -27,8 +28,9 @@ FeatureMode GetOfflinePageFeatureMode();
// Returns true if offline pages is enabled.
bool IsOfflinePagesEnabled();
-} // namespace offline_pages
+// Returns true if offlining of recent pages (aka 'Last N pages') is enabled.
+bool IsOffliningRecentPagesEnabled();
-#endif // defined(OS_ANDROID)
+} // namespace offline_pages
#endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_FEATURE_H_
diff --git a/components/offline_pages/offline_page_model_unittest.cc b/components/offline_pages/offline_page_model_unittest.cc
index aea301e..31b3723 100644
--- a/components/offline_pages/offline_page_model_unittest.cc
+++ b/components/offline_pages/offline_page_model_unittest.cc
@@ -9,6 +9,8 @@
#include <utility>
#include "base/bind.h"
+#include "base/command_line.h"
+#include "base/feature_list.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/run_loop.h"
@@ -25,7 +27,9 @@
#include "components/bookmarks/browser/bookmark_undo_delegate.h"
#include "components/bookmarks/browser/bookmark_undo_provider.h"
#include "components/bookmarks/test/test_bookmark_client.h"
+#include "components/offline_pages/offline_page_feature.h"
#include "components/offline_pages/offline_page_item.h"
+#include "components/offline_pages/offline_page_switches.h"
#include "components/offline_pages/offline_page_test_archiver.h"
#include "components/offline_pages/offline_page_test_store.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -989,4 +993,20 @@ TEST_F(OfflinePageModelTest, SaveRetrieveMultipleClientIds) {
EXPECT_TRUE(id_set.find(offline2) != id_set.end());
}
+TEST(CommandLineFlagsTest, OffliningRecentPages) {
+ // TODO(dimich): once offline pages are enabled by default, remove this.
+ base::CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kEnableOfflinePages);
+ // Disabled by default.
+ EXPECT_FALSE(offline_pages::IsOffliningRecentPagesEnabled());
+
+ // Check if feature is correctly enabled by command-line flag.
+ base::FeatureList::ClearInstanceForTesting();
+ scoped_ptr<base::FeatureList> feature_list(new base::FeatureList);
+ feature_list->InitializeFromCommandLine(
+ offline_pages::kOffliningRecentPagesFeature.name, "");
+ base::FeatureList::SetInstance(std::move(feature_list));
+ EXPECT_TRUE(offline_pages::IsOffliningRecentPagesEnabled());
+}
+
} // namespace offline_pages