[Extensions Toolbar Mac] Fix actions bar min size, spacing
[chromium-blink-merge.git] / chrome / browser / ui / webui / theme_source.h
blobd6d0d1f8050c6c814355e244ab52fcca4e6af4c6
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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_THEME_SOURCE_H_
6 #define CHROME_BROWSER_UI_WEBUI_THEME_SOURCE_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "base/memory/ref_counted.h"
12 #include "content/public/browser/url_data_source.h"
14 class Profile;
16 namespace base {
17 class RefCountedMemory;
20 class ThemeSource : public content::URLDataSource {
21 public:
22 explicit ThemeSource(Profile* profile);
23 ~ThemeSource() override;
25 // content::URLDataSource implementation.
26 std::string GetSource() const override;
27 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 std::string GetMimeType(const std::string& path) const override;
33 base::MessageLoop* MessageLoopForRequestPath(
34 const std::string& path) const override;
35 bool ShouldReplaceExistingSource() const override;
36 bool ShouldServiceRequest(const net::URLRequest* request) const override;
38 private:
39 // Fetch and send the theme bitmap.
40 void SendThemeBitmap(const content::URLDataSource::GotDataCallback& callback,
41 int resource_id,
42 float scale_factor);
44 // Similar to SendThemeBitmap but treat the responded data as image; if the
45 // resource bundle does not contain the data for |scale_factor|, the resource
46 // bundle falls back to the data of a lower scale, which means smaller images
47 // will be served and webui handles the image incorrectly.
48 // See crbug.com/442384.
49 void SendThemeImage(const content::URLDataSource::GotDataCallback& callback,
50 int resource_id,
51 float scale_factor);
53 // The original profile (never an OTR profile).
54 Profile* profile_;
56 // We grab the CSS early so we don't have to go back to the UI thread later.
57 scoped_refptr<base::RefCountedMemory> css_bytes_;
59 DISALLOW_COPY_AND_ASSIGN(ThemeSource);
62 #endif // CHROME_BROWSER_UI_WEBUI_THEME_SOURCE_H_