Commit 317f71a5 authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

Remove GetDataResourceAsASCIIString and remained uses

This CL replaces all remained uses of GetDataResourceAsASCIIString
as well as the implementation of GetDataResourceAsASCIIString
in data_resource_helper.

Bug: 983396
Change-Id: Ic388ac0c72162ae6c081797d23245b5b1f3d41e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1746213
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686679}
parent 7cabf412
...@@ -427,19 +427,6 @@ const DataResource kDataResources[] = { ...@@ -427,19 +427,6 @@ const DataResource kDataResources[] = {
false}, false},
{"generatePasswordHover", IDR_PASSWORD_GENERATION_ICON_HOVER, {"generatePasswordHover", IDR_PASSWORD_GENERATION_ICON_HOVER,
ui::SCALE_FACTOR_100P, false}, ui::SCALE_FACTOR_100P, false},
// Not limited to Android since it's used for mobile layouts in inspector.
{"android.css", IDR_UASTYLE_THEME_CHROMIUM_ANDROID_CSS,
ui::SCALE_FACTOR_NONE, true},
// Not limited to Android since it's used for mobile layouts in inspector.
{"fullscreenAndroid.css", IDR_UASTYLE_FULLSCREEN_ANDROID_CSS,
ui::SCALE_FACTOR_NONE, true},
// Not limited to Linux since it's used for mobile layouts in inspector.
{"linux.css", IDR_UASTYLE_THEME_CHROMIUM_LINUX_CSS, ui::SCALE_FACTOR_NONE,
true},
#if defined(ENABLE_TOUCHLESS_UASTYLE_THEME)
{"touchless.css", IDR_UASTYLE_THEME_TOUCHLESS_CSS, ui::SCALE_FACTOR_NONE,
true},
#endif
{"DocumentXMLTreeViewer.css", IDR_DOCUMENTXMLTREEVIEWER_CSS, {"DocumentXMLTreeViewer.css", IDR_DOCUMENTXMLTREEVIEWER_CSS,
ui::SCALE_FACTOR_NONE, true}, ui::SCALE_FACTOR_NONE, true},
{"DocumentXMLTreeViewer.js", IDR_DOCUMENTXMLTREEVIEWER_JS, {"DocumentXMLTreeViewer.js", IDR_DOCUMENTXMLTREEVIEWER_JS,
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "third_party/blink/renderer/core/layout/layout_theme_linux.h" #include "third_party/blink/renderer/core/layout/layout_theme_linux.h"
#include "third_party/blink/public/resources/grit/blink_resources.h"
#include "third_party/blink/renderer/platform/data_resource_helper.h" #include "third_party/blink/renderer/platform/data_resource_helper.h"
namespace blink { namespace blink {
...@@ -19,7 +20,7 @@ LayoutTheme& LayoutTheme::NativeTheme() { ...@@ -19,7 +20,7 @@ LayoutTheme& LayoutTheme::NativeTheme() {
String LayoutThemeLinux::ExtraDefaultStyleSheet() { String LayoutThemeLinux::ExtraDefaultStyleSheet() {
return LayoutThemeDefault::ExtraDefaultStyleSheet() + return LayoutThemeDefault::ExtraDefaultStyleSheet() +
GetDataResourceAsASCIIString("linux.css"); UncompressResourceAsASCIIString(IDR_UASTYLE_THEME_CHROMIUM_LINUX_CSS);
} }
} // namespace blink } // namespace blink
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/web_theme_engine.h" #include "third_party/blink/public/platform/web_theme_engine.h"
#include "third_party/blink/public/resources/grit/blink_resources.h"
#include "third_party/blink/renderer/core/style/computed_style.h" #include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/platform/data_resource_helper.h" #include "third_party/blink/renderer/platform/data_resource_helper.h"
#include "third_party/blink/renderer/platform/web_test_support.h" #include "third_party/blink/renderer/platform/web_test_support.h"
...@@ -42,12 +43,13 @@ LayoutThemeMobile::~LayoutThemeMobile() = default; ...@@ -42,12 +43,13 @@ LayoutThemeMobile::~LayoutThemeMobile() = default;
String LayoutThemeMobile::ExtraDefaultStyleSheet() { String LayoutThemeMobile::ExtraDefaultStyleSheet() {
return LayoutThemeDefault::ExtraDefaultStyleSheet() + return LayoutThemeDefault::ExtraDefaultStyleSheet() +
GetDataResourceAsASCIIString("linux.css") + UncompressResourceAsASCIIString(IDR_UASTYLE_THEME_CHROMIUM_LINUX_CSS) +
GetDataResourceAsASCIIString("android.css"); UncompressResourceAsASCIIString(
IDR_UASTYLE_THEME_CHROMIUM_ANDROID_CSS);
} }
String LayoutThemeMobile::ExtraFullscreenStyleSheet() { String LayoutThemeMobile::ExtraFullscreenStyleSheet() {
return GetDataResourceAsASCIIString("fullscreenAndroid.css"); return UncompressResourceAsASCIIString(IDR_UASTYLE_FULLSCREEN_ANDROID_CSS);
} }
void LayoutThemeMobile::AdjustInnerSpinButtonStyle(ComputedStyle& style) const { void LayoutThemeMobile::AdjustInnerSpinButtonStyle(ComputedStyle& style) const {
......
...@@ -22,7 +22,7 @@ LayoutThemeTouchless::~LayoutThemeTouchless() {} ...@@ -22,7 +22,7 @@ LayoutThemeTouchless::~LayoutThemeTouchless() {}
String LayoutThemeTouchless::ExtraDefaultStyleSheet() { String LayoutThemeTouchless::ExtraDefaultStyleSheet() {
return LayoutThemeMobile::ExtraDefaultStyleSheet() + return LayoutThemeMobile::ExtraDefaultStyleSheet() +
GetDataResourceAsASCIIString("touchless.css"); UncompressResourceAsASCIIString(IDR_UASTYLE_THEME_TOUCHLESS_CSS);
} }
bool LayoutThemeTouchless::IsFocusRingOutset() const { bool LayoutThemeTouchless::IsFocusRingOutset() const {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "third_party/blink/renderer/core/xml/document_xml_tree_viewer.h" #include "third_party/blink/renderer/core/xml/document_xml_tree_viewer.h"
#include "third_party/blink/public/resources/grit/blink_resources.h"
#include "third_party/blink/renderer/bindings/core/v8/sanitize_script_errors.h" #include "third_party/blink/renderer/bindings/core/v8/sanitize_script_errors.h"
#include "third_party/blink/renderer/bindings/core/v8/script_controller.h" #include "third_party/blink/renderer/bindings/core/v8/script_controller.h"
#include "third_party/blink/renderer/bindings/core/v8/script_source_code.h" #include "third_party/blink/renderer/bindings/core/v8/script_source_code.h"
...@@ -18,8 +19,9 @@ namespace blink { ...@@ -18,8 +19,9 @@ namespace blink {
void TransformDocumentToXMLTreeView(Document& document) { void TransformDocumentToXMLTreeView(Document& document) {
String script_string = String script_string =
GetDataResourceAsASCIIString("DocumentXMLTreeViewer.js"); UncompressResourceAsASCIIString(IDR_DOCUMENTXMLTREEVIEWER_JS);
String css_string = GetDataResourceAsASCIIString("DocumentXMLTreeViewer.css"); String css_string =
UncompressResourceAsASCIIString(IDR_DOCUMENTXMLTREEVIEWER_CSS);
v8::HandleScope handle_scope(V8PerIsolateData::MainThreadIsolate()); v8::HandleScope handle_scope(V8PerIsolateData::MainThreadIsolate());
......
...@@ -4,30 +4,10 @@ ...@@ -4,30 +4,10 @@
#include "third_party/blink/renderer/platform/data_resource_helper.h" #include "third_party/blink/renderer/platform/data_resource_helper.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/web_data.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
namespace blink { namespace blink {
String GetDataResourceAsASCIIString(const char* resource) {
StringBuilder builder;
const WebData& resource_data = Platform::Current()->GetDataResource(resource);
builder.ReserveCapacity(resource_data.size());
resource_data.ForEachSegment([&builder](const char* segment,
size_t segment_size,
size_t segment_offset) {
builder.Append(segment, segment_size);
return true;
});
String data_string = builder.ToString();
DCHECK(!data_string.IsEmpty());
DCHECK(data_string.ContainsOnlyASCIIOrEmpty());
return data_string;
}
String UncompressResourceAsString(int resource_id) { String UncompressResourceAsString(int resource_id) {
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
std::string uncompressed = bundle.DecompressDataResourceScaled( std::string uncompressed = bundle.DecompressDataResourceScaled(
......
...@@ -13,10 +13,6 @@ namespace blink { ...@@ -13,10 +13,6 @@ namespace blink {
// Helper functions providing access to ui::ResourceBundle in Blink. // Helper functions providing access to ui::ResourceBundle in Blink.
// Returns the contents of a resource as a string specified by the
// resource name.
PLATFORM_EXPORT String GetDataResourceAsASCIIString(const char* resource);
// Uncompresses a gzipped resource and returns it as a string. The resource // Uncompresses a gzipped resource and returns it as a string. The resource
// is specified by the resource id from Grit. // is specified by the resource id from Grit.
PLATFORM_EXPORT String UncompressResourceAsString(int resource_id); PLATFORM_EXPORT String UncompressResourceAsString(int resource_id);
......
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