OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/theme_source.h" | 5 #include "chrome/browser/ui/webui/theme_source.h" |
6 | 6 |
7 #include "base/memory/ref_counted_memory.h" | 7 #include "base/memory/ref_counted_memory.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 ui::ScaleFactor scale_factor; | 63 ui::ScaleFactor scale_factor; |
64 std::string uncached_path; | 64 std::string uncached_path; |
65 webui::ParsePathAndScale(GURL(GetThemePath() + path), | 65 webui::ParsePathAndScale(GURL(GetThemePath() + path), |
66 &uncached_path, | 66 &uncached_path, |
67 &scale_factor); | 67 &scale_factor); |
68 | 68 |
69 if (uncached_path == kNewTabCSSPath || | 69 if (uncached_path == kNewTabCSSPath || |
70 uncached_path == kNewIncognitoTabCSSPath) { | 70 uncached_path == kNewIncognitoTabCSSPath) { |
71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
72 | 72 |
73 callback.Run(css_bytes_); | 73 callback.Run(css_bytes_.get()); |
74 return; | 74 return; |
75 } | 75 } |
76 | 76 |
77 | 77 |
78 int resource_id = ResourcesUtil::GetThemeResourceId(uncached_path); | 78 int resource_id = ResourcesUtil::GetThemeResourceId(uncached_path); |
79 if (resource_id != -1) { | 79 if (resource_id != -1) { |
80 SendThemeBitmap(callback, resource_id, scale_factor); | 80 SendThemeBitmap(callback, resource_id, scale_factor); |
81 return; | 81 return; |
82 } | 82 } |
83 | 83 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 const content::URLDataSource::GotDataCallback& callback, | 136 const content::URLDataSource::GotDataCallback& callback, |
137 int resource_id, | 137 int resource_id, |
138 ui::ScaleFactor scale_factor) { | 138 ui::ScaleFactor scale_factor) { |
139 if (ThemeProperties::IsThemeableImage(resource_id)) { | 139 if (ThemeProperties::IsThemeableImage(resource_id)) { |
140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
141 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); | 141 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); |
142 DCHECK(tp); | 142 DCHECK(tp); |
143 | 143 |
144 scoped_refptr<base::RefCountedMemory> image_data(tp->GetRawData( | 144 scoped_refptr<base::RefCountedMemory> image_data(tp->GetRawData( |
145 resource_id, scale_factor)); | 145 resource_id, scale_factor)); |
146 callback.Run(image_data); | 146 callback.Run(image_data.get()); |
147 } else { | 147 } else { |
148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
149 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 149 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
150 callback.Run(rb.LoadDataResourceBytesForScale(resource_id, scale_factor)); | 150 callback.Run(rb.LoadDataResourceBytesForScale(resource_id, scale_factor)); |
151 } | 151 } |
152 } | 152 } |
OLD | NEW |