| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/web_ui_theme_source.h" | 5 #include "chrome/browser/dom_ui/web_ui_theme_source.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/ref_counted_memory.h" | 8 #include "base/ref_counted_memory.h" |
| 9 #include "chrome/browser/browser_thread.h" | 9 #include "chrome/browser/browser_thread.h" |
| 10 #include "chrome/browser/dom_ui/ntp_resource_cache.h" | 10 #include "chrome/browser/dom_ui/ntp_resource_cache.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 87 } |
| 88 | 88 |
| 89 // If it's not a themeable image, we don't need to go to the UI thread. | 89 // If it's not a themeable image, we don't need to go to the UI thread. |
| 90 int resource_id = ResourcesUtil::GetThemeResourceId(uncached_path); | 90 int resource_id = ResourcesUtil::GetThemeResourceId(uncached_path); |
| 91 if (!BrowserThemeProvider::IsThemeableImage(resource_id)) | 91 if (!BrowserThemeProvider::IsThemeableImage(resource_id)) |
| 92 return NULL; | 92 return NULL; |
| 93 | 93 |
| 94 return DataSource::MessageLoopForRequestPath(path); | 94 return DataSource::MessageLoopForRequestPath(path); |
| 95 } | 95 } |
| 96 | 96 |
| 97 bool WebUIThemeSource::ShouldReplaceExistingSource() const { |
| 98 return false; |
| 99 } |
| 100 |
| 97 //////////////////////////////////////////////////////////////////////////////// | 101 //////////////////////////////////////////////////////////////////////////////// |
| 98 // WebUIThemeSource, private: | 102 // WebUIThemeSource, private: |
| 99 | 103 |
| 100 void WebUIThemeSource::SendThemeBitmap(int request_id, int resource_id) { | 104 void WebUIThemeSource::SendThemeBitmap(int request_id, int resource_id) { |
| 101 if (BrowserThemeProvider::IsThemeableImage(resource_id)) { | 105 if (BrowserThemeProvider::IsThemeableImage(resource_id)) { |
| 102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 106 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 103 ui::ThemeProvider* tp = profile_->GetThemeProvider(); | 107 ui::ThemeProvider* tp = profile_->GetThemeProvider(); |
| 104 DCHECK(tp); | 108 DCHECK(tp); |
| 105 | 109 |
| 106 scoped_refptr<RefCountedMemory> image_data(tp->GetRawData(resource_id)); | 110 scoped_refptr<RefCountedMemory> image_data(tp->GetRawData(resource_id)); |
| 107 SendResponse(request_id, image_data); | 111 SendResponse(request_id, image_data); |
| 108 } else { | 112 } else { |
| 109 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 113 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 110 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 114 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 111 SendResponse(request_id, rb.LoadDataResourceBytes(resource_id)); | 115 SendResponse(request_id, rb.LoadDataResourceBytes(resource_id)); |
| 112 } | 116 } |
| 113 } | 117 } |
| OLD | NEW |