diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 0a72b5b1847a9..eda434fcb9abf 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -15870,6 +15870,15 @@ After you create a new supervised user, you can manage their settings at any tim </message> </if> + <if expr="is_android"> + <message name="IDS_FLAGS_OFFLINE_PAGES_NAME" desc="Name for the flag to enable offline pages."> + Enable offline pages + </message> + <message name="IDS_FLAGS_OFFLINE_PAGES_DESCRIPTION" desc="Description for the flag to enable offline pages."> + Enable storing pages locally for offline use. Requires Enhanced Bookmarks to be enabled. + </message> + </if> + </messages> </release> </grit> diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index 4d9071fe52320..253026a71f4bf 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS @@ -57,6 +57,7 @@ include_rules = [ "+components/navigation_metrics", "+components/network_hints", "+components/network_time", + "+components/offline_pages", "+components/omnibox/browser", "+components/os_crypt", "+components/password_manager", diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 5bc0eddf6e40e..967ab839b4d5c 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -31,6 +31,7 @@ #include "components/enhanced_bookmarks/enhanced_bookmark_switches.h" #include "components/metrics/metrics_hashes.h" #include "components/nacl/common/nacl_switches.h" +#include "components/offline_pages/offline_page_switches.h" #include "components/omnibox/browser/omnibox_switches.h" #include "components/plugins/common/plugins_switches.h" #include "components/proximity_auth/switches.h" @@ -2099,6 +2100,14 @@ const Experiment kExperiments[] = { kOsAndroid, MULTI_VALUE_TYPE(kProgressBarAnimationChoices)}, #endif // defined(OS_ANDROID) +#if defined(OS_ANDROID) + {"offline-pages", + IDS_FLAGS_OFFLINE_PAGES_NAME, + IDS_FLAGS_OFFLINE_PAGES_DESCRIPTION, + kOsAndroid, + ENABLE_DISABLE_VALUE_TYPE(switches::kEnableOfflinePages, + switches::kDisableOfflinePages)}, +#endif // defined(OS_ANDROID) // NOTE: Adding new command-line switches requires adding corresponding // entries to enum "LoginCustomFlags" in histograms.xml. See note in diff --git a/components/offline_pages.gypi b/components/offline_pages.gypi index 09776420ecb70..322f676b0d882 100644 --- a/components/offline_pages.gypi +++ b/components/offline_pages.gypi @@ -32,6 +32,8 @@ 'offline_pages/offline_page_metadata_store.h', 'offline_pages/offline_page_metadata_store_impl.cc', 'offline_pages/offline_page_metadata_store_impl.h', + 'offline_pages/offline_page_switches.cc', + 'offline_pages/offline_page_switches.h', ], }, { diff --git a/components/offline_pages/BUILD.gn b/components/offline_pages/BUILD.gn index 6568141a055ee..bd0131555984c 100644 --- a/components/offline_pages/BUILD.gn +++ b/components/offline_pages/BUILD.gn @@ -20,6 +20,8 @@ static_library("offline_pages") { "offline_page_metadata_store_impl.h", "offline_page_model.cc", "offline_page_model.h", + "offline_page_switches.cc", + "offline_page_switches.h", ] deps = [ diff --git a/components/offline_pages/offline_page_feature.cc b/components/offline_pages/offline_page_feature.cc index 2d63da71eee2b..8d51f52756413 100644 --- a/components/offline_pages/offline_page_feature.cc +++ b/components/offline_pages/offline_page_feature.cc @@ -6,7 +6,9 @@ #include <string> +#include "base/command_line.h" #include "base/metrics/field_trial.h" +#include "components/offline_pages/offline_page_switches.h" #if defined(OS_ANDROID) @@ -18,6 +20,15 @@ const char kOfflinePagesFieldTrialEnabledGroupName[] = "Enabled"; } // namespace bool IsOfflinePagesEnabled() { + if (base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableOfflinePages)) { + return true; + } + if (base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableOfflinePages)) { + return false; + } + std::string group_name = base::FieldTrialList::FindFullName(kOfflinePagesFieldTrialName); return group_name == kOfflinePagesFieldTrialEnabledGroupName; diff --git a/components/offline_pages/offline_page_switches.cc b/components/offline_pages/offline_page_switches.cc new file mode 100644 index 0000000000000..2a24c35c0c6cb --- /dev/null +++ b/components/offline_pages/offline_page_switches.cc @@ -0,0 +1,15 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/offline_pages/offline_page_switches.h" + +namespace switches { + +// Enable Offline Pages. +const char kEnableOfflinePages[] = "enable-offline-pages"; + +// Disable Offline Pages. +const char kDisableOfflinePages[] = "disable-offline-pages"; + +} // namespace switches diff --git a/components/offline_pages/offline_page_switches.h b/components/offline_pages/offline_page_switches.h new file mode 100644 index 0000000000000..4df0618ff0058 --- /dev/null +++ b/components/offline_pages/offline_page_switches.h @@ -0,0 +1,15 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGES_SWITCHES_H_ +#define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGES_SWITCHES_H_ + +namespace switches { + +extern const char kEnableOfflinePages[]; +extern const char kDisableOfflinePages[]; + +} // namespace switches + +#endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGES_SWITCHES_H_ diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 34c8e93fb69aa..8927575f23a27 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -61459,6 +61459,7 @@ To add a new entry, add it with any value and run test to compute valid value. <int value="-1930720286" label="nacl-debug-mask"/> <int value="-1928198763" label="enable-async-dns"/> <int value="-1925117279" label="disable-quic-https"/> + <int value="-1915854488" label="enable-offline-pages"/> <int value="-1911153473" label="enable-easy-signin"/> <int value="-1888273969" label="tab-capture-upscale-quality"/> <int value="-1887053262" @@ -61763,6 +61764,7 @@ To add a new entry, add it with any value and run test to compute valid value. <int value="880510010" label="enable-permissions-bubbles"/> <int value="884106779" label="supervised-user-safesites"/> <int value="887011602" label="enable-spelling-auto-correct"/> + <int value="903267263" label="disable-offline-pages"/> <int value="909439558" label="disable-device-discovery"/> <int value="916316159" label="disable-new-app-list-mixer"/> <int value="929462705" label="disable-link-disambiguation-popup"/>