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