This source file includes following definitions.
- GetUserAgent
- GetDataResource
#include "content/test/test_content_client.h"
#include "base/base_paths.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/strings/string_piece.h"
namespace content {
TestContentClient::TestContentClient()
: data_pack_(ui::SCALE_FACTOR_100P) {
#if !defined(OS_IOS)
base::FilePath content_resources_pack_path;
#if defined(OS_ANDROID)
PathService::Get(base::DIR_ANDROID_APP_DATA, &content_resources_pack_path);
content_resources_pack_path = content_resources_pack_path.Append(
FILE_PATH_LITERAL("paks"));
#else
PathService::Get(base::DIR_MODULE, &content_resources_pack_path);
#endif
content_resources_pack_path = content_resources_pack_path.Append(
FILE_PATH_LITERAL("content_resources.pak"));
data_pack_.LoadFromPath(content_resources_pack_path);
#endif
}
TestContentClient::~TestContentClient() {
}
std::string TestContentClient::GetUserAgent() const {
return std::string("TestContentClient");
}
base::StringPiece TestContentClient::GetDataResource(
int resource_id,
ui::ScaleFactor scale_factor) const {
base::StringPiece resource;
data_pack_.GetStringPiece(resource_id, &resource);
return resource;
}
}