| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/test/test_content_client.h" | 5 #include "content/test/test_content_client.h" |
| 6 | 6 |
| 7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
| 12 #include "ui/base/ui_base_paths.h" | |
| 13 | 12 |
| 14 namespace content { | 13 namespace content { |
| 15 | 14 |
| 16 TestContentClient::TestContentClient() | 15 TestContentClient::TestContentClient() |
| 17 : data_pack_(ui::SCALE_FACTOR_100P) { | 16 : data_pack_(ui::SCALE_FACTOR_100P) { |
| 18 // content_shell.pak is not built on iOS as it is not required. | 17 // content_shell.pak is not built on iOS as it is not required. |
| 19 #if !defined(OS_IOS) | 18 #if !defined(OS_IOS) |
| 20 base::FilePath content_shell_pack_path; | 19 base::FilePath content_shell_pack_path; |
| 21 #if defined(OS_ANDROID) | 20 #if defined(OS_ANDROID) |
| 22 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &content_shell_pack_path); | 21 // on Android all pak files are inside the paks folder. |
| 22 PathService::Get(base::DIR_ANDROID_APP_DATA, &content_shell_pack_path); |
| 23 content_shell_pack_path = content_shell_pack_path.Append( |
| 24 FILE_PATH_LITERAL("paks")); |
| 23 #else | 25 #else |
| 24 PathService::Get(base::DIR_MODULE, &content_shell_pack_path); | 26 PathService::Get(base::DIR_MODULE, &content_shell_pack_path); |
| 25 #endif | 27 #endif |
| 26 content_shell_pack_path = content_shell_pack_path.Append( | 28 content_shell_pack_path = content_shell_pack_path.Append( |
| 27 FILE_PATH_LITERAL("content_shell.pak")); | 29 FILE_PATH_LITERAL("content_shell.pak")); |
| 28 data_pack_.LoadFromPath(content_shell_pack_path); | 30 data_pack_.LoadFromPath(content_shell_pack_path); |
| 29 #endif | 31 #endif |
| 30 } | 32 } |
| 31 | 33 |
| 32 TestContentClient::~TestContentClient() { | 34 TestContentClient::~TestContentClient() { |
| 33 } | 35 } |
| 34 | 36 |
| 35 std::string TestContentClient::GetUserAgent() const { | 37 std::string TestContentClient::GetUserAgent() const { |
| 36 return std::string("TestContentClient"); | 38 return std::string("TestContentClient"); |
| 37 } | 39 } |
| 38 | 40 |
| 39 base::StringPiece TestContentClient::GetDataResource( | 41 base::StringPiece TestContentClient::GetDataResource( |
| 40 int resource_id, | 42 int resource_id, |
| 41 ui::ScaleFactor scale_factor) const { | 43 ui::ScaleFactor scale_factor) const { |
| 42 base::StringPiece resource; | 44 base::StringPiece resource; |
| 43 data_pack_.GetStringPiece(resource_id, &resource); | 45 data_pack_.GetStringPiece(resource_id, &resource); |
| 44 return resource; | 46 return resource; |
| 45 } | 47 } |
| 46 | 48 |
| 47 } // namespace content | 49 } // namespace content |
| OLD | NEW |