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/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 std::string uncached_path = StripQueryParams(path); | 83 std::string uncached_path = StripQueryParams(path); |
84 | 84 |
85 if (uncached_path == kNewTabCSSPath || | 85 if (uncached_path == kNewTabCSSPath || |
86 uncached_path == kNewIncognitoTabCSSPath) { | 86 uncached_path == kNewIncognitoTabCSSPath) { |
87 return "text/css"; | 87 return "text/css"; |
88 } | 88 } |
89 | 89 |
90 return "image/png"; | 90 return "image/png"; |
91 } | 91 } |
92 | 92 |
93 void DOMUIThemeSource::SendResponse(int request_id, RefCountedBytes* data) { | 93 void DOMUIThemeSource::SendResponse(int request_id, RefCountedMemory* data) { |
94 ChromeURLDataManager::DataSource::SendResponse(request_id, data); | 94 ChromeURLDataManager::DataSource::SendResponse(request_id, data); |
95 } | 95 } |
96 | 96 |
97 MessageLoop* DOMUIThemeSource::MessageLoopForRequestPath( | 97 MessageLoop* DOMUIThemeSource::MessageLoopForRequestPath( |
98 const std::string& path) const { | 98 const std::string& path) const { |
99 std::string uncached_path = StripQueryParams(path); | 99 std::string uncached_path = StripQueryParams(path); |
100 | 100 |
101 if (uncached_path == kNewTabCSSPath || | 101 if (uncached_path == kNewTabCSSPath || |
102 uncached_path == kNewIncognitoTabCSSPath) { | 102 uncached_path == kNewIncognitoTabCSSPath) { |
103 // All of the operations that need to be on the UI thread for these | 103 // All of the operations that need to be on the UI thread for these |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 std::copy(css_string.begin(), css_string.end(), css_bytes->data.begin()); | 241 std::copy(css_string.begin(), css_string.end(), css_bytes->data.begin()); |
242 | 242 |
243 // Send. | 243 // Send. |
244 SendResponse(request_id, css_bytes); | 244 SendResponse(request_id, css_bytes); |
245 } | 245 } |
246 | 246 |
247 void DOMUIThemeSource::SendThemeBitmap(int request_id, int resource_id) { | 247 void DOMUIThemeSource::SendThemeBitmap(int request_id, int resource_id) { |
248 ThemeProvider* tp = profile_->GetThemeProvider(); | 248 ThemeProvider* tp = profile_->GetThemeProvider(); |
249 DCHECK(tp); | 249 DCHECK(tp); |
250 | 250 |
251 std::vector<unsigned char> png_bytes; | 251 scoped_refptr<RefCountedMemory> image_data(tp->GetRawData(resource_id)); |
252 if (tp->GetRawData(resource_id, &png_bytes)) { | 252 SendResponse(request_id, image_data); |
253 scoped_refptr<RefCountedBytes> image_data = | |
254 new RefCountedBytes(png_bytes); | |
255 SendResponse(request_id, image_data); | |
256 } else { | |
257 SendResponse(request_id, NULL); | |
258 } | |
259 } | 253 } |
260 | 254 |
261 std::string DOMUIThemeSource::GetNewTabBackgroundCSS(bool bar_attached) { | 255 std::string DOMUIThemeSource::GetNewTabBackgroundCSS(bool bar_attached) { |
262 int alignment; | 256 int alignment; |
263 profile_->GetThemeProvider()->GetDisplayProperty( | 257 profile_->GetThemeProvider()->GetDisplayProperty( |
264 BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT, &alignment); | 258 BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT, &alignment); |
265 | 259 |
266 // TODO(glen): This is a quick workaround to hide the notused.png image when | 260 // TODO(glen): This is a quick workaround to hide the notused.png image when |
267 // no image is provided - we don't have time right now to figure out why | 261 // no image is provided - we don't have time right now to figure out why |
268 // this is painting as white. | 262 // this is painting as white. |
(...skipping 27 matching lines...) Expand all Loading... |
296 return BrowserThemeProvider::AlignmentToString(alignment); | 290 return BrowserThemeProvider::AlignmentToString(alignment); |
297 } | 291 } |
298 | 292 |
299 std::string DOMUIThemeSource::GetNewTabBackgroundTilingCSS() { | 293 std::string DOMUIThemeSource::GetNewTabBackgroundTilingCSS() { |
300 int repeat_mode; | 294 int repeat_mode; |
301 profile_->GetThemeProvider()->GetDisplayProperty( | 295 profile_->GetThemeProvider()->GetDisplayProperty( |
302 BrowserThemeProvider::NTP_BACKGROUND_TILING, &repeat_mode); | 296 BrowserThemeProvider::NTP_BACKGROUND_TILING, &repeat_mode); |
303 return BrowserThemeProvider::TilingToString(repeat_mode); | 297 return BrowserThemeProvider::TilingToString(repeat_mode); |
304 } | 298 } |
305 | 299 |
OLD | NEW |