OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * Returns a promise that will resolve to the default zoom factor. | 8 * Returns a promise that will resolve to the default zoom factor. |
9 * @param {!Object} streamInfo The stream object pointing to the data contained | 9 * @param {!Object} streamInfo The stream object pointing to the data contained |
10 * in the PDF. | 10 * in the PDF. |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 /** | 129 /** |
130 * Returns how to manage the zoom. | 130 * Returns how to manage the zoom. |
131 * @return {BrowserApi.ZoomBehavior} How to manage zoom. | 131 * @return {BrowserApi.ZoomBehavior} How to manage zoom. |
132 */ | 132 */ |
133 getZoomBehavior() { | 133 getZoomBehavior() { |
134 return this.zoomBehavior_; | 134 return this.zoomBehavior_; |
135 } | 135 } |
136 | 136 |
137 /** | 137 /** |
138 * Adds an event listener to be notified when the browser zoom changes. | 138 * Adds an event listener to be notified when the browser zoom changes. |
139 * @param {function} listener The listener to be called with the new zoom | 139 * @param {!Function} listener The listener to be called with the new zoom |
140 * factor. | 140 * factor. |
141 */ | 141 */ |
142 addZoomEventListener(listener) { | 142 addZoomEventListener(listener) { |
143 if (!(this.zoomBehavior_ == BrowserApi.ZoomBehavior.MANAGE || | 143 if (!(this.zoomBehavior_ == BrowserApi.ZoomBehavior.MANAGE || |
144 this.zoomBehavior_ == BrowserApi.ZoomBehavior.PROPAGATE_PARENT)) | 144 this.zoomBehavior_ == BrowserApi.ZoomBehavior.PROPAGATE_PARENT)) |
145 return; | 145 return; |
146 | 146 |
147 chrome.tabs.onZoomChange.addListener(function(zoomChangeInfo) { | 147 chrome.tabs.onZoomChange.addListener(function(info) { |
| 148 var zoomChangeInfo = |
| 149 /** @type {{tabId: number, newZoomFactor: number}} */ (info); |
148 if (zoomChangeInfo.tabId != this.streamInfo_.tabId) | 150 if (zoomChangeInfo.tabId != this.streamInfo_.tabId) |
149 return; | 151 return; |
150 listener(zoomChangeInfo.newZoomFactor); | 152 listener(zoomChangeInfo.newZoomFactor); |
151 }.bind(this)); | 153 }.bind(this)); |
152 } | 154 } |
153 } | 155 } |
154 | 156 |
155 /** | 157 /** |
156 * Enumeration of ways to manage zoom changes. | 158 * Enumeration of ways to manage zoom changes. |
157 * @enum {number} | 159 * @enum {number} |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 * @return {Promise<BrowserApi>} A promise to a BrowserApi instance for the | 231 * @return {Promise<BrowserApi>} A promise to a BrowserApi instance for the |
230 * current environment. | 232 * current environment. |
231 */ | 233 */ |
232 function createBrowserApi() { | 234 function createBrowserApi() { |
233 if (location.origin === 'chrome://print') { | 235 if (location.origin === 'chrome://print') { |
234 return createBrowserApiForPrintPreview(); | 236 return createBrowserApiForPrintPreview(); |
235 } | 237 } |
236 | 238 |
237 return createBrowserApiForMimeHandlerView(); | 239 return createBrowserApiForMimeHandlerView(); |
238 } | 240 } |
OLD | NEW |