summaryrefslogtreecommitdiffstats
path: root/chrome/browser/dom_ui
diff options
context:
space:
mode:
authorglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-05 01:33:36 +0000
committerglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-05 01:33:36 +0000
commit04a1f975f55a6bd2d73a45f0cec8bb2b8a5a67dd (patch)
tree6da04673ee580778b5ae4f1d42bae5d83df2ae93 /chrome/browser/dom_ui
parentbec7e3c3e479216d419281af4bf52151101fb6a9 (diff)
downloadchromium_src-04a1f975f55a6bd2d73a45f0cec8bb2b8a5a67dd.zip
chromium_src-04a1f975f55a6bd2d73a45f0cec8bb2b8a5a67dd.tar.gz
chromium_src-04a1f975f55a6bd2d73a45f0cec8bb2b8a5a67dd.tar.bz2
Make the DOMUIThemeSource load and pass through a PNG, rather than relying on decode/encode.
BUG=18427 TEST=Install a giant theme, load the NNTP, verify that you can type in the omnibox without delay while the page is loading. Review URL: http://codereview.chromium.org/159891 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22457 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r--chrome/browser/dom_ui/dom_ui_theme_source.cc16
-rw-r--r--chrome/browser/dom_ui/dom_ui_theme_source_unittest.cc16
2 files changed, 12 insertions, 20 deletions
diff --git a/chrome/browser/dom_ui/dom_ui_theme_source.cc b/chrome/browser/dom_ui/dom_ui_theme_source.cc
index 7e7fd38..2b7b826 100644
--- a/chrome/browser/dom_ui/dom_ui_theme_source.cc
+++ b/chrome/browser/dom_ui/dom_ui_theme_source.cc
@@ -155,18 +155,14 @@ void DOMUIThemeSource::SendThemeBitmap(int request_id, int resource_id) {
ThemeProvider* tp = profile_->GetThemeProvider();
DCHECK(tp);
- SkBitmap* image = tp->GetBitmapNamed(resource_id);
- if (!image || image->empty()) {
+ std::vector<unsigned char> png_bytes;
+ if (tp->GetRawData(resource_id, &png_bytes)) {
+ scoped_refptr<RefCountedBytes> image_data =
+ new RefCountedBytes(png_bytes);
+ SendResponse(request_id, image_data);
+ } else {
SendResponse(request_id, NULL);
- return;
}
-
- std::vector<unsigned char> png_bytes;
- PNGEncoder::EncodeBGRASkBitmap(*image, false, &png_bytes);
-
- scoped_refptr<RefCountedBytes> image_data =
- new RefCountedBytes(png_bytes);
- SendResponse(request_id, image_data);
}
std::string DOMUIThemeSource::GetNewTabBackgroundCSS(bool bar_attached) {
diff --git a/chrome/browser/dom_ui/dom_ui_theme_source_unittest.cc b/chrome/browser/dom_ui/dom_ui_theme_source_unittest.cc
index 1d323fa..561cd6d 100644
--- a/chrome/browser/dom_ui/dom_ui_theme_source_unittest.cc
+++ b/chrome/browser/dom_ui/dom_ui_theme_source_unittest.cc
@@ -17,7 +17,7 @@ class MockThemeSource : public DOMUIThemeSource {
explicit MockThemeSource(Profile* profile)
: DOMUIThemeSource(profile),
result_request_id_(-1),
- result_data_size_(0) {
+ result_data_size_(0) {
}
virtual void SendResponse(int request_id, RefCountedBytes* data) {
@@ -56,20 +56,16 @@ TEST_F(DOMUISourcesTest, ThemeSourceMimeTypes) {
}
TEST_F(DOMUISourcesTest, ThemeSourceImages) {
- // Our test data. Rather than comparing the data itself, we just compare
- // its size.
- SkBitmap* image = ResourceBundle::GetSharedInstance().GetBitmapNamed(
- IDR_THEME_FRAME_INCOGNITO);
- std::vector<unsigned char> png_bytes;
- PNGEncoder::EncodeBGRASkBitmap(*image, false, &png_bytes);
-
+ // We used to PNGEncode the images ourselves, but encoder differences
+ // invalidated that. We now just check that the image exists.
theme_source()->StartDataRequest("theme_frame_incognito", 1);
+ size_t min = 0;
EXPECT_EQ(theme_source()->result_request_id_, 1);
- EXPECT_EQ(theme_source()->result_data_size_, png_bytes.size());
+ EXPECT_GT(theme_source()->result_data_size_, min);
theme_source()->StartDataRequest("theme_toolbar", 2);
EXPECT_EQ(theme_source()->result_request_id_, 2);
- EXPECT_NE(theme_source()->result_data_size_, png_bytes.size());
+ EXPECT_GT(theme_source()->result_data_size_, min);
}
TEST_F(DOMUISourcesTest, ThemeSourceCSS) {