Exemplo n.º 1
0
 public static void destroy() {
   if (instance != null) {
     EventDispatcher.getInstance()
         .unregisterGeckoThreadListener((GeckoEventListener) instance, EVENTS);
     EventDispatcher.getInstance()
         .unregisterGeckoThreadListener((NativeEventListener) instance, NATIVE_EVENTS);
     instance = null;
   }
 }
Exemplo n.º 2
0
 public ZoomedView(Context context, AttributeSet attrs, int defStyle) {
   super(context, attrs, defStyle);
   isSimplifiedUI = true;
   isBlockedFromAppearing = false;
   getPrefs();
   currentZoomFactorIndex = 0;
   returnValue = new PointF();
   animationStart = new PointF();
   requestRenderRunnable =
       new Runnable() {
         @Override
         public void run() {
           requestZoomedViewRender();
         }
       };
   touchListener = new ZoomedViewTouchListener();
   EventDispatcher.getInstance()
       .registerGeckoThreadListener(
           this,
           "Gesture:clusteredLinksClicked",
           "Window:Resize",
           "Content:LocationChange",
           "Gesture:CloseZoomedView",
           "Browser:ZoomToPageWidth",
           "Browser:ZoomToRect",
           "FormAssist:AutoComplete",
           "FormAssist:Hide");
 }
Exemplo n.º 3
0
 public static void unregister() {
   if (DEBUG) {
     Log.d(LOGTAG, "Unregistered listener");
   }
   EventDispatcher.getInstance()
       .unregisterGeckoThreadListener(EVENT_LISTENER, "Gecko:ScheduleRun");
 }
Exemplo n.º 4
0
  DoorHangerPopup(GeckoApp activity) {
    super(activity);

    mDoorHangers = new HashSet<DoorHanger>();

    EventDispatcher.getInstance()
        .registerGeckoThreadListener(this, "Doorhanger:Add", "Doorhanger:Remove");
    Tabs.registerOnTabsChangedListener(this);
  }
Exemplo n.º 5
0
 void destroy() {
   if (prefObserver != null) {
     PrefsHelper.removeObserver(prefObserver);
     prefObserver = null;
   }
   ThreadUtils.removeCallbacksFromUiThread(requestRenderRunnable);
   EventDispatcher.getInstance()
       .unregisterGeckoThreadListener(
           this,
           "Gesture:clusteredLinksClicked",
           "Window:Resize",
           "Content:LocationChange",
           "Gesture:CloseZoomedView",
           "Browser:ZoomToPageWidth",
           "Browser:ZoomToRect",
           "FormAssist:AutoComplete",
           "FormAssist:Hide");
 }
