List of usage examples for com.google.gwt.gears.client Factory getPermission
public native boolean getPermission(String siteName, String imageUrl, String extraMessage) ;
From source file:org.sigmah.client.offline.sigmah.OnlineMode.java
License:Open Source License
/** * Verify if the usage of Google Gears has been approved by the user.<br> * If the permission hasn't been granted yet, this method will ask for * permission if <code>askForPermission</code> is true.<br> * <br>//from www. j a v a 2 s . co m * Also, this method creates the database * @param askForPermission <code>true</code> to ask for permission to use * Google Gears (only if needed), <code>false</code> otherwise. */ private void checkPermission(boolean askForPermission) { final Factory factory = Factory.getInstance(); if (factory != null && !databaseCheckIsDone) { if (!factory.hasPermission() && askForPermission) factory.getPermission("Sigmah", "desktopicons/48x48.png", I18N.CONSTANTS.sigmahOfflineDescription()); if (factory.hasPermission()) { localDatabase = factory.createDatabase(); // Verifying the existence of the "status" table localDatabase.open(LOCAL_DATABASE_NAME); try { localDatabase.execute("SELECT online FROM status WHERE id = 1"); } catch (DatabaseException ex) { // Most likely, the database doesn't exists. // Creating the database createStatusTable(); } finally { try { localDatabase.close(); } catch (DatabaseException ex) { Log.debug("Database closing error.", ex); } } databaseCheckIsDone = true; } } }