Ejemplo n.º 1
0
  /**
   * Handle messages posted to us.
   *
   * @param msg The message to handle.
   */
  @Override
  public void handleMessage(Message msg) {
    switch (msg.what) {
      case FRAME_COMPLETED:
        {
          if (mSettings.getSavePassword() && hasPasswordField()) {
            if (WebView.DEBUG) {
              Assert.assertNotNull(mCallbackProxy.getBackForwardList().getCurrentItem());
            }
            WebAddress uri =
                new WebAddress(mCallbackProxy.getBackForwardList().getCurrentItem().getUrl());
            String schemePlusHost = uri.mScheme + uri.mHost;
            String[] up = mDatabase.getUsernamePassword(schemePlusHost);
            if (up != null && up[0] != null) {
              setUsernamePassword(up[0], up[1]);
            }
          }
          CacheManager.trimCacheIfNeeded();
          break;
        }

      case POLICY_FUNCTION:
        {
          nativeCallPolicyFunction(msg.arg1, msg.arg2);
          break;
        }

      default:
        break;
    }
  }
  /**
   * Handle messages posted to us.
   *
   * @param msg The message to handle.
   */
  @Override
  public void handleMessage(Message msg) {
    if (mBlockMessages) {
      return;
    }
    switch (msg.what) {
      case FRAME_COMPLETED:
        {
          if (mSettings.getSavePassword() && hasPasswordField()) {
            WebHistoryItem item = mCallbackProxy.getBackForwardList().getCurrentItem();
            if (item != null) {
              WebAddress uri = new WebAddress(item.getUrl());
              String schemePlusHost = uri.getScheme() + uri.getHost();
              String[] up = mDatabase.getUsernamePassword(schemePlusHost);
              if (up != null && up[0] != null) {
                setUsernamePassword(up[0], up[1]);
              }
            }
          }
          if (!JniUtil.useChromiumHttpStack()) {
            WebViewWorker.getHandler().sendEmptyMessage(WebViewWorker.MSG_TRIM_CACHE);
          }
          break;
        }

      case POLICY_FUNCTION:
        {
          nativeCallPolicyFunction(msg.arg1, msg.arg2);
          break;
        }

      case ORIENTATION_CHANGED:
        {
          if (mOrientation != msg.arg1) {
            mOrientation = msg.arg1;
            nativeOrientationChanged(msg.arg1);
          }
          break;
        }

      default:
        break;
    }
  }