Exemplo n.º 6
0
  private void init(Context context, String url, boolean doInit) {
    // TODO: Fennec currently takes care of its own initialization, so this
    // flag is a hack used in Fennec to prevent GeckoView initialization.
    // This should go away once Fennec also uses GeckoView for
    // initialization.
    if (!doInit) return;

    // If running outside of a GeckoActivity (eg, from a library project),
    // load the native code and disable content providers
    boolean isGeckoActivity = false;
    try {
      isGeckoActivity = context instanceof GeckoActivity;
    } catch (NoClassDefFoundError ex) {
    }

    if (!isGeckoActivity) {
      // Set the GeckoInterface if the context is an activity and the GeckoInterface
      // has not already been set
      if (context instanceof Activity && getGeckoInterface() == null) {
        setGeckoInterface(new BaseGeckoInterface(context));
      }

      Clipboard.init(context);
      HardwareUtils.init(context);

      // If you want to use GeckoNetworkManager, start it.

      GeckoLoader.loadMozGlue();
      BrowserDB.setEnableContentProviders(false);
    }

    if (url != null) {
      GeckoThread.setUri(url);
      GeckoThread.setAction(Intent.ACTION_VIEW);
      GeckoAppShell.sendEventToGecko(GeckoEvent.createURILoadEvent(url));
    }
    GeckoAppShell.setContextGetter(this);
    if (context instanceof Activity) {
      Tabs tabs = Tabs.getInstance();
      tabs.attachToContext(context);
    }

    EventDispatcher.getInstance()
        .registerGeckoThreadListener(
            this,
            "Gecko:Ready",
            "Content:StateChange",
            "Content:LoadError",
            "Content:PageShow",
            "DOMTitleChanged",
            "Link:Favicon",
            "Prompt:Show",
            "Prompt:ShowTop");

    ThreadUtils.setUiThread(Thread.currentThread(), new Handler());
    initializeView(EventDispatcher.getInstance());

    if (GeckoThread.checkAndSetLaunchState(
        GeckoThread.LaunchState.Launching, GeckoThread.LaunchState.Launched)) {
      // This is the first launch, so finish initialization and go.
      GeckoProfile profile = GeckoProfile.get(context).forceCreate();
      BrowserDB.initialize(profile.getName());

      GeckoAppShell.setLayerView(this);
      GeckoThread.createAndStart();
    } else if (GeckoThread.checkLaunchState(GeckoThread.LaunchState.GeckoRunning)) {
      // If Gecko is already running, that means the Activity was
      // destroyed, so we need to re-attach Gecko to this GeckoView.
      connectToGecko();
    }
  }
 private void onDestroy() {
   handleManagerEvent(ManagerEvent.stop);
   EventDispatcher.getInstance()
       .unregisterGeckoThreadListener(this, "Wifi:Enable", "Wifi:GetIPAddress");
 }
 private GeckoNetworkManager() {
   EventDispatcher.getInstance()
       .registerGeckoThreadListener(this, "Wifi:Enable", "Wifi:GetIPAddress");
 }
Exemplo n.º 9
0
 public void init() {
   mClearableNotifications = new HashMap<String, String>();
   EventDispatcher.getInstance()
       .registerGeckoThreadListener(this, "Notification:Show", "Notification:Hide");
   mInitialized = true;
 }
Exemplo n.º 10
0
  @WrapForJNI
  @Override
  public void notifyIME(final int type) {
    if (DEBUG) {
      // GeckoEditableListener methods should all be called from the Gecko thread
      ThreadUtils.assertOnGeckoThread();
      // NOTIFY_IME_REPLY_EVENT is logged separately, inside geckoActionReply()
      if (type != NOTIFY_IME_REPLY_EVENT) {
        Log.d(
            LOGTAG,
            "notifyIME(" + getConstantName(GeckoEditableListener.class, "NOTIFY_IME_", type) + ")");
      }
    }

    if (type == NOTIFY_IME_REPLY_EVENT) {
      try {
        if (mGeckoFocused) {
          // When mGeckoFocused is false, the reply is for a stale action,
          // and we should not do anything
          geckoActionReply();
        } else if (DEBUG) {
          Log.d(LOGTAG, "discarding stale reply");
        }
      } finally {
        // Ensure action is always removed from queue
        // even if stale action results in exception in geckoActionReply
        mActionQueue.poll();
      }
      return;
    } else if (type == NOTIFY_IME_TO_COMMIT_COMPOSITION) {
      notifyCommitComposition();
      return;
    } else if (type == NOTIFY_IME_TO_CANCEL_COMPOSITION) {
      notifyCancelComposition();
      return;
    }

    geckoPostToIc(
        new Runnable() {
          @Override
          public void run() {
            if (type == NOTIFY_IME_OF_FOCUS) {
              mFocused = true;
              // Unmask events on the Gecko side
              mActionQueue.offer(new Action(Action.TYPE_ACKNOWLEDGE_FOCUS));
            }

            // Make sure there are no other things going on. If we sent
            // Action.TYPE_ACKNOWLEDGE_FOCUS, this line also makes us
            // wait for Gecko to update us on the newly focused content
            mActionQueue.syncWithGecko();
            mListener.notifyIME(type);

            // Unset mFocused after we call syncWithGecko because
            // syncWithGecko becomes a no-op when mFocused is false.
            if (type == NOTIFY_IME_OF_BLUR) {
              mFocused = false;
            }
          }
        });

    // Register/unregister Gecko-side text selection listeners
    // and update the mGeckoFocused flag.
    if (type == NOTIFY_IME_OF_BLUR && mGeckoFocused) {
      // Check for focus here because Gecko may send us a blur before a focus in some
      // cases, and we don't want to unregister an event that was not registered.
      mGeckoFocused = false;
      mSuppressCompositions = false;
      EventDispatcher.getInstance()
          .unregisterGeckoThreadListener(this, "TextSelection:DraggingHandle");
    } else if (type == NOTIFY_IME_OF_FOCUS) {
      mGeckoFocused = true;
      mSuppressCompositions = false;
      EventDispatcher.getInstance()
          .registerGeckoThreadListener(this, "TextSelection:DraggingHandle");
    }
  }
