Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: chrome/browser/dom_ui/dom_ui_theme_source.cc

Issue 159146: Sometimes it's possible for a DOMUI to request images that don't exist (theme... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698