2017-01-30 11:55:46 +00:00
|
|
|
// Copyright 2014 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.
|
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#ifndef SHELL_BROWSER_ZOOM_LEVEL_DELEGATE_H_
|
|
|
|
#define SHELL_BROWSER_ZOOM_LEVEL_DELEGATE_H_
|
2017-01-30 11:55:46 +00:00
|
|
|
|
2017-05-18 22:06:57 +00:00
|
|
|
#include <string>
|
|
|
|
|
2017-01-30 11:55:46 +00:00
|
|
|
#include "components/prefs/pref_service.h"
|
|
|
|
#include "content/public/browser/host_zoom_map.h"
|
|
|
|
#include "content/public/browser/zoom_level_delegate.h"
|
|
|
|
|
|
|
|
namespace base {
|
|
|
|
class DictionaryValue;
|
2021-07-02 00:51:37 +00:00
|
|
|
class FilePath;
|
|
|
|
} // namespace base
|
2017-01-30 11:55:46 +00:00
|
|
|
|
|
|
|
class PrefRegistrySimple;
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
namespace electron {
|
2017-01-30 11:55:46 +00:00
|
|
|
|
|
|
|
// A class to manage per-partition default and per-host zoom levels.
|
|
|
|
// It implements an interface between the content/ zoom
|
|
|
|
// levels in HostZoomMap and preference system. All changes
|
|
|
|
// to the per-partition default zoom levels flow through this
|
|
|
|
// class. Any changes to per-host levels are updated when HostZoomMap calls
|
|
|
|
// OnZoomLevelChanged.
|
|
|
|
class ZoomLevelDelegate : public content::ZoomLevelDelegate {
|
|
|
|
public:
|
|
|
|
static void RegisterPrefs(PrefRegistrySimple* pref_registry);
|
|
|
|
|
|
|
|
ZoomLevelDelegate(PrefService* pref_service,
|
|
|
|
const base::FilePath& partition_path);
|
|
|
|
~ZoomLevelDelegate() override;
|
|
|
|
|
2021-11-03 11:41:45 +00:00
|
|
|
// disable copy
|
|
|
|
ZoomLevelDelegate(const ZoomLevelDelegate&) = delete;
|
|
|
|
ZoomLevelDelegate& operator=(const ZoomLevelDelegate&) = delete;
|
|
|
|
|
2017-01-30 11:55:46 +00:00
|
|
|
void SetDefaultZoomLevelPref(double level);
|
|
|
|
double GetDefaultZoomLevelPref() const;
|
|
|
|
|
|
|
|
// content::ZoomLevelDelegate:
|
|
|
|
void InitHostZoomMap(content::HostZoomMap* host_zoom_map) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void ExtractPerHostZoomLevels(
|
|
|
|
const base::DictionaryValue* host_zoom_dictionary);
|
|
|
|
|
|
|
|
// This is a callback function that receives notifications from HostZoomMap
|
|
|
|
// when per-host zoom levels change. It is used to update the per-host
|
|
|
|
// zoom levels (if any) managed by this class (for its associated partition).
|
|
|
|
void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change);
|
|
|
|
|
|
|
|
PrefService* pref_service_;
|
2021-01-26 18:16:21 +00:00
|
|
|
content::HostZoomMap* host_zoom_map_ = nullptr;
|
2020-12-14 18:57:36 +00:00
|
|
|
base::CallbackListSubscription zoom_subscription_;
|
2017-01-30 11:55:46 +00:00
|
|
|
std::string partition_key_;
|
|
|
|
};
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|
2017-01-30 11:55:46 +00:00
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#endif // SHELL_BROWSER_ZOOM_LEVEL_DELEGATE_H_
|