0

I have build simple desktop application, which is loading content into webview element.

Now I am looking for some options how to resize application window based on some Javascript action called from DOM inside webview.

For example: By default I am displaying some information related to the team of people using this Chrome application on their desktop. These data are being fetched from PHP application running on our servera rendered using HTML/CSS/jQuery. Now I would like to render some form, which will give us options to edit this content directly inside Chrome application and store them in database, but the issue is, that by default is Chrome application very small: approx. 200x300px and at the moment, when I render this form I would need to resize whole application to approx. 300x500px and I have no idea how to achieve that.

I was browsing in Chrome apps documentation where i have found some info related to app.window, but I did not find a way, how to apply this into the real world app and execute such a commands via Javascript inside webview element.

Thank you for any ideas and suggestions.

iguana007
  • 15
  • 1
  • 8

1 Answers1

0

You won't be able to do that from inside the webview. You are correct that chrome.app.window is the required API, but a webview-embedded page has no privileges to call it.

You'll need to communicate with your app's script, which has the necessary privileges. I would actually recommend using the "externally_connectable" method since it's for a specific site.

Once you've passed a message to the app page's script, you can resize the window with

chrome.app.window.current().innerBounds.setSize(width, height)

or, in case of a listener in the event page,

chrome.app.window.get(windowId).innerBounds.setSize(width, height)

Note that you can set the initial size when creating the window.

Xan
  • 74,770
  • 16
  • 179
  • 206
  • Thank you, I will try to study, how to achieve this communication between app and webview. – iguana007 May 27 '15 at 12:06
  • I have studied how to achieve this and if I add into browser.js loaded inside html file defined in manifest console.log(e.data); consele outputs "Hello host!" message, so this seems to be working fine, but I cannot figure out, how to change the bounds size - could you give me a hint please? – iguana007 Jun 02 '15 at 14:47