1// Copyright 2014 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/**
6 * @constructor
7 * @extends {WebInspector.Object}
8 * @param {!InspectorFrontendHostAPI} frontendHost
9 */
10WebInspector.ZoomManager = function(frontendHost)
11{
12    this._frontendHost = frontendHost;
13    this._zoomFactor = this._frontendHost.zoomFactor();
14    window.addEventListener("resize", this._onWindowResize.bind(this), true);
15};
16
17WebInspector.ZoomManager.Events = {
18    ZoomChanged: "ZoomChanged"
19};
20
21WebInspector.ZoomManager.prototype = {
22    /**
23     * @return {number}
24     */
25    zoomFactor: function()
26    {
27        return this._zoomFactor;
28    },
29
30    _onWindowResize: function()
31    {
32        var oldZoomFactor = this._zoomFactor;
33        this._zoomFactor = this._frontendHost.zoomFactor();
34        if (oldZoomFactor !== this._zoomFactor)
35            this.dispatchEventToListeners(WebInspector.ZoomManager.Events.ZoomChanged, {from: oldZoomFactor, to: this._zoomFactor});
36    },
37
38    __proto__: WebInspector.Object.prototype
39};
40
41/**
42 * @type {!WebInspector.ZoomManager}
43 */
44WebInspector.zoomManager;
45