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