blob: bf0b6058bed7d10713ca3ab126900210620bf63c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// Copyright (c) 2012 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 "webkit/support/platform_support.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/strings/string16.h"
#include "base/strings/string_piece.h"
#include "grit/webkit_resources.h"
#include "ui/base/resource/resource_bundle.h"
#include "webkit/support/test_webkit_platform_support.h"
namespace webkit_support {
// TODO(tkent): Implement some of the followings for platform-dependent tasks
// such as loading resource.
void BeforeInitialize() {
}
void AfterInitialize() {
base::FilePath data_path;
PathService::Get(base::DIR_EXE, &data_path);
data_path = data_path.Append("DumpRenderTree.pak");
ResourceBundle::InitSharedInstanceWithPakPath(data_path);
}
void BeforeShutdown() {
ResourceBundle::CleanupSharedInstance();
}
void AfterShutdown() {
}
} // namespace webkit_support
base::string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) {
return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id);
}
base::StringPiece TestWebKitPlatformSupport::GetDataResource(
int resource_id,
ui::ScaleFactor scale_factor) {
base::FilePath resources_path;
PathService::Get(base::DIR_EXE, &resources_path);
resources_path = resources_path.Append("DumpRenderTree_resources");
switch (resource_id) {
case IDR_BROKENIMAGE: {
CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ());
if (broken_image_data.empty()) {
base::FilePath path = resources_path.Append("missingImage.gif");
bool success = file_util::ReadFileToString(path, &broken_image_data);
if (!success)
LOG(FATAL) << "Failed reading: " << path.value();
}
return broken_image_data;
}
case IDR_TEXTAREA_RESIZER: {
CR_DEFINE_STATIC_LOCAL(std::string, resize_corner_data, ());
if (resize_corner_data.empty()) {
base::FilePath path = resources_path.Append("textAreaResizeCorner.png");
bool success = file_util::ReadFileToString(path, &resize_corner_data);
if (!success)
LOG(FATAL) << "Failed reading: " << path.value();
}
return resize_corner_data;
}
}
return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
resource_id, scale_factor);
}
|