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/ui/webui/theme_source.h" | 5 #include "chrome/browser/ui/webui/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/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/resources_util.h" | 10 #include "chrome/browser/resources_util.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 : DataSource(chrome::kChromeUIThemePath, MessageLoop::current()), | 34 : DataSource(chrome::kChromeUIThemePath, MessageLoop::current()), |
35 profile_(profile->GetOriginalProfile()) { | 35 profile_(profile->GetOriginalProfile()) { |
36 css_bytes_ = profile_->GetNTPResourceCache()->GetNewTabCSS( | 36 css_bytes_ = profile_->GetNTPResourceCache()->GetNewTabCSS( |
37 profile->IsOffTheRecord()); | 37 profile->IsOffTheRecord()); |
38 } | 38 } |
39 | 39 |
40 ThemeSource::~ThemeSource() { | 40 ThemeSource::~ThemeSource() { |
41 } | 41 } |
42 | 42 |
43 void ThemeSource::StartDataRequest(const std::string& path, | 43 void ThemeSource::StartDataRequest(const std::string& path, |
44 bool is_off_the_record, | 44 bool is_incognito, |
45 int request_id) { | 45 int request_id) { |
46 // Our path may include cachebuster arguments, so trim them off. | 46 // Our path may include cachebuster arguments, so trim them off. |
47 std::string uncached_path = StripQueryParams(path); | 47 std::string uncached_path = StripQueryParams(path); |
48 | 48 |
49 if (uncached_path == kNewTabCSSPath || | 49 if (uncached_path == kNewTabCSSPath || |
50 uncached_path == kNewIncognitoTabCSSPath) { | 50 uncached_path == kNewIncognitoTabCSSPath) { |
51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
52 DCHECK((uncached_path == kNewTabCSSPath && !is_off_the_record) || | 52 DCHECK((uncached_path == kNewTabCSSPath && !is_incognito) || |
53 (uncached_path == kNewIncognitoTabCSSPath && is_off_the_record)); | 53 (uncached_path == kNewIncognitoTabCSSPath && is_incognito)); |
54 | 54 |
55 SendResponse(request_id, css_bytes_); | 55 SendResponse(request_id, css_bytes_); |
56 return; | 56 return; |
57 } else { | 57 } else { |
58 int resource_id = ResourcesUtil::GetThemeResourceId(uncached_path); | 58 int resource_id = ResourcesUtil::GetThemeResourceId(uncached_path); |
59 if (resource_id != -1) { | 59 if (resource_id != -1) { |
60 SendThemeBitmap(request_id, resource_id); | 60 SendThemeBitmap(request_id, resource_id); |
61 return; | 61 return; |
62 } | 62 } |
63 } | 63 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 DCHECK(tp); | 111 DCHECK(tp); |
112 | 112 |
113 scoped_refptr<RefCountedMemory> image_data(tp->GetRawData(resource_id)); | 113 scoped_refptr<RefCountedMemory> image_data(tp->GetRawData(resource_id)); |
114 SendResponse(request_id, image_data); | 114 SendResponse(request_id, image_data); |
115 } else { | 115 } else { |
116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
117 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 117 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
118 SendResponse(request_id, rb.LoadDataResourceBytes(resource_id)); | 118 SendResponse(request_id, rb.LoadDataResourceBytes(resource_id)); |
119 } | 119 } |
120 } | 120 } |
OLD | NEW |