Commit 9f6510f2 authored by Jian Li's avatar Jian Li Committed by Commit Bot

Add the method to check if offline archive is in internal dir

Bug: 758690
Change-Id: I8bb4283fc40a87fa7a87df2c7e513e2e16903290
Reviewed-on: https://chromium-review.googlesource.com/828049Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Commit-Queue: Jian Li <jianli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524232}
parent 0959654c
......@@ -264,6 +264,16 @@ const base::FilePath& OfflinePageModelTaskified::GetArchiveDirectory(
return archive_manager_->GetPersistentArchivesDir();
}
bool OfflinePageModelTaskified::IsArchiveInInternalDir(
const base::FilePath& file_path) const {
DCHECK(!file_path.empty());
// TODO(jianli): Update this once persistent archives are moved into the
// public directory.
return archive_manager_->GetTemporaryArchivesDir().IsParent(file_path) ||
archive_manager_->GetPersistentArchivesDir().IsParent(file_path);
}
ClientPolicyController* OfflinePageModelTaskified::GetPolicyController() {
return policy_controller_.get();
}
......
......@@ -107,6 +107,7 @@ class OfflinePageModelTaskified : public OfflinePageModel,
const base::FilePath& GetArchiveDirectory(
const std::string& name_space) const override;
bool IsArchiveInInternalDir(const base::FilePath& file_path) const override;
ClientPolicyController* GetPolicyController() override;
......
......@@ -201,6 +201,10 @@ class OfflinePageModel : public base::SupportsUserData {
virtual const base::FilePath& GetArchiveDirectory(
const std::string& name_space) const = 0;
// Returns whether given archive file is in the internal directory.
virtual bool IsArchiveInInternalDir(
const base::FilePath& file_path) const = 0;
// Returns the logger. Ownership is retained by the model.
virtual OfflineEventLogger* GetLogger() = 0;
};
......
......@@ -685,6 +685,16 @@ const base::FilePath& OfflinePageModelImpl::GetArchiveDirectory(
return archive_manager_->GetPersistentArchivesDir();
}
bool OfflinePageModelImpl::IsArchiveInInternalDir(
const base::FilePath& file_path) const {
DCHECK(!file_path.empty());
// TODO(jianli): Update this once persisten archives are moved into the public
// directory.
return archive_manager_->GetTemporaryArchivesDir().IsParent(file_path) ||
archive_manager_->GetPersistentArchivesDir().IsParent(file_path);
}
void OfflinePageModelImpl::CheckMetadataConsistency() {
DCHECK(is_loaded_);
......
......@@ -106,6 +106,7 @@ class OfflinePageModelImpl : public OfflinePageModel, public KeyedService {
const MultipleOfflinePageItemCallback& callback) override;
const base::FilePath& GetArchiveDirectory(
const std::string& name_space) const override;
bool IsArchiveInInternalDir(const base::FilePath& file_path) const override;
ClientPolicyController* GetPolicyController() override;
......
......@@ -59,6 +59,10 @@ const base::FilePath& StubOfflinePageModel::GetArchiveDirectory(
const std::string& name_space) const {
return archive_directory_;
}
bool StubOfflinePageModel::IsArchiveInInternalDir(
const base::FilePath& file_path) const {
return archive_directory_.IsParent(file_path);
}
ClientPolicyController* StubOfflinePageModel::GetPolicyController() {
return &policy_controller_;
......
......@@ -63,6 +63,7 @@ class StubOfflinePageModel : public OfflinePageModelImpl {
const MultipleOfflinePageItemCallback& callback) override;
const base::FilePath& GetArchiveDirectory(
const std::string& name_space) const override;
bool IsArchiveInInternalDir(const base::FilePath& file_path) const override;
ClientPolicyController* GetPolicyController() override;
OfflineEventLogger* GetLogger() override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment