• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_UI_WEBUI_THEME_SOURCE_H_
6 #define CHROME_BROWSER_UI_WEBUI_THEME_SOURCE_H_
7 #pragma once
8 
9 #include <string>
10 
11 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
12 
13 class Profile;
14 class RefCountedBytes;
15 
16 class ThemeSource : public ChromeURLDataManager::DataSource {
17  public:
18   explicit ThemeSource(Profile* profile);
19 
20   // Called when the network layer has requested a resource underneath
21   // the path we registered.
22   virtual void StartDataRequest(const std::string& path,
23                                 bool is_incognito,
24                                 int request_id);
25   virtual std::string GetMimeType(const std::string& path) const;
26 
27   // Used to tell ChromeURLDataManager which thread to handle the request on.
28   virtual MessageLoop* MessageLoopForRequestPath(const std::string& path) const;
29 
30   virtual bool ShouldReplaceExistingSource() const;
31 
32  protected:
33   virtual ~ThemeSource();
34 
35  private:
36   // Fetch and send the theme bitmap.
37   void SendThemeBitmap(int request_id, int resource_id);
38 
39   // The original profile (never an OTR profile).
40   Profile* profile_;
41 
42   // We grab the CSS early so we don't have to go back to the UI thread later.
43   scoped_refptr<RefCountedBytes> css_bytes_;
44 
45   DISALLOW_COPY_AND_ASSIGN(ThemeSource);
46 };
47 
48 #endif  // CHROME_BROWSER_UI_WEBUI_THEME_SOURCE_H_
49