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 #ifndef CHROME_BROWSER_UI_WEBUI_THEME_SOURCE_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_THEME_SOURCE_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_THEME_SOURCE_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_THEME_SOURCE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "content/public/browser/url_data_source_delegate.h" | 12 #include "content/public/browser/url_data_source.h" |
13 #include "ui/base/layout.h" | 13 #include "ui/base/layout.h" |
14 | 14 |
15 class Profile; | 15 class Profile; |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class RefCountedMemory; | 18 class RefCountedMemory; |
19 } | 19 } |
20 | 20 |
21 class ThemeSource : public content::URLDataSourceDelegate { | 21 class ThemeSource : public content::URLDataSource { |
22 public: | 22 public: |
23 explicit ThemeSource(Profile* profile); | 23 explicit ThemeSource(Profile* profile); |
| 24 virtual ~ThemeSource(); |
24 | 25 |
25 // content::URLDataSourceDelegate implementation. | 26 // content::URLDataSource implementation. |
26 virtual std::string GetSource() OVERRIDE; | 27 virtual std::string GetSource() OVERRIDE; |
27 virtual void StartDataRequest(const std::string& path, | 28 virtual void StartDataRequest( |
28 bool is_incognito, | 29 const std::string& path, |
29 int request_id) OVERRIDE; | 30 bool is_incognito, |
| 31 const content::URLDataSource::GotDataCallback& callback) OVERRIDE; |
30 virtual std::string GetMimeType(const std::string& path) const OVERRIDE; | 32 virtual std::string GetMimeType(const std::string& path) const OVERRIDE; |
31 virtual MessageLoop* MessageLoopForRequestPath( | 33 virtual MessageLoop* MessageLoopForRequestPath( |
32 const std::string& path) const OVERRIDE; | 34 const std::string& path) const OVERRIDE; |
33 virtual bool ShouldReplaceExistingSource() const OVERRIDE; | 35 virtual bool ShouldReplaceExistingSource() const OVERRIDE; |
34 | 36 |
35 protected: | |
36 virtual ~ThemeSource(); | |
37 | |
38 private: | 37 private: |
39 // Fetch and send the theme bitmap. | 38 // Fetch and send the theme bitmap. |
40 void SendThemeBitmap(int request_id, | 39 void SendThemeBitmap( |
41 int resource_id, | 40 const content::URLDataSource::GotDataCallback& callback, |
42 ui::ScaleFactor scale_factor); | 41 int resource_id, |
| 42 ui::ScaleFactor scale_factor); |
43 | 43 |
44 // The original profile (never an OTR profile). | 44 // The original profile (never an OTR profile). |
45 Profile* profile_; | 45 Profile* profile_; |
46 | 46 |
47 // We grab the CSS early so we don't have to go back to the UI thread later. | 47 // We grab the CSS early so we don't have to go back to the UI thread later. |
48 scoped_refptr<base::RefCountedMemory> css_bytes_; | 48 scoped_refptr<base::RefCountedMemory> css_bytes_; |
49 | 49 |
50 DISALLOW_COPY_AND_ASSIGN(ThemeSource); | 50 DISALLOW_COPY_AND_ASSIGN(ThemeSource); |
51 }; | 51 }; |
52 | 52 |
53 #endif // CHROME_BROWSER_UI_WEBUI_THEME_SOURCE_H_ | 53 #endif // CHROME_BROWSER_UI_WEBUI_THEME_SOURCE_H_ |
OLD | NEW |