Chromium Code Reviews| 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/message_loop.h" | 8 #include "base/message_loop/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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 std::string ThemeSource::GetSource() const { | 55 std::string ThemeSource::GetSource() const { |
| 56 return chrome::kChromeUIThemePath; | 56 return chrome::kChromeUIThemePath; |
| 57 } | 57 } |
| 58 | 58 |
| 59 void ThemeSource::StartDataRequest( | 59 void ThemeSource::StartDataRequest( |
| 60 const std::string& path, | 60 const std::string& path, |
| 61 int render_process_id, | 61 int render_process_id, |
| 62 int render_frame_id, | 62 int render_frame_id, |
| 63 const content::URLDataSource::GotDataCallback& callback) { | 63 const content::URLDataSource::GotDataCallback& callback) { |
| 64 // Default scale factor if not specified. | 64 // Default scale factor if not specified. |
| 65 ui::ScaleFactor scale_factor; | 65 float scale_factor; |
|
pkotwicz
2014/05/20 03:31:19
Nit: default initialize float
oshima
2014/05/20 18:23:28
Done.
| |
| 66 std::string uncached_path; | 66 std::string uncached_path; |
| 67 webui::ParsePathAndScale(GURL(GetThemePath() + path), | 67 webui::ParsePathAndScale(GURL(GetThemePath() + path), |
| 68 &uncached_path, | 68 &uncached_path, |
| 69 &scale_factor); | 69 &scale_factor); |
| 70 | 70 |
| 71 if (uncached_path == kNewTabCSSPath || | 71 if (uncached_path == kNewTabCSSPath || |
| 72 uncached_path == kNewIncognitoTabCSSPath) { | 72 uncached_path == kNewIncognitoTabCSSPath) { |
| 73 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 73 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 74 | 74 |
| 75 callback.Run(css_bytes_.get()); | 75 callback.Run(css_bytes_.get()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 return InstantIOContext::ShouldServiceRequest(request); | 130 return InstantIOContext::ShouldServiceRequest(request); |
| 131 return URLDataSource::ShouldServiceRequest(request); | 131 return URLDataSource::ShouldServiceRequest(request); |
| 132 } | 132 } |
| 133 | 133 |
| 134 //////////////////////////////////////////////////////////////////////////////// | 134 //////////////////////////////////////////////////////////////////////////////// |
| 135 // ThemeSource, private: | 135 // ThemeSource, private: |
| 136 | 136 |
| 137 void ThemeSource::SendThemeBitmap( | 137 void ThemeSource::SendThemeBitmap( |
| 138 const content::URLDataSource::GotDataCallback& callback, | 138 const content::URLDataSource::GotDataCallback& callback, |
| 139 int resource_id, | 139 int resource_id, |
| 140 ui::ScaleFactor scale_factor) { | 140 float scale_factor) { |
| 141 ui::ScaleFactor resource_scale_factor = | |
| 142 ui::GetSupportedScaleFactor(scale_factor); | |
| 141 if (ThemeProperties::IsThemeableImage(resource_id)) { | 143 if (ThemeProperties::IsThemeableImage(resource_id)) { |
| 142 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 144 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 143 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); | 145 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); |
| 144 DCHECK(tp); | 146 DCHECK(tp); |
| 145 | 147 |
| 146 scoped_refptr<base::RefCountedMemory> image_data(tp->GetRawData( | 148 scoped_refptr<base::RefCountedMemory> image_data( |
| 147 resource_id, scale_factor)); | 149 tp->GetRawData(resource_id, resource_scale_factor)); |
| 148 callback.Run(image_data.get()); | 150 callback.Run(image_data.get()); |
| 149 } else { | 151 } else { |
| 150 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 152 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 151 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 153 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 152 callback.Run(rb.LoadDataResourceBytesForScale(resource_id, scale_factor)); | 154 callback.Run( |
| 155 rb.LoadDataResourceBytesForScale(resource_id, resource_scale_factor)); | |
| 153 } | 156 } |
| 154 } | 157 } |
| OLD | NEW |