CordovaWebViewEngine.java 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. Licensed to the Apache Software Foundation (ASF) under one
  3. or more contributor license agreements. See the NOTICE file
  4. distributed with this work for additional information
  5. regarding copyright ownership. The ASF licenses this file
  6. to you under the Apache License, Version 2.0 (the
  7. "License"); you may not use this file except in compliance
  8. with the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing,
  11. software distributed under the License is distributed on an
  12. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  13. KIND, either express or implied. See the License for the
  14. specific language governing permissions and limitations
  15. under the License.
  16. */
  17. package org.apache.cordova;
  18. import android.view.KeyEvent;
  19. import android.view.View;
  20. import android.webkit.ValueCallback;
  21. /**
  22. * Interface for all Cordova engines.
  23. * No methods will be added to this class (in order to be compatible with existing engines).
  24. * Instead, we will create a new interface: e.g. CordovaWebViewEngineV2
  25. */
  26. public interface CordovaWebViewEngine {
  27. void init(CordovaWebView parentWebView, CordovaInterface cordova, Client client,
  28. CordovaResourceApi resourceApi, PluginManager pluginManager,
  29. NativeToJsMessageQueue nativeToJsMessageQueue);
  30. CordovaWebView getCordovaWebView();
  31. ICordovaCookieManager getCookieManager();
  32. View getView();
  33. void loadUrl(String url, boolean clearNavigationStack);
  34. void stopLoading();
  35. /** Return the currently loaded URL */
  36. String getUrl();
  37. void clearCache();
  38. /** After calling clearHistory(), canGoBack() should be false. */
  39. void clearHistory();
  40. boolean canGoBack();
  41. /** Returns whether a navigation occurred */
  42. boolean goBack();
  43. /** Pauses / resumes the WebView's event loop. */
  44. void setPaused(boolean value);
  45. /** Clean up all resources associated with the WebView. */
  46. void destroy();
  47. /** Add the evaulate Javascript method **/
  48. void evaluateJavascript(String js, ValueCallback<String> callback);
  49. /**
  50. * Used to retrieve the associated CordovaWebView given a View without knowing the type of Engine.
  51. * E.g. ((CordovaWebView.EngineView)activity.findViewById(android.R.id.webView)).getCordovaWebView();
  52. */
  53. public interface EngineView {
  54. CordovaWebView getCordovaWebView();
  55. }
  56. /**
  57. * Contains methods that an engine uses to communicate with the parent CordovaWebView.
  58. * Methods may be added in future cordova versions, but never removed.
  59. */
  60. public interface Client {
  61. Boolean onDispatchKeyEvent(KeyEvent event);
  62. void clearLoadTimeoutTimer();
  63. void onPageStarted(String newUrl);
  64. void onReceivedError(int errorCode, String description, String failingUrl);
  65. void onPageFinishedLoading(String url);
  66. boolean onNavigationAttempt(String url);
  67. }
  68. }