2017-01-30 14:55:46 +03: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.
|
|
|
|
|
2021-11-22 10:34:31 +03:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_ZOOM_LEVEL_DELEGATE_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_ZOOM_LEVEL_DELEGATE_H_
|
2017-01-30 14:55:46 +03:00
|
|
|
|
2017-05-19 01:06:57 +03:00
|
|
|
#include <string>
|
|
|
|
|
2023-05-11 23:07:39 +03:00
|
|
|
#include "base/memory/raw_ptr.h"
|
2022-09-07 10:46:37 +03:00
|
|
|
#include "base/values.h"
|
2017-01-30 14:55:46 +03: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 {
|
2021-07-02 03:51:37 +03:00
|
|
|
class FilePath;
|
|
|
|
} // namespace base
|
2017-01-30 14:55:46 +03:00
|
|
|
|
|
|
|
class PrefRegistrySimple;
|
|
|
|
|
2018-10-19 21:51:43 +03:00
|
|
|
namespace electron {
|
2017-01-30 14:55:46 +03: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 14:41:45 +03:00
|
|
|
// disable copy
|
|
|
|
ZoomLevelDelegate(const ZoomLevelDelegate&) = delete;
|
|
|
|
ZoomLevelDelegate& operator=(const ZoomLevelDelegate&) = delete;
|
|
|
|
|
2017-01-30 14:55:46 +03:00
|
|
|
void SetDefaultZoomLevelPref(double level);
|
|
|
|
double GetDefaultZoomLevelPref() const;
|
|
|
|
|
|
|
|
// content::ZoomLevelDelegate:
|
|
|
|
void InitHostZoomMap(content::HostZoomMap* host_zoom_map) override;
|
|
|
|
|
|
|
|
private:
|
2022-09-07 10:46:37 +03:00
|
|
|
void ExtractPerHostZoomLevels(const base::Value::Dict& host_zoom_dictionary);
|
2017-01-30 14:55:46 +03:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
2023-05-11 23:07:39 +03:00
|
|
|
raw_ptr<PrefService> pref_service_;
|
|
|
|
raw_ptr<content::HostZoomMap> host_zoom_map_ = nullptr;
|
2020-12-14 21:57:36 +03:00
|
|
|
base::CallbackListSubscription zoom_subscription_;
|
2017-01-30 14:55:46 +03:00
|
|
|
std::string partition_key_;
|
|
|
|
};
|
|
|
|
|
2018-10-19 21:51:43 +03:00
|
|
|
} // namespace electron
|
2017-01-30 14:55:46 +03:00
|
|
|
|
2021-11-22 10:34:31 +03:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_ZOOM_LEVEL_DELEGATE_H_
|