Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: webkit/support/platform_support_linux.cc

Issue 8602002: Move some webkit_glue embedder functions into WebKitPlatformSupport virtual methods (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: copyright year Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/support/platform_support_android.cc ('k') | webkit/support/platform_support_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "webkit/support/platform_support.h" 5 #include "webkit/support/platform_support.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.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/string16.h" 11 #include "base/string16.h"
12 #include "base/string_piece.h" 12 #include "base/string_piece.h"
13 #include "grit/webkit_resources.h" 13 #include "grit/webkit_resources.h"
14 #include "ui/base/resource/resource_bundle.h" 14 #include "ui/base/resource/resource_bundle.h"
15 #include "webkit/support/test_webkit_platform_support.h"
15 16
16 namespace webkit_support { 17 namespace webkit_support {
17 18
18 // TODO(tkent): Implement some of the followings for platform-dependent tasks 19 // TODO(tkent): Implement some of the followings for platform-dependent tasks
19 // such as loading resource. 20 // such as loading resource.
20 21
21 void BeforeInitialize(bool unit_test_mode) { 22 void BeforeInitialize(bool unit_test_mode) {
22 } 23 }
23 24
24 void AfterInitialize(bool unit_test_mode) { 25 void AfterInitialize(bool unit_test_mode) {
25 if (unit_test_mode) 26 if (unit_test_mode)
26 return; // We don't have a resource pack when running the unit-tests. 27 return; // We don't have a resource pack when running the unit-tests.
27 28
28 FilePath data_path; 29 FilePath data_path;
29 PathService::Get(base::DIR_EXE, &data_path); 30 PathService::Get(base::DIR_EXE, &data_path);
30 data_path = data_path.Append("DumpRenderTree.pak"); 31 data_path = data_path.Append("DumpRenderTree.pak");
31 ResourceBundle::InitSharedInstanceForTest(data_path); 32 ResourceBundle::InitSharedInstanceForTest(data_path);
32 } 33 }
33 34
34 void BeforeShutdown() { 35 void BeforeShutdown() {
35 ResourceBundle::CleanupSharedInstance(); 36 ResourceBundle::CleanupSharedInstance();
36 } 37 }
37 38
38 void AfterShutdown() { 39 void AfterShutdown() {
39 } 40 }
40 41
41 } // namespace webkit_support 42 } // namespace webkit_support
42 43
43 namespace webkit_glue { 44 string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) {
44
45 string16 GetLocalizedString(int message_id) {
46 return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); 45 return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id);
47 } 46 }
48 47
49 base::StringPiece GetDataResource(int resource_id) { 48 base::StringPiece TestWebKitPlatformSupport::GetDataResource(int resource_id) {
50 FilePath resources_path; 49 FilePath resources_path;
51 PathService::Get(base::DIR_EXE, &resources_path); 50 PathService::Get(base::DIR_EXE, &resources_path);
52 resources_path = resources_path.Append("DumpRenderTree_resources"); 51 resources_path = resources_path.Append("DumpRenderTree_resources");
53 switch (resource_id) { 52 switch (resource_id) {
54 case IDR_BROKENIMAGE: { 53 case IDR_BROKENIMAGE: {
55 CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ()); 54 CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ());
56 if (broken_image_data.empty()) { 55 if (broken_image_data.empty()) {
57 FilePath path = resources_path.Append("missingImage.gif"); 56 FilePath path = resources_path.Append("missingImage.gif");
58 bool success = file_util::ReadFileToString(path, &broken_image_data); 57 bool success = file_util::ReadFileToString(path, &broken_image_data);
59 if (!success) 58 if (!success)
60 LOG(FATAL) << "Failed reading: " << path.value(); 59 LOG(FATAL) << "Failed reading: " << path.value();
61 } 60 }
62 return broken_image_data; 61 return broken_image_data;
63 } 62 }
64 case IDR_TEXTAREA_RESIZER: { 63 case IDR_TEXTAREA_RESIZER: {
65 CR_DEFINE_STATIC_LOCAL(std::string, resize_corner_data, ()); 64 CR_DEFINE_STATIC_LOCAL(std::string, resize_corner_data, ());
66 if (resize_corner_data.empty()) { 65 if (resize_corner_data.empty()) {
67 FilePath path = resources_path.Append("textAreaResizeCorner.png"); 66 FilePath path = resources_path.Append("textAreaResizeCorner.png");
68 bool success = file_util::ReadFileToString(path, &resize_corner_data); 67 bool success = file_util::ReadFileToString(path, &resize_corner_data);
69 if (!success) 68 if (!success)
70 LOG(FATAL) << "Failed reading: " << path.value(); 69 LOG(FATAL) << "Failed reading: " << path.value();
71 } 70 }
72 return resize_corner_data; 71 return resize_corner_data;
73 } 72 }
74 } 73 }
75 74
76 return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); 75 return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id);
77 } 76 }
78
79 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/support/platform_support_android.cc ('k') | webkit/support/platform_support_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698