Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / common / font_cache_dispatcher_win.h
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 CONTENT_COMMON_FONT_CACHE_DISPATCHER_WIN_H_
6 #define CONTENT_COMMON_FONT_CACHE_DISPATCHER_WIN_H_
7
8 #include <windows.h>
9
10 #include "base/basictypes.h"
11 #include "base/memory/singleton.h"
12 #include "ipc/ipc_sender.h"
13 #include "ipc/message_filter.h"
14
15 namespace IPC {
16 class Channel;
17 }
18
19 namespace content {
20
21 // Dispatches messages used for font caching on Windows. This is needed because
22 // Windows can't load fonts into its kernel cache in sandboxed processes. So the
23 // sandboxed process asks the browser process to do this for it.
24 class FontCacheDispatcher : public IPC::MessageFilter, public IPC::Sender {
25  public:
26   FontCacheDispatcher();
27   virtual ~FontCacheDispatcher();
28
29   // IPC::Sender implementation:
30   virtual bool Send(IPC::Message* message) OVERRIDE;
31
32  private:
33   // IPC::MessageFilter implementation:
34   virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE;
35   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
36   virtual void OnChannelClosing() OVERRIDE;
37
38   // Message handlers.
39   void OnPreCacheFont(const LOGFONT& font);
40   void OnReleaseCachedFonts();
41
42   IPC::Channel* channel_;
43
44   DISALLOW_COPY_AND_ASSIGN(FontCacheDispatcher);
45 };
46
47 }  // namespace content
48
49 #endif  // CONTENT_COMMON_FONT_CACHE_DISPATCHER_WIN_H_