| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 ThemeSource::~ThemeSource() { | 50 ThemeSource::~ThemeSource() { |
| 51 } | 51 } |
| 52 | 52 |
| 53 std::string ThemeSource::GetSource() { | 53 std::string ThemeSource::GetSource() { |
| 54 return chrome::kChromeUIThemePath; | 54 return chrome::kChromeUIThemePath; |
| 55 } | 55 } |
| 56 | 56 |
| 57 void ThemeSource::StartDataRequest( | 57 void ThemeSource::StartDataRequest( |
| 58 const std::string& path, | 58 const std::string& path, |
| 59 bool is_incognito, | 59 const content::URLDataSource::ExtraRequestInfo& info, |
| 60 const content::URLDataSource::GotDataCallback& callback) { | 60 const content::URLDataSource::GotDataCallback& callback) { |
| 61 // Default scale factor if not specified. | 61 // Default scale factor if not specified. |
| 62 ui::ScaleFactor scale_factor; | 62 ui::ScaleFactor scale_factor; |
| 63 std::string uncached_path; | 63 std::string uncached_path; |
| 64 webui::ParsePathAndScale(GURL(GetThemePath() + path), | 64 webui::ParsePathAndScale(GURL(GetThemePath() + path), |
| 65 &uncached_path, | 65 &uncached_path, |
| 66 &scale_factor); | 66 &scale_factor); |
| 67 | 67 |
| 68 if (uncached_path == kNewTabCSSPath || | 68 if (uncached_path == kNewTabCSSPath || |
| 69 uncached_path == kNewIncognitoTabCSSPath) { | 69 uncached_path == kNewIncognitoTabCSSPath) { |
| 70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 71 DCHECK((uncached_path == kNewTabCSSPath && !is_incognito) || | 71 DCHECK((uncached_path == kNewTabCSSPath && !info.is_incognito) || |
| 72 (uncached_path == kNewIncognitoTabCSSPath && is_incognito)); | 72 (uncached_path == kNewIncognitoTabCSSPath && info.is_incognito)); |
| 73 | 73 |
| 74 callback.Run(css_bytes_); | 74 callback.Run(css_bytes_); |
| 75 return; | 75 return; |
| 76 } | 76 } |
| 77 | 77 |
| 78 | 78 |
| 79 int resource_id = ResourcesUtil::GetThemeResourceId(uncached_path); | 79 int resource_id = ResourcesUtil::GetThemeResourceId(uncached_path); |
| 80 if (resource_id != -1) { | 80 if (resource_id != -1) { |
| 81 SendThemeBitmap(callback, resource_id, scale_factor); | 81 SendThemeBitmap(callback, resource_id, scale_factor); |
| 82 return; | 82 return; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 scoped_refptr<base::RefCountedMemory> image_data(tp->GetRawData( | 145 scoped_refptr<base::RefCountedMemory> image_data(tp->GetRawData( |
| 146 resource_id, scale_factor)); | 146 resource_id, scale_factor)); |
| 147 callback.Run(image_data); | 147 callback.Run(image_data); |
| 148 } else { | 148 } else { |
| 149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 150 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 150 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 151 callback.Run(rb.LoadDataResourceBytesForScale(resource_id, scale_factor)); | 151 callback.Run(rb.LoadDataResourceBytesForScale(resource_id, scale_factor)); |
| 152 } | 152 } |
| 153 } | 153 } |
| OLD | NEW |