summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-04 16:15:17 +0000
committerxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-04 16:15:17 +0000
commit8009f23dff4aeea8b2a1b32481ffbfbb334760c5 (patch)
treec6042d4cb63f05bfd29005f97ca592a0ed44c559
parent81bb1092f354f3cb3c597ab3c9ed568905078e49 (diff)
downloadchromium_src-8009f23dff4aeea8b2a1b32481ffbfbb334760c5.zip
chromium_src-8009f23dff4aeea8b2a1b32481ffbfbb334760c5.tar.gz
chromium_src-8009f23dff4aeea8b2a1b32481ffbfbb334760c5.tar.bz2
Use ResourceBundle for NativeThemeLinux/Chromeos resource images.
- Clean up gfx NativeThemeLinux/Chromeos code to use ResourceBundle. This should also fix valgrind failures in issue 77712 and 77721. - Remove no longer needed gfx_module and gfx_resource_provider files. - Update linux/chromeos test_shell and DumpRenderTree to use ResourceBundle as well. BUG=77712,77721 TEST=Build should pass and valgrind failure in issue 77712 and 77721 should be gone. Review URL: http://codereview.chromium.org/6773021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80319 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_main.cc3
-rw-r--r--chrome/chrome_common.gypi2
-rw-r--r--chrome/common/gfx_resource_provider.cc16
-rw-r--r--chrome/common/gfx_resource_provider.h20
-rw-r--r--chrome/renderer/renderer_main.cc3
-rw-r--r--chrome/test/render_view_test.cc5
-rw-r--r--tools/valgrind/memcheck/suppressions.txt28
-rw-r--r--ui/base/resource/resource_bundle.cc8
-rw-r--r--ui/base/resource/resource_bundle.h6
-rw-r--r--ui/base/resource/resource_bundle_posix.cc8
-rw-r--r--ui/base/resource/resource_bundle_win.cc5
-rw-r--r--ui/gfx/gfx_module.cc56
-rw-r--r--ui/gfx/gfx_module.h41
-rw-r--r--ui/gfx/native_theme_chromeos.cc20
-rw-r--r--ui/gfx/native_theme_linux.cc35
-rw-r--r--ui/ui_gfx.gypi2
-rw-r--r--webkit/support/platform_support_gtk.cc40
-rw-r--r--webkit/tools/test_shell/test_shell_gtk.cc27
-rw-r--r--webkit/tools/test_shell/test_shell_main.cc2
19 files changed, 70 insertions, 257 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 0e60c55..737f01b 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -79,7 +79,6 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/env_vars.h"
-#include "chrome/common/gfx_resource_provider.h"
#include "chrome/common/json_pref_store.h"
#include "chrome/common/jstemplate_builder.h"
#include "chrome/common/logging_chrome.h"
@@ -114,7 +113,6 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/system_monitor/system_monitor.h"
-#include "ui/gfx/gfx_module.h"
#if defined(USE_LINUX_BREAKPAD)
#include "base/linux_util.h"
@@ -1588,7 +1586,6 @@ int BrowserMain(const MainFunctionParams& parameters) {
// Configure modules that need access to resources.
net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider);
- gfx::GfxModule::SetResourceProvider(chrome::GfxResourceProvider);
// Register our global network handler for chrome:// and
// chrome-extension:// URLs.
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 16f3ecf..284f82c 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -47,8 +47,6 @@
'common/content_settings_helper.h',
'common/content_settings_types.h',
'common/devtools_messages.h',
- 'common/gfx_resource_provider.cc',
- 'common/gfx_resource_provider.h',
'common/guid.cc',
'common/guid.h',
'common/guid_posix.cc',
diff --git a/chrome/common/gfx_resource_provider.cc b/chrome/common/gfx_resource_provider.cc
deleted file mode 100644
index 8cee034..0000000
--- a/chrome/common/gfx_resource_provider.cc
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (c) 2011 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 "chrome/common/gfx_resource_provider.h"
-
-#include "base/string_piece.h"
-#include "ui/base/resource/resource_bundle.h"
-
-namespace chrome {
-
-base::StringPiece GfxResourceProvider(int key) {
- return ResourceBundle::GetSharedInstance().GetRawDataResource(key);
-}
-
-} // namespace chrome
diff --git a/chrome/common/gfx_resource_provider.h b/chrome/common/gfx_resource_provider.h
deleted file mode 100644
index 41b67b8..0000000
--- a/chrome/common/gfx_resource_provider.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) 2011 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.
-
-#ifndef CHROME_COMMON_GFX_RESOURCE_PROVIDER_H_
-#define CHROME_COMMON_GFX_RESOURCE_PROVIDER_H_
-#pragma once
-
-namespace base {
-class StringPiece;
-}
-
-namespace chrome {
-
-// This is called indirectly by the gfx theme code to access resources.
-base::StringPiece GfxResourceProvider(int key);
-
-} // namespace chrome
-
-#endif // CHROME_COMMON_GFX_RESOURCE_PROVIDER_H_
diff --git a/chrome/renderer/renderer_main.cc b/chrome/renderer/renderer_main.cc
index 385da63..cd3bb5d 100644
--- a/chrome/renderer/renderer_main.cc
+++ b/chrome/renderer/renderer_main.cc
@@ -24,7 +24,6 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_counters.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/gfx_resource_provider.h"
#include "chrome/common/logging_chrome.h"
#include "chrome/common/net/net_resource_provider.h"
#include "chrome/common/pepper_plugin_registry.h"
@@ -37,7 +36,6 @@
#include "net/base/net_module.h"
#include "ui/base/system_monitor/system_monitor.h"
#include "ui/base/ui_base_switches.h"
-#include "ui/gfx/gfx_module.h"
#if defined(OS_MACOSX)
#include "base/eintr_wrapper.h"
@@ -249,7 +247,6 @@ int RendererMain(const MainFunctionParams& parameters) {
// Configure modules that need access to resources.
net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider);
- gfx::GfxModule::SetResourceProvider(chrome::GfxResourceProvider);
// This function allows pausing execution using the --renderer-startup-dialog
// flag allowing us to attach a debugger.
diff --git a/chrome/test/render_view_test.cc b/chrome/test/render_view_test.cc
index 27b2ef2..8c3854b 100644
--- a/chrome/test/render_view_test.cc
+++ b/chrome/test/render_view_test.cc
@@ -6,7 +6,6 @@
#include "chrome/browser/extensions/extension_function_dispatcher.h"
#include "chrome/common/extensions/extension.h"
-#include "chrome/common/gfx_resource_provider.h"
#include "chrome/common/print_messages.h"
#include "chrome/common/render_messages.h"
#include "chrome/renderer/autofill/password_autofill_manager.h"
@@ -28,7 +27,6 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
-#include "ui/gfx/gfx_module.h"
#include "webkit/glue/webkit_glue.h"
#if defined(OS_LINUX)
@@ -96,9 +94,6 @@ void RenderViewTest::LoadHTML(const char* html) {
}
void RenderViewTest::SetUp() {
- // Configure modules that need access to resources.
- gfx::GfxModule::SetResourceProvider(chrome::GfxResourceProvider);
-
content::GetContentClient()->set_renderer(&chrome_content_renderer_client_);
extension_dispatcher_ = new ExtensionDispatcher();
sandbox_init_wrapper_.reset(new SandboxInitWrapper());
diff --git a/tools/valgrind/memcheck/suppressions.txt b/tools/valgrind/memcheck/suppressions.txt
index b6a119a..004ba0f 100644
--- a/tools/valgrind/memcheck/suppressions.txt
+++ b/tools/valgrind/memcheck/suppressions.txt
@@ -4138,34 +4138,6 @@
fun:gtk_file_chooser_dialog_constructor
}
{
- bug_77712
- Memcheck:Leak
- fun:_Znw*
- fun:_ZN3gfx9GfxModule14GetBitmapNamedEi
- fun:_ZN3gfx16NativeThemeLinux*Paint*EPN4skia14PlatformCanvasENS0_5StateERKNS_4RectERKNS0_17ButtonExtraParamsE
- fun:_ZN3gfx16NativeThemeLinux5PaintEPN4skia14PlatformCanvasENS0_4PartENS0_5StateERKNS_4RectERKNS0_11ExtraParamsE
- fun:_ZN11webkit_glue18WebThemeEngineImpl5paintEPN4skia14PlatformCanvasEN6WebKit14WebThemeEngine4PartENS5_5StateERKNS4_7WebRectEPKNS5_11ExtraParamsE
- fun:_ZN7WebCore14PlatformBridge14paintThemePartEPNS_15GraphicsContextENS0_9ThemePartENS0_15ThemePaintStateERKNS_7IntRectEPKNS0_21ThemePaintExtraParamsE
- fun:_ZN7WebCore24RenderThemeChromiumLinux*paint*EPNS_12RenderObjectERKNS_9PaintInfoERKNS_7IntRectE
- fun:_ZN7WebCore11RenderTheme5paintEPNS_12RenderObjectERKNS_9PaintInfoERKNS_7IntRectE
- fun:_ZN7WebCore9RenderBox27paintBoxDecorationsWithSizeERNS_9PaintInfoEiiii
- fun:_ZN7WebCore9RenderBox19paintBoxDecorationsERNS_9PaintInfoEii
- fun:_ZN7WebCore11RenderBlock11paintObjectERNS_9PaintInfoEii
- fun:_ZN7WebCore11RenderBlock5paintERNS_9PaintInfoEii
-}
-{
- bug_77721
- Memcheck:Leak
- fun:_Znw*
- fun:_ZN3gfx9GfxModule14GetBitmapNamedEi
- fun:_ZN3gfx16NativeThemeLinux*
- fun:_ZN3gfx16NativeThemeLinux5PaintEPN4skia14PlatformCanvasENS0_4PartENS0_5StateERKNS_4RectERKNS0_11ExtraParamsE
- fun:_ZN11webkit_glue18WebThemeEngineImpl5paintEPN4skia14PlatformCanvasEN6WebKit14WebThemeEngine4PartENS5_5StateERKNS4_7WebRectEPKNS5_11ExtraParamsE
- fun:_ZN7WebCore14PlatformBridge14paintThemePartEPNS_15GraphicsContextENS0_9ThemePartENS0_15ThemePaintStateERKNS_7IntRectEPKNS0_21ThemePaintExtraParamsE
- fun:_ZN7WebCore24RenderThemeChromiumLinux*
- fun:_ZN7WebCore11RenderTheme5paintEPNS_12RenderObjectERKNS_9PaintInfoERKNS_7IntRectE
-}
-{
bug_77885
Memcheck:Leak
fun:malloc
diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc
index 7d60cfc..af615c0 100644
--- a/ui/base/resource/resource_bundle.cc
+++ b/ui/base/resource/resource_bundle.cc
@@ -65,6 +65,14 @@ std::string ResourceBundle::InitSharedInstance(
}
/* static */
+void ResourceBundle::InitSharedInstanceForTest(const FilePath& path) {
+ DCHECK(g_shared_instance_ == NULL) << "ResourceBundle initialized twice";
+ g_shared_instance_ = new ResourceBundle();
+
+ g_shared_instance_->LoadTestResources(path);
+}
+
+/* static */
std::string ResourceBundle::ReloadSharedInstance(
const std::string& pref_locale) {
DCHECK(g_shared_instance_ != NULL) << "ResourceBundle not initialized";
diff --git a/ui/base/resource/resource_bundle.h b/ui/base/resource/resource_bundle.h
index c77f01f..aa3d306 100644
--- a/ui/base/resource/resource_bundle.h
+++ b/ui/base/resource/resource_bundle.h
@@ -76,6 +76,9 @@ class ResourceBundle {
// defined by the Cocoa UI (ie-NSBundle does the langange work).
static std::string InitSharedInstance(const std::string& pref_locale);
+ // Initialize the ResourceBundle using given data pack path for testing.
+ static void InitSharedInstanceForTest(const FilePath& path);
+
// Changes the locale for an already-initialized ResourceBundle. Future
// calls to get strings will return the strings for this new locale. This
// has no effect on existing or future image resources. This has no effect
@@ -211,6 +214,9 @@ class ResourceBundle {
// Returns the locale that is loaded.
std::string LoadLocaleResources(const std::string& pref_locale);
+ // Load test resources in given path.
+ void LoadTestResources(const FilePath& path);
+
// Unload the locale specific strings and prepares to load new ones. See
// comments for ReloadSharedInstance().
void UnloadLocaleResources();
diff --git a/ui/base/resource/resource_bundle_posix.cc b/ui/base/resource/resource_bundle_posix.cc
index a5db6cb..97747e0 100644
--- a/ui/base/resource/resource_bundle_posix.cc
+++ b/ui/base/resource/resource_bundle_posix.cc
@@ -115,4 +115,12 @@ std::string ResourceBundle::LoadLocaleResources(
return app_locale;
}
+void ResourceBundle::LoadTestResources(const FilePath& path) {
+ DCHECK(!resources_data_) << "resource already loaded";
+
+ // Use the given resource pak for both common and localized resources.
+ resources_data_ = LoadResourcesDataPak(path);
+ locale_resources_data_ = LoadResourcesDataPak(path);
+}
+
} // namespace ui
diff --git a/ui/base/resource/resource_bundle_win.cc b/ui/base/resource/resource_bundle_win.cc
index 14b2769..36c35fe 100644
--- a/ui/base/resource/resource_bundle_win.cc
+++ b/ui/base/resource/resource_bundle_win.cc
@@ -68,6 +68,11 @@ std::string ResourceBundle::LoadLocaleResources(
return app_locale;
}
+void ResourceBundle::LoadTestResources(const FilePath& path) {
+ // ResourceBundle with test resources is only used on Linux test_sheel/DRT.
+ NOTREACHED();
+}
+
void ResourceBundle::UnloadLocaleResources() {
if (locale_resources_data_) {
BOOL rv = FreeLibrary(locale_resources_data_);
diff --git a/ui/gfx/gfx_module.cc b/ui/gfx/gfx_module.cc
deleted file mode 100644
index 020b797..0000000
--- a/ui/gfx/gfx_module.cc
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) 2011 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 "ui/gfx/gfx_module.h"
-
-#include <map>
-
-#include "base/logging.h"
-#include "base/scoped_ptr.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/gfx/codec/png_codec.h"
-
-namespace gfx {
-
-static GfxModule::ResourceProvider resource_provider = NULL;
-
-// static
-void GfxModule::SetResourceProvider(ResourceProvider func) {
- resource_provider = func;
-}
-
-// static
-base::StringPiece GfxModule::GetResource(int key) {
- return resource_provider ? resource_provider(key) : base::StringPiece();
-}
-
-// TODO(xiyuan): Use ResourceBundle to have shared cache when it is in ui_base.
-// static
-SkBitmap* GfxModule::GetBitmapNamed(int key) {
- typedef std::map<int, SkBitmap*> SkImageMap;
- static SkImageMap images; // Image resource cache.
-
- SkImageMap::const_iterator found = images.find(key);
- if (found != images.end())
- return found->second;
-
- base::StringPiece data = GetResource(key);
- if (!data.size()) {
- NOTREACHED() << "Unable to load image resource " << key;
- return NULL;
- }
-
- scoped_ptr<SkBitmap> bitmap(new SkBitmap);
- if (!gfx::PNGCodec::Decode(
- reinterpret_cast<const unsigned char*>(data.data()),
- data.size(), bitmap.get())) {
- NOTREACHED() << "Unable to decode image resource " << key;
- return NULL;
- }
-
- images[key] = bitmap.get();
- return bitmap.release();
-}
-
-} // namespace gfx
diff --git a/ui/gfx/gfx_module.h b/ui/gfx/gfx_module.h
deleted file mode 100644
index 311fc9b..0000000
--- a/ui/gfx/gfx_module.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2011 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.
-
-#ifndef UI_GFX_MODULE_H_
-#define UI_GFX_MODULE_H_
-#pragma once
-
-#include "base/basictypes.h"
-#include "base/string_piece.h"
-
-class SkBitmap;
-
-namespace gfx {
-
-// Defines global initializers and associated methods for the gfx module.
-// See net/base/net_module.h for more details.
-class GfxModule {
- public:
- typedef base::StringPiece (*ResourceProvider)(int key);
-
- // Set the function to call when the gfx module needs resources
- static void SetResourceProvider(ResourceProvider func);
-
- // Call the resource provider (if one exists) to get the specified resource.
- // Returns an empty string if the resource does not exist or if there is no
- // resource provider.
- static base::StringPiece GetResource(int key);
-
- // Load named resource and return decoded SkBitmap.
- // Note this function is not thread-safe and assumes that it would only be
- // called from UI thread.
- static SkBitmap* GetBitmapNamed(int key);
-
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(GfxModule);
-};
-
-} // namespace gfx
-
-#endif // UI_GFX_MODULE_H_
diff --git a/ui/gfx/native_theme_chromeos.cc b/ui/gfx/native_theme_chromeos.cc
index afa1668..fe3ed72 100644
--- a/ui/gfx/native_theme_chromeos.cc
+++ b/ui/gfx/native_theme_chromeos.cc
@@ -10,7 +10,7 @@
#include "third_party/skia/include/core/SkPaint.h"
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkShader.h"
-#include "ui/gfx/gfx_module.h"
+#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
@@ -298,13 +298,12 @@ gfx::Size NativeThemeChromeos::GetPartSize(Part part) const {
void NativeThemeChromeos::PaintScrollbarTrack(skia::PlatformCanvas* canvas,
Part part, State state,
const ScrollbarTrackExtraParams& extra_params, const gfx::Rect& rect) {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
if (part == kScrollbarVerticalTrack) {
- SkBitmap* background =
- gfx::GfxModule::GetBitmapNamed(IDR_SCROLL_BACKGROUND);
- SkBitmap* border_up =
- gfx::GfxModule::GetBitmapNamed(IDR_SCROLL_BACKGROUND_BORDER_UP);
+ SkBitmap* background = rb.GetBitmapNamed(IDR_SCROLL_BACKGROUND);
+ SkBitmap* border_up = rb.GetBitmapNamed(IDR_SCROLL_BACKGROUND_BORDER_UP);
SkBitmap* border_down =
- gfx::GfxModule::GetBitmapNamed(IDR_SCROLL_BACKGROUND_BORDER_DOWN);
+ rb.GetBitmapNamed(IDR_SCROLL_BACKGROUND_BORDER_DOWN);
// Draw track background.
DrawBitmapInt(
canvas, *background,
@@ -342,13 +341,14 @@ void NativeThemeChromeos::PaintScrollbarTrack(skia::PlatformCanvas* canvas,
void NativeThemeChromeos::PaintScrollbarThumb(skia::PlatformCanvas* canvas,
Part part, State state, const gfx::Rect& rect) {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
int resource_id = IDR_SCROLL_THUMB;
if (state == kHovered)
resource_id++;
else if (state == kPressed)
resource_id += 2;
if (part == kScrollbarVerticalThumb) {
- SkBitmap* bitmap = gfx::GfxModule::GetBitmapNamed(resource_id);
+ SkBitmap* bitmap = rb.GetBitmapNamed(resource_id);
// Top
DrawBitmapInt(
canvas, *bitmap,
@@ -386,6 +386,7 @@ void NativeThemeChromeos::PaintScrollbarThumb(skia::PlatformCanvas* canvas,
void NativeThemeChromeos::PaintArrowButton(skia::PlatformCanvas* canvas,
const gfx::Rect& rect, Part part, State state) {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
int resource_id =
(part == kScrollbarUpArrow || part == kScrollbarLeftArrow) ?
IDR_SCROLL_ARROW_UP : IDR_SCROLL_ARROW_DOWN;
@@ -395,7 +396,7 @@ void NativeThemeChromeos::PaintArrowButton(skia::PlatformCanvas* canvas,
resource_id += 2;
SkBitmap* bitmap;
if (part == kScrollbarUpArrow || part == kScrollbarDownArrow)
- bitmap = gfx::GfxModule::GetBitmapNamed(resource_id);
+ bitmap = rb.GetBitmapNamed(resource_id);
else
bitmap = GetHorizontalBitmapNamed(resource_id);
DrawBitmapInt(canvas, *bitmap,
@@ -678,7 +679,8 @@ SkBitmap* NativeThemeChromeos::GetHorizontalBitmapNamed(int resource_id) {
if (found != horizontal_bitmaps_.end())
return found->second;
- SkBitmap* vertical_bitmap = gfx::GfxModule::GetBitmapNamed(resource_id);
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ SkBitmap* vertical_bitmap = rb.GetBitmapNamed(resource_id);
if (vertical_bitmap) {
SkBitmap transposed_bitmap =
diff --git a/ui/gfx/native_theme_linux.cc b/ui/gfx/native_theme_linux.cc
index d873739..e6d0d14 100644
--- a/ui/gfx/native_theme_linux.cc
+++ b/ui/gfx/native_theme_linux.cc
@@ -9,8 +9,8 @@
#include "base/logging.h"
#include "grit/gfx_resources.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
+#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/color_utils.h"
-#include "ui/gfx/gfx_module.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
@@ -383,19 +383,20 @@ void NativeThemeLinux::PaintCheckbox(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
const ButtonExtraParams& button) {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
SkBitmap* image = NULL;
if (button.indeterminate) {
image = state == kDisabled ?
- GfxModule::GetBitmapNamed(IDR_LINUX_CHECKBOX_DISABLED_INDETERMINATE) :
- GfxModule::GetBitmapNamed(IDR_LINUX_CHECKBOX_INDETERMINATE);
+ rb.GetBitmapNamed(IDR_LINUX_CHECKBOX_DISABLED_INDETERMINATE) :
+ rb.GetBitmapNamed(IDR_LINUX_CHECKBOX_INDETERMINATE);
} else if (button.checked) {
image = state == kDisabled ?
- GfxModule::GetBitmapNamed(IDR_LINUX_CHECKBOX_DISABLED_ON) :
- GfxModule::GetBitmapNamed(IDR_LINUX_CHECKBOX_ON);
+ rb.GetBitmapNamed(IDR_LINUX_CHECKBOX_DISABLED_ON) :
+ rb.GetBitmapNamed(IDR_LINUX_CHECKBOX_ON);
} else {
image = state == kDisabled ?
- GfxModule::GetBitmapNamed(IDR_LINUX_CHECKBOX_DISABLED_OFF) :
- GfxModule::GetBitmapNamed(IDR_LINUX_CHECKBOX_OFF);
+ rb.GetBitmapNamed(IDR_LINUX_CHECKBOX_DISABLED_OFF) :
+ rb.GetBitmapNamed(IDR_LINUX_CHECKBOX_OFF);
}
gfx::Rect bounds = rect.Center(gfx::Size(image->width(), image->height()));
@@ -407,15 +408,16 @@ void NativeThemeLinux::PaintRadio(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
const ButtonExtraParams& button) {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
SkBitmap* image = NULL;
if (state == kDisabled) {
image = button.checked ?
- GfxModule::GetBitmapNamed(IDR_LINUX_RADIO_DISABLED_ON) :
- GfxModule::GetBitmapNamed(IDR_LINUX_RADIO_DISABLED_OFF);
+ rb.GetBitmapNamed(IDR_LINUX_RADIO_DISABLED_ON) :
+ rb.GetBitmapNamed(IDR_LINUX_RADIO_DISABLED_OFF);
} else {
image = button.checked ?
- GfxModule::GetBitmapNamed(IDR_LINUX_RADIO_ON) :
- GfxModule::GetBitmapNamed(IDR_LINUX_RADIO_OFF);
+ rb.GetBitmapNamed(IDR_LINUX_RADIO_ON) :
+ rb.GetBitmapNamed(IDR_LINUX_RADIO_OFF);
}
gfx::Rect bounds = rect.Center(gfx::Size(image->width(), image->height()));
@@ -697,11 +699,10 @@ void NativeThemeLinux::PaintProgressBar(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
const ProgressBarExtraParams& progress_bar) {
- SkBitmap* bar_image = GfxModule::GetBitmapNamed(IDR_PROGRESS_BAR);
- SkBitmap* left_border_image = GfxModule::GetBitmapNamed(
- IDR_PROGRESS_BORDER_LEFT);
- SkBitmap* right_border_image = GfxModule::GetBitmapNamed(
- IDR_PROGRESS_BORDER_RIGHT);
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ SkBitmap* bar_image = rb.GetBitmapNamed(IDR_PROGRESS_BAR);
+ SkBitmap* left_border_image = rb.GetBitmapNamed(IDR_PROGRESS_BORDER_LEFT);
+ SkBitmap* right_border_image = rb.GetBitmapNamed(IDR_PROGRESS_BORDER_RIGHT);
double tile_scale = static_cast<double>(rect.height()) /
bar_image->height();
@@ -714,7 +715,7 @@ void NativeThemeLinux::PaintProgressBar(skia::PlatformCanvas* canvas,
rect.x(), rect.y(), rect.width(), rect.height());
if (progress_bar.value_rect_width) {
- SkBitmap* value_image = GfxModule::GetBitmapNamed(IDR_PROGRESS_VALUE);
+ SkBitmap* value_image = rb.GetBitmapNamed(IDR_PROGRESS_VALUE);
new_tile_width = static_cast<int>(value_image->width() * tile_scale);
tile_scale_x = static_cast<double>(new_tile_width) /
diff --git a/ui/ui_gfx.gypi b/ui/ui_gfx.gypi
index c01420a..78303a6 100644
--- a/ui/ui_gfx.gypi
+++ b/ui/ui_gfx.gypi
@@ -74,8 +74,6 @@
'gfx/font.cc',
'gfx/gfx_paths.cc',
'gfx/gfx_paths.h',
- 'gfx/gfx_module.cc',
- 'gfx/gfx_module.h',
'gfx/image.cc',
'gfx/image.h',
'gfx/image_mac.mm',
diff --git a/webkit/support/platform_support_gtk.cc b/webkit/support/platform_support_gtk.cc
index 41b144c..b315958 100644
--- a/webkit/support/platform_support_gtk.cc
+++ b/webkit/support/platform_support_gtk.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -11,22 +11,7 @@
#include "base/string16.h"
#include "base/string_piece.h"
#include "grit/webkit_resources.h"
-#include "ui/base/resource/data_pack.h"
-#include "ui/gfx/gfx_module.h"
-
-namespace {
-
-// Data resources on linux. This is a pointer to the mmapped resources file.
-ui::DataPack* g_resource_data_pack = NULL;
-
-base::StringPiece TestResourceProvider(int resource_id) {
- base::StringPiece res;
- if (g_resource_data_pack)
- g_resource_data_pack->GetStringPiece(resource_id, &res);
- return res;
-}
-
-}
+#include "ui/base/resource/resource_bundle.h"
namespace webkit_support {
@@ -39,18 +24,15 @@ void BeforeInitialize(bool unit_test_mode) {
void AfterInitialize(bool unit_test_mode) {
if (unit_test_mode)
return; // We don't have a resource pack when running the unit-tests.
- g_resource_data_pack = new ui::DataPack;
+
FilePath data_path;
PathService::Get(base::DIR_EXE, &data_path);
data_path = data_path.Append("DumpRenderTree.pak");
- if (!g_resource_data_pack->Load(data_path))
- LOG(FATAL) << "failed to load DumpRenderTree.pak";
-
- // Config the modules that need access to a limited set of resources.
- gfx::GfxModule::SetResourceProvider(TestResourceProvider);
+ ResourceBundle::InitSharedInstanceForTest(data_path);
}
void BeforeShutdown() {
+ ResourceBundle::CleanupSharedInstance();
}
void AfterShutdown() {
@@ -61,12 +43,7 @@ void AfterShutdown() {
namespace webkit_glue {
string16 GetLocalizedString(int message_id) {
- base::StringPiece res;
- if (!g_resource_data_pack->GetStringPiece(message_id, &res))
- LOG(FATAL) << "failed to load webkit string with id " << message_id;
-
- return string16(reinterpret_cast<const char16*>(res.data()),
- res.length() / 2);
+ return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id);
}
base::StringPiece GetDataResource(int resource_id) {
@@ -95,9 +72,8 @@ base::StringPiece GetDataResource(int resource_id) {
return resize_corner_data;
}
}
- base::StringPiece res;
- g_resource_data_pack->GetStringPiece(resource_id, &res);
- return res;
+
+ return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id);
}
} // namespace webkit_glue
diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc
index 9f8ec9d..b94da99 100644
--- a/webkit/tools/test_shell/test_shell_gtk.cc
+++ b/webkit/tools/test_shell/test_shell_gtk.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -25,7 +25,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPoint.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
-#include "ui/base/resource/data_pack.h"
+#include "ui/base/resource/resource_bundle.h"
#include "webkit/glue/plugins/plugin_list.h"
#include "webkit/glue/resource_loader_bridge.h"
#include "webkit/glue/webkit_glue.h"
@@ -44,9 +44,6 @@ const FcChar8* FilePathAsFcChar(const FilePath& path) {
return reinterpret_cast<const FcChar8*>(path.value().c_str());
}
-// Data resources on linux. This is a pointer to the mmapped resources file.
-ui::DataPack* g_resource_data_pack = NULL;
-
void TerminationSignalHandler(int signatl) {
TestShell::ShutdownTestShell();
exit(0);
@@ -159,13 +156,10 @@ void TestShell::InitializeTestShell(bool layout_test_mode,
web_prefs_ = new WebPreferences;
- g_resource_data_pack = new ui::DataPack;
FilePath data_path;
PathService::Get(base::DIR_EXE, &data_path);
data_path = data_path.Append("test_shell.pak");
- if (!g_resource_data_pack->Load(data_path)) {
- LOG(FATAL) << "failed to load test_shell.pak";
- }
+ ResourceBundle::InitSharedInstanceForTest(data_path);
FilePath resources_dir;
PathService::Get(base::DIR_SOURCE_ROOT, &resources_dir);
@@ -281,8 +275,7 @@ void TestShell::InitializeTestShell(bool layout_test_mode,
}
void TestShell::PlatformShutdown() {
- delete g_resource_data_pack;
- g_resource_data_pack = NULL;
+ ResourceBundle::CleanupSharedInstance();
}
void TestShell::PlatformCleanUp() {
@@ -563,9 +556,7 @@ void TestShell::ShowStartupDebuggingDialog() {
// static
base::StringPiece TestShell::ResourceProvider(int key) {
- base::StringPiece res;
- g_resource_data_pack->GetStringPiece(key, &res);
- return res;
+ return ResourceBundle::GetSharedInstance().GetRawDataResource(key);
}
//-----------------------------------------------------------------------------
@@ -573,13 +564,7 @@ base::StringPiece TestShell::ResourceProvider(int key) {
namespace webkit_glue {
string16 GetLocalizedString(int message_id) {
- base::StringPiece res;
- if (!g_resource_data_pack->GetStringPiece(message_id, &res)) {
- LOG(FATAL) << "failed to load webkit string with id " << message_id;
- }
-
- return string16(reinterpret_cast<const char16*>(res.data()),
- res.length() / 2);
+ return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id);
}
base::StringPiece GetDataResource(int resource_id) {
diff --git a/webkit/tools/test_shell/test_shell_main.cc b/webkit/tools/test_shell/test_shell_main.cc
index 0b26419..49ed62b 100644
--- a/webkit/tools/test_shell/test_shell_main.cc
+++ b/webkit/tools/test_shell/test_shell_main.cc
@@ -29,7 +29,6 @@
#include "net/url_request/url_request_context.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h"
-#include "ui/gfx/gfx_module.h"
#include "ui/gfx/gl/gl_implementation.h"
#include "ui/gfx/gl/gl_switches.h"
#include "webkit/glue/webkit_glue.h"
@@ -198,7 +197,6 @@ int main(int argc, char* argv[]) {
// Config the modules that need access to a limited set of resources.
net::NetModule::SetResourceProvider(TestShell::ResourceProvider);
- gfx::GfxModule::SetResourceProvider(TestShell::ResourceProvider);
platform.InitializeGUI();