blob: 96669a5ce954afe94a3f7cda2912292fec8c210f [file] [log] [blame]
dschuylera02f49932015-10-26 22:05:321// Copyright 2015 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_SETTINGS_FONT_HANDLER_H_
6#define CHROME_BROWSER_UI_WEBUI_SETTINGS_FONT_HANDLER_H_
7
dcheng9603ab92016-04-08 04:17:328#include <memory>
dschuylerd939f77f62016-04-06 00:44:339#include <string>
10
dschuylera02f49932015-10-26 22:05:3211#include "base/macros.h"
dschuylera02f49932015-10-26 22:05:3212#include "base/memory/weak_ptr.h"
dbeam7cbbde42016-03-11 17:54:1413#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
dschuylera02f49932015-10-26 22:05:3214
Kyle Horimoto549b3372020-05-08 18:41:0115class Profile;
16
dschuylera02f49932015-10-26 22:05:3217namespace base {
18class ListValue;
Kyle Horimoto549b3372020-05-08 18:41:0119} // namespace base
dschuylerd939f77f62016-04-06 00:44:3320
dschuylera02f49932015-10-26 22:05:3221namespace settings {
22
dschuyler08b1d3752016-10-08 02:45:4423// Handle OS font list and font preference settings.
Matt Falkenhagenda6aa732020-03-12 02:24:4324class FontHandler : public SettingsPageUIHandler {
dschuylera02f49932015-10-26 22:05:3225 public:
Kyle Horimoto549b3372020-05-08 18:41:0126 explicit FontHandler(Profile* profile);
dschuylera02f49932015-10-26 22:05:3227 ~FontHandler() override;
28
29 // SettingsPageUIHandler implementation.
30 void RegisterMessages() override;
tommyclib0e0efca2016-04-22 19:58:5231 void OnJavascriptAllowed() override;
32 void OnJavascriptDisallowed() override;
dschuyler9aebfe152016-04-12 18:18:4333
dschuylera02f49932015-10-26 22:05:3234 private:
35 // Handler for script asking for font information.
36 void HandleFetchFontsData(const base::ListValue* args);
37
dschuylera02f49932015-10-26 22:05:3238 // Callback to handle fonts loading.
dschuylerd939f77f62016-04-06 00:44:3339 void FontListHasLoaded(std::string callback_id,
dcheng9603ab92016-04-08 04:17:3240 std::unique_ptr<base::ListValue> list);
dschuylerd939f77f62016-04-06 00:44:3341
Jeremy Roman495db682019-07-12 16:03:2442 base::WeakPtrFactory<FontHandler> weak_ptr_factory_{this};
dschuylera02f49932015-10-26 22:05:3243
44 DISALLOW_COPY_AND_ASSIGN(FontHandler);
45};
46
47} // namespace settings
48
49#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_FONT_HANDLER_H_