| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 141 |
| 142 // Send. | 142 // Send. |
| 143 SendResponse(request_id, css_bytes); | 143 SendResponse(request_id, css_bytes); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void DOMUIThemeSource::SendThemeBitmap(int request_id, int resource_id) { | 146 void DOMUIThemeSource::SendThemeBitmap(int request_id, int resource_id) { |
| 147 ThemeProvider* tp = profile_->GetThemeProvider(); | 147 ThemeProvider* tp = profile_->GetThemeProvider(); |
| 148 DCHECK(tp); | 148 DCHECK(tp); |
| 149 | 149 |
| 150 SkBitmap* image = tp->GetBitmapNamed(resource_id); | 150 SkBitmap* image = tp->GetBitmapNamed(resource_id); |
| 151 DCHECK(image); | 151 if (!image || image->empty()) { |
| 152 SendResponse(request_id, NULL); |
| 153 return; |
| 154 } |
| 155 |
| 152 std::vector<unsigned char> png_bytes; | 156 std::vector<unsigned char> png_bytes; |
| 153 PNGEncoder::EncodeBGRASkBitmap(*image, false, &png_bytes); | 157 PNGEncoder::EncodeBGRASkBitmap(*image, false, &png_bytes); |
| 154 | 158 |
| 155 scoped_refptr<RefCountedBytes> image_data = | 159 scoped_refptr<RefCountedBytes> image_data = |
| 156 new RefCountedBytes(png_bytes); | 160 new RefCountedBytes(png_bytes); |
| 157 SendResponse(request_id, image_data); | 161 SendResponse(request_id, image_data); |
| 158 } | 162 } |
| 159 | 163 |
| 160 std::string DOMUIThemeSource::GetNewTabBackgroundCSS(bool bar_attached) { | 164 std::string DOMUIThemeSource::GetNewTabBackgroundCSS(bool bar_attached) { |
| 161 int alignment; | 165 int alignment; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 183 return BrowserThemeProvider::AlignmentToString(alignment); | 187 return BrowserThemeProvider::AlignmentToString(alignment); |
| 184 } | 188 } |
| 185 | 189 |
| 186 std::string DOMUIThemeSource::GetNewTabBackgroundTilingCSS() { | 190 std::string DOMUIThemeSource::GetNewTabBackgroundTilingCSS() { |
| 187 int repeat_mode; | 191 int repeat_mode; |
| 188 profile_->GetThemeProvider()->GetDisplayProperty( | 192 profile_->GetThemeProvider()->GetDisplayProperty( |
| 189 BrowserThemeProvider::NTP_BACKGROUND_TILING, &repeat_mode); | 193 BrowserThemeProvider::NTP_BACKGROUND_TILING, &repeat_mode); |
| 190 return BrowserThemeProvider::TilingToString(repeat_mode); | 194 return BrowserThemeProvider::TilingToString(repeat_mode); |
| 191 } | 195 } |
| 192 | 196 |
| OLD | NEW |