fix signature of zoom getter apis
authordeepak1556 <hop2deep@gmail.com>
Wed, 15 Feb 2017 22:14:24 +0000 (03:44 +0530)
committerdeepak1556 <hop2deep@gmail.com>
Fri, 17 Feb 2017 20:04:32 +0000 (01:34 +0530)
atom/browser/api/atom_api_web_contents.cc
lib/browser/api/web-contents.js
lib/browser/guest-view-manager.js

index 3fc2243..89e7a7d 100644 (file)
@@ -1672,9 +1672,9 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
       .SetMethod("getFrameRate", &WebContents::GetFrameRate)
       .SetMethod("invalidate", &WebContents::Invalidate)
       .SetMethod("setZoomLevel", &WebContents::SetZoomLevel)
-      .SetMethod("getZoomLevel", &WebContents::GetZoomLevel)
+      .SetMethod("_getZoomLevel", &WebContents::GetZoomLevel)
       .SetMethod("setZoomFactor", &WebContents::SetZoomFactor)
-      .SetMethod("getZoomFactor", &WebContents::GetZoomFactor)
+      .SetMethod("_getZoomFactor", &WebContents::GetZoomFactor)
       .SetMethod("getType", &WebContents::GetType)
       .SetMethod("getWebPreferences", &WebContents::GetWebPreferences)
       .SetMethod("getOwnerBrowserWindow", &WebContents::GetOwnerBrowserWindow)
index c94bd76..c43a288 100644 (file)
@@ -206,6 +206,26 @@ WebContents.prototype.printToPDF = function (options, callback) {
   this._printToPDF(printingSetting, callback)
 }
 
+WebContents.prototype.getZoomLevel = function (callback) {
+  if (typeof callback !== 'function') {
+    throw new Error('Must pass function as an argument')
+  }
+  process.nextTick(() => {
+    const zoomLevel = this._getZoomLevel()
+    callback(zoomLevel)
+  })
+}
+
+WebContents.prototype.getZoomFactor = function (callback) {
+  if (typeof callback !== 'function') {
+    throw new Error('Must pass function as an argument')
+  }
+  process.nextTick(() => {
+    const zoomFactor = this._getZoomFactor()
+    callback(zoomFactor)
+  })
+}
+
 // Add JavaScript wrappers for WebContents class.
 WebContents.prototype._init = function () {
   // The navigation controller.
index e61b257..83a5682 100644 (file)
@@ -184,7 +184,6 @@ const attachGuest = function (event, elementInstanceId, guestInstanceId, params)
     guestInstanceId: guestInstanceId,
     nodeIntegration: params.nodeintegration != null ? params.nodeintegration : false,
     plugins: params.plugins,
-    zoomFactor: embedder.getZoomFactor(),
     webSecurity: !params.disablewebsecurity,
     blinkFeatures: params.blinkfeatures,
     disableBlinkFeatures: params.disableblinkfeatures
@@ -213,15 +212,18 @@ const attachGuest = function (event, elementInstanceId, guestInstanceId, params)
     return
   }
 
-  webViewManager.addGuest(guestInstanceId, elementInstanceId, embedder, guest, webPreferences)
-  guest.attachParams = params
-  embedderElementsMap[key] = guestInstanceId
+  embedder.getZoomFactor(function (zoomFactor) {
+    webPreferences.zoomFactor = zoomFactor
+    webViewManager.addGuest(guestInstanceId, elementInstanceId, embedder, guest, webPreferences)
+    guest.attachParams = params
+    embedderElementsMap[key] = guestInstanceId
 
-  guest.setEmbedder(embedder)
-  guestInstance.embedder = embedder
-  guestInstance.elementInstanceId = elementInstanceId
+    guest.setEmbedder(embedder)
+    guestInstance.embedder = embedder
+    guestInstance.elementInstanceId = elementInstanceId
 
-  watchEmbedder(embedder)
+    watchEmbedder(embedder)
+  })
 }
 
 // Destroy an existing guest instance.