summaryrefslogtreecommitdiff
path: root/chromium/components/services/font/font_service_app.h
blob: 949551b69494228a220592aec17993be4c3621b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_SERVICES_FONT_FONT_SERVICE_APP_H_
#define COMPONENTS_SERVICES_FONT_FONT_SERVICE_APP_H_

#include <stdint.h>
#include <vector>

#include "base/files/file_path.h"
#include "components/services/font/public/mojom/font_service.mojom.h"
#include "mojo/public/cpp/bindings/receiver_set.h"

namespace font_service {

class FontServiceApp : public mojom::FontService {
 public:
  FontServiceApp();

  FontServiceApp(const FontServiceApp&) = delete;
  FontServiceApp& operator=(const FontServiceApp&) = delete;

  ~FontServiceApp() override;

  void BindReceiver(mojo::PendingReceiver<mojom::FontService> receiver);

 private:
  // FontService:
  void MatchFamilyName(const std::string& family_name,
                       mojom::TypefaceStylePtr requested_style,
                       MatchFamilyNameCallback callback) override;
  void OpenStream(uint32_t id_number, OpenStreamCallback callback) override;
  void FallbackFontForCharacter(
      uint32_t character,
      const std::string& locale,
      FallbackFontForCharacterCallback callback) override;
  void FontRenderStyleForStrike(
      const std::string& family,
      uint32_t size,
      bool italic,
      bool bold,
      float device_scale_factor,
      FontRenderStyleForStrikeCallback callback) override;
  void MatchFontByPostscriptNameOrFullFontName(
      const std::string& family,
      MatchFontByPostscriptNameOrFullFontNameCallback callback) override;
  void MatchFontWithFallback(const std::string& family,
                             bool is_bold,
                             bool is_italic,
                             uint32_t charset,
                             uint32_t fallbackFamilyType,
                             MatchFontWithFallbackCallback callback) override;
  size_t FindOrAddPath(const base::FilePath& path);

  mojo::ReceiverSet<mojom::FontService> receivers_;

  // We don't want to leak paths to our callers; we thus enumerate the paths of
  // fonts.
  std::vector<base::FilePath> paths_;
};

}  // namespace font_service

#endif  // COMPONENTS_SERVICES_FONT_FONT_SERVICE_APP_H_