Exemplo n.º 11
0
  @Override
  public void run() {
    Looper.prepare();
    GeckoThread.msgQueue = Looper.myQueue();
    ThreadUtils.sGeckoThread = this;
    ThreadUtils.sGeckoHandler = new Handler();

    // Preparation for pumpMessageLoop()
    final MessageQueue.IdleHandler idleHandler =
        new MessageQueue.IdleHandler() {
          @Override
          public boolean queueIdle() {
            final Handler geckoHandler = ThreadUtils.sGeckoHandler;
            Message idleMsg = Message.obtain(geckoHandler);
            // Use |Message.obj == GeckoHandler| to identify our "queue is empty" message
            idleMsg.obj = geckoHandler;
            geckoHandler.sendMessageAtFrontOfQueue(idleMsg);
            // Keep this IdleHandler
            return true;
          }
        };
    Looper.myQueue().addIdleHandler(idleHandler);

    if (mDebugging) {
      try {
        Thread.sleep(5 * 1000 /* 5 seconds */);
      } catch (final InterruptedException e) {
      }
    }

    final String args = getGeckoArgs(initGeckoEnvironment());

    // This can only happen after the call to initGeckoEnvironment
    // above, because otherwise the JNI code hasn't been loaded yet.
    ThreadUtils.postToUiThread(
        new Runnable() {
          @Override
          public void run() {
            GeckoAppShell.registerJavaUiThread();
          }
        });

    Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - runGecko");

    if (!AppConstants.MOZILLA_OFFICIAL) {
      Log.i(LOGTAG, "RunGecko - args = " + args);
    }

    // And go.
    GeckoLoader.nativeRun(args);

    // And... we're done.
    setState(State.EXITED);

    try {
      final JSONObject msg = new JSONObject();
      msg.put("type", "Gecko:Exited");
      EventDispatcher.getInstance().dispatchEvent(msg, null);
    } catch (final JSONException e) {
      Log.e(LOGTAG, "unable to dispatch event", e);
    }

    // Remove pumpMessageLoop() idle handler
    Looper.myQueue().removeIdleHandler(idleHandler);
  }
Exemplo n.º 12
0
 public Customer(int mandant, String name) {
   this.mandant = mandant;
   this.name = name;
   this.disp = EventDispatcher.getInstance();
 }
Exemplo n.º 13
0
 void destroy() {
   EventDispatcher.getInstance()
       .unregisterGeckoThreadListener(this, "Doorhanger:Add", "Doorhanger:Remove");
   Tabs.unregisterOnTabsChangedListener(this);
 }
Exemplo n.º 14
0
 private IntentHelper(Activity activity) {
   this.activity = activity;
   EventDispatcher.getInstance().registerGeckoThreadListener((GeckoEventListener) this, EVENTS);
   EventDispatcher.getInstance()
       .registerGeckoThreadListener((NativeEventListener) this, NATIVE_EVENTS);
 }