| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/dom_ui/dom_ui_theme_source.h" | 5 #include "chrome/browser/dom_ui/dom_ui_theme_source.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "app/theme_provider.h" | 9 #include "app/theme_provider.h" |
| 10 #include "base/gfx/png_encoder.h" | 10 #include "base/gfx/png_encoder.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 std::copy(css_string2.begin(), css_string2.end(), css_bytes->data.begin()); | 148 std::copy(css_string2.begin(), css_string2.end(), css_bytes->data.begin()); |
| 149 | 149 |
| 150 // Send. | 150 // Send. |
| 151 SendResponse(request_id, css_bytes); | 151 SendResponse(request_id, css_bytes); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void DOMUIThemeSource::SendThemeBitmap(int request_id, int resource_id) { | 154 void DOMUIThemeSource::SendThemeBitmap(int request_id, int resource_id) { |
| 155 ThemeProvider* tp = profile_->GetThemeProvider(); | 155 ThemeProvider* tp = profile_->GetThemeProvider(); |
| 156 DCHECK(tp); | 156 DCHECK(tp); |
| 157 | 157 |
| 158 SkBitmap* image = tp->GetBitmapNamed(resource_id); | 158 std::vector<unsigned char> png_bytes; |
| 159 if (!image || image->empty()) { | 159 if (tp->GetRawData(resource_id, &png_bytes)) { |
| 160 scoped_refptr<RefCountedBytes> image_data = |
| 161 new RefCountedBytes(png_bytes); |
| 162 SendResponse(request_id, image_data); |
| 163 } else { |
| 160 SendResponse(request_id, NULL); | 164 SendResponse(request_id, NULL); |
| 161 return; | |
| 162 } | 165 } |
| 163 | |
| 164 std::vector<unsigned char> png_bytes; | |
| 165 PNGEncoder::EncodeBGRASkBitmap(*image, false, &png_bytes); | |
| 166 | |
| 167 scoped_refptr<RefCountedBytes> image_data = | |
| 168 new RefCountedBytes(png_bytes); | |
| 169 SendResponse(request_id, image_data); | |
| 170 } | 166 } |
| 171 | 167 |
| 172 std::string DOMUIThemeSource::GetNewTabBackgroundCSS(bool bar_attached) { | 168 std::string DOMUIThemeSource::GetNewTabBackgroundCSS(bool bar_attached) { |
| 173 int alignment; | 169 int alignment; |
| 174 profile_->GetThemeProvider()->GetDisplayProperty( | 170 profile_->GetThemeProvider()->GetDisplayProperty( |
| 175 BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT, &alignment); | 171 BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT, &alignment); |
| 176 | 172 |
| 177 if (bar_attached) | 173 if (bar_attached) |
| 178 return BrowserThemeProvider::AlignmentToString(alignment); | 174 return BrowserThemeProvider::AlignmentToString(alignment); |
| 179 | 175 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 203 return BrowserThemeProvider::AlignmentToString(alignment); | 199 return BrowserThemeProvider::AlignmentToString(alignment); |
| 204 } | 200 } |
| 205 | 201 |
| 206 std::string DOMUIThemeSource::GetNewTabBackgroundTilingCSS() { | 202 std::string DOMUIThemeSource::GetNewTabBackgroundTilingCSS() { |
| 207 int repeat_mode; | 203 int repeat_mode; |
| 208 profile_->GetThemeProvider()->GetDisplayProperty( | 204 profile_->GetThemeProvider()->GetDisplayProperty( |
| 209 BrowserThemeProvider::NTP_BACKGROUND_TILING, &repeat_mode); | 205 BrowserThemeProvider::NTP_BACKGROUND_TILING, &repeat_mode); |
| 210 return BrowserThemeProvider::TilingToString(repeat_mode); | 206 return BrowserThemeProvider::TilingToString(repeat_mode); |
| 211 } | 207 } |
| 212 | 208 |
| OLD | NEW |