forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Offline Pages] PF: Checks Chrome settings for prefetching being enabled
Adds a new PrefetchConfiguration component to PrefethService that serves as an interface to the embedder to obtain user settings information. Initially it allows determining if the prefetching of offline pages should be enabled based on current user settings. Bug: 701939 Change-Id: Ia33e1264c11acce2a09cd8585f5b484c6a750182 Reviewed-on: https://chromium-review.googlesource.com/618447 Commit-Queue: Justin DeWitt <dewittj@chromium.org> Reviewed-by: Justin DeWitt <dewittj@chromium.org> Reviewed-by: Dmitry Titov <dimich@chromium.org> Cr-Commit-Position: refs/heads/master@{#495574}
- Loading branch information
Showing
14 changed files
with
194 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
chrome/browser/offline_pages/prefetch/prefetch_configuration_impl.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2017 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 "chrome/browser/offline_pages/prefetch/prefetch_configuration_impl.h" | ||
|
||
#include "chrome/browser/net/prediction_options.h" | ||
#include "chrome/common/pref_names.h" | ||
#include "components/prefs/pref_service.h" | ||
|
||
namespace offline_pages { | ||
|
||
PrefetchConfigurationImpl::PrefetchConfigurationImpl(PrefService* pref_service) | ||
: pref_service_(pref_service) {} | ||
|
||
PrefetchConfigurationImpl::~PrefetchConfigurationImpl() = default; | ||
|
||
bool PrefetchConfigurationImpl::IsPrefetchingEnabledBySettings() { | ||
return pref_service_->GetInteger(prefs::kNetworkPredictionOptions) != | ||
chrome_browser_net::NETWORK_PREDICTION_NEVER; | ||
} | ||
|
||
} // namespace offline_pages |
32 changes: 32 additions & 0 deletions
32
chrome/browser/offline_pages/prefetch/prefetch_configuration_impl.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2017 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 CHROME_BROWSER_OFFLINE_PAGES_PREFETCH_PREFETCH_CONFIGURATION_IMPL_H_ | ||
#define CHROME_BROWSER_OFFLINE_PAGES_PREFETCH_PREFETCH_CONFIGURATION_IMPL_H_ | ||
|
||
#include "base/macros.h" | ||
#include "components/offline_pages/core/prefetch/prefetch_configuration.h" | ||
|
||
class PrefService; | ||
|
||
namespace offline_pages { | ||
|
||
// Implementation of PrefetchConfiguration that queries Chrome preferences. | ||
class PrefetchConfigurationImpl : public PrefetchConfiguration { | ||
public: | ||
explicit PrefetchConfigurationImpl(PrefService* pref_service); | ||
~PrefetchConfigurationImpl() override; | ||
|
||
// PrefetchConfiguration implementation. | ||
bool IsPrefetchingEnabledBySettings() override; | ||
|
||
private: | ||
PrefService* pref_service_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(PrefetchConfigurationImpl); | ||
}; | ||
|
||
} // namespace offline_pages | ||
|
||
#endif // CHROME_BROWSER_OFFLINE_PAGES_PREFETCH_PREFETCH_CONFIGURATION_IMPL_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
components/offline_pages/core/prefetch/prefetch_configuration.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2017 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/core/prefetch/prefetch_configuration.h" | ||
|
||
#include "components/offline_pages/core/offline_page_feature.h" | ||
|
||
namespace offline_pages { | ||
|
||
bool PrefetchConfiguration::IsPrefetchingEnabled() { | ||
return IsPrefetchingOfflinePagesEnabled() && IsPrefetchingEnabledBySettings(); | ||
} | ||
|
||
} // namespace offline_pages |
29 changes: 29 additions & 0 deletions
29
components/offline_pages/core/prefetch/prefetch_configuration.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2017 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_CORE_PREFETCH_PREFETCH_CONFIGURATION_H_ | ||
#define COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_CONFIGURATION_H_ | ||
|
||
namespace offline_pages { | ||
|
||
// Class that interfaces with configuration systems to provide prefetching | ||
// specific configuration information. | ||
class PrefetchConfiguration { | ||
public: | ||
virtual ~PrefetchConfiguration() = default; | ||
|
||
// Returns true if all needed flags and settings allows the prefetching of | ||
// offline pages to run. Note that this result can change in the course of the | ||
// application lifetime. Should not be overridden by subclasses. | ||
bool IsPrefetchingEnabled(); | ||
|
||
protected: | ||
// Returns true if user settings allow the prefetching of offline pages to | ||
// run. Should not be called by users of this class. | ||
virtual bool IsPrefetchingEnabledBySettings() = 0; | ||
}; | ||
|
||
} // namespace offline_pages | ||
|
||
#endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_CONFIGURATION_